コード例 #1
0
 /**
  * Assigns a constant rectangle to the input Gray8Image, replacing values in the image.
  *
  * @param image the input image (output replaces input).
  * @throws Error if the input is not a Gray8Image.
  */
 public void push(Image image) throws Error {
   if (!(image instanceof Gray8Image)) {
     throw new Error(
         Error.PACKAGE.ALGORITHM, ErrorCodes.IMAGE_NOT_GRAY8IMAGE, image.toString(), null, null);
   }
   Gray8Image input = (Gray8Image) image;
   byte[] data = input.getData();
   int nLimitY = Math.min(input.getHeight(), this.cY + this.nHeight);
   int nLimitX = Math.min(input.getWidth(), this.cX + this.nWidth);
   for (int i = this.cY; i < nLimitY; i++) {
     int nStart = i * image.getWidth();
     for (int j = this.cX; j < nLimitX; j++) {
       data[nStart + j] = this.bValue;
     }
   }
   super.setOutput(input);
 }
コード例 #2
0
 /**
  * Accepts a new MaskedGray8Image and initializes all the generator indices.
  *
  * @param image The input MaskedGray8Image.
  * @throws jjil.core.Error if the input is not of type MaskedGray8Image or is smaller than the
  *     subimages to be generated.
  */
 public void push(Image image) throws jjil.core.Error {
   if (!(image instanceof Gray8MaskedImage)) {
     throw new Error(
         Error.PACKAGE.ALGORITHM,
         ErrorCodes.OBJECT_NOT_EXPECTED_TYPE,
         image.toString(),
         "Gray8MaskedImage",
         null);
   }
   if (image.getWidth() < this.nWidth || image.getHeight() < this.nHeight) {
     throw new Error(
         Error.PACKAGE.ALGORITHM,
         ErrorCodes.IMAGE_TOO_SMALL,
         image.toString(),
         new Integer(this.nWidth).toString(),
         new Integer(this.nHeight).toString());
   }
   this.imageInput = (Gray8MaskedImage) image;
   // we want to find the largest integer l such that
   // (l-1) * w + w  <= iw
   // where l = computed limit on index
   // w = subimage width or height
   // iw = image width or height
   // or l = (iw - w) / w  + 1 (truncated)
   // Java division truncates
   this.nHorizLimit = (image.getWidth() - this.nWidth) / this.nXOffset;
   this.nVertLimit = (image.getHeight() - this.nHeight) / this.nYOffset;
   this.nHorizIndex = -1; // first time through increments
   this.nVertIndex = 0;
   this.oSubImageReady = false;
 }