Package jjil.core

Examples of jjil.core.Gray8Image


                    ErrorCodes.IMAGE_NOT_GRAY8IMAGE,
                    image.toString(),
                    null,
                    null);
        }
        Gray8Image input = (Gray8Image) image;
        byte[] data = input.getData();
        for (int i=0; i<data.length; i++) {
            data[i] = this.table[data[i]+128];
        }
        super.setOutput(input);
    }
View Full Code Here


                      ErrorCodes.IMAGE_NOT_GRAY8IMAGE,
                      image.toString(),
                      null,
                      null);
        }
        Gray8Image input = (Gray8Image) image;
        Gray8Image result = new Gray8Image(image.getWidth(), image.getHeight());
        byte[] bIn = input.getData();
        byte[] bResult = result.getData();
        int[] wCoeff = this.nCoeff[this.cSigma];
        int cWidth = input.getWidth();
        for (int i=0; i<input.getHeight(); i++) {
            for (int j=0; j<cWidth; j++) {
                /* left side of Gaussian */
 
View Full Code Here

    if (!(imageInput instanceof Gray8Image)) {
      throw new Error(Error.PACKAGE.ALGORITHM,
          ErrorCodes.IMAGE_NOT_GRAY8IMAGE, imageInput.toString(),
          null, null);
    }
    Gray8Image gray = (Gray8Image) imageInput;
    byte[] rb = gray.getData();
    for (int i=0; i<gray.getWidth()*gray.getHeight(); i++) {
      rb[i] = (byte) ((0xff&rb[i]) + Byte.MIN_VALUE);
    }
    super.setOutput(gray);
  }
View Full Code Here

        if (this.mg32 == null ||
            !this.mg32.getSize().equals(imageInput.getSize())) {
          this.mg32 = new Gray32Image(
              imageInput.getWidth(), imageInput.getHeight());
        }
        Gray8Image gray = (Gray8Image) imageInput;
        byte[] grayData = gray.getData();
        int[] gray32Data = this.mg32.getData();
        // First row
        int nSum = 0;
        for (int j=0; j<gray.getWidth(); j++) {
            /* Store unsigned byte value into Gray32Image
             */
            int grayUnsigned = 0xff & grayData[j];
            /* Assign 32-bit output */
            nSum += grayUnsigned;
            gray32Data[j] = nSum;
        }
        // Other rows
        for (int i=1; i<gray.getHeight(); i++) {
            nSum = 0;
            for (int j=0; j<gray.getWidth(); j++) {
                /* Get unsigned byte value as an int
                 */
                int grayUnsigned = grayData[i*gray.getWidth()+j] & 0xff;
                nSum += grayUnsigned;
                gray32Data[i*gray.getWidth()+j] =
                        gray32Data[(i-1)*gray.getWidth()+j] +
                        nSum;
            }
        }
        // now compute the average value at each pixel and subtract it
        // from the input, replacing the original image
        for (int i=0; i<gray.getHeight(); i++) {
          /* nTop and nBottom are the top and bottom rows of the averaging
           * window, taking into account edge effects
           */
          int nTop, nBottom;
          if (i<this.mnHeight/2) {
            nTop = 0;
            nBottom = this.mnHeight;
          } else if (i>=gray.getHeight()-this.mnHeight/2) {
            nBottom = gray.getHeight()-1;
            nTop = nBottom - this.mnHeight;
          } else {
            nTop = i-this.mnHeight/2;
            nBottom = i+this.mnHeight/2;           
          }
          for (int j=0; j<this.mnWidth/2; j++) {
            /* nLeft and nRigth are the left and right edges of the
             * averaging window, taking into account edge effects
             */
            int nLeft = 0;
            int nRight = this.mnWidth;
            // compute the sum of the averaging window using the cumulative
            // sum array
            nSum = gray32Data[nBottom*gray.getWidth()+nRight] -
              gray32Data[nTop*gray.getWidth()+nLeft];
            // compute the difference between this pixel and the averaged
            // value
            grayData[i*gray.getWidth()+j] =
              (byte) ((grayData[i*gray.getWidth()+j] & 0xff) -
                  nSum / (this.mnWidth * this.mnHeight));
          }
          for (int j=this.mnWidth/2; j<gray.getWidth()-this.mnWidth/2; j++) {
            /* nLeft and nRigth are the left and right edges of the
             * averaging window, taking into account edge effects
             */
            int nLeft = j-this.mnWidth/2;
            int nRight = j + this.mnWidth/2;
            // compute the sum of the averaging window using the cumulative
            // sum array
            nSum = gray32Data[nBottom*gray.getWidth()+nRight] -
              gray32Data[nTop*gray.getWidth()+nLeft];
            // compute the difference between this pixel and the averaged
            // value
            grayData[i*gray.getWidth()+j] =
              (byte) ((grayData[i*gray.getWidth()+j] & 0xff) -
                  nSum / (this.mnWidth * this.mnHeight));
          }
          for (int j=gray.getWidth()-this.mnWidth/2; j<gray.getWidth(); j++) {
            /* nLeft and nRigth are the left and right edges of the
             * averaging window, taking into account edge effects
             */
            int nRight = gray.getWidth()-1;
            int nLeft = nRight-this.mnWidth;
            // compute the sum of the averaging window using the cumulative
            // sum array
            nSum = gray32Data[nBottom*gray.getWidth()+nRight] -
              gray32Data[nTop*gray.getWidth()+nLeft];
            // compute the difference between this pixel and the averaged
            // value
            grayData[i*gray.getWidth()+j] =
              (byte) ((grayData[i*gray.getWidth()+j] & 0xff) -
                  nSum / (this.mnWidth * this.mnHeight));
          }
        }
        // output result
        super.setOutput(gray);
View Full Code Here

            image.toString(),
            null,
            null);
        }
        Gray32Image gray32 = (Gray32Image) image;
        Gray8Image gray8 = new Gray8Image(image.getWidth(), image.getHeight());
        int[] gray32Data = gray32.getData();
        byte[] gray8Data = gray8.getData();
        int nMax = Integer.MIN_VALUE;
        int nMin = Integer.MAX_VALUE;
        for (int i=0; i<gray32.getWidth() * gray32.getHeight(); i++) {
            nMax = Math.max(nMax, gray32Data[i]);
            nMin = Math.min(nMin, gray32Data[i]);
View Full Code Here

     * @throws jjil.core.Error if the input is not a Gray8Image or is too small.
     */
        
    public void push(Image image) throws jjil.core.Error
    {
        Gray8Image imGray;
        if (image instanceof Gray8Image) {
            imGray = (Gray8Image) image;
        } else {
            throw new Error(
                            Error.PACKAGE.ALGORITHM,
                            ErrorCodes.IMAGE_NOT_GRAY8IMAGE,
                            image.toString(),
                            null,
                            null);
        }
        if (image.getWidth() < this.hcc.getWidth() ||
            image.getHeight() < this.hcc.getHeight()) {
            throw new Error(
                            Error.PACKAGE.ALGORITHM,
                            ErrorCodes.IMAGE_TOO_SMALL,
                            image.toString(),
                            this.hcc.toString(),
                            null);
        }
        int nScale = Math.min(this.nMaxScale,
                Math.min(image.getWidth() / this.hcc.getWidth(),
                image.getHeight() / this.hcc.getHeight()));
        // Zero the mask
        Gray8Image imMask = new Gray8Image(1,1,Byte.MIN_VALUE);
        while (nScale >= this.nMinScale) {
            // shrink the input image
            int nTargetWidth = imGray.getWidth() / nScale;
            int nTargetHeight = imGray.getHeight() / nScale;
            Gray8Shrink gs = new Gray8Shrink(nTargetWidth, nTargetHeight);
            gs.push(imGray);
            Gray8Image imShrunk = (Gray8Image) gs.getFront();
            // scale the mask to the new size
            Gray8RectStretch grs = new Gray8RectStretch(nTargetWidth, nTargetHeight);
            grs.push(imMask);
            imMask = (Gray8Image) grs.getFront();
            // combine the image and mask to make a masked image
View Full Code Here

            }
        }
        // compute range of values in image and avoid division by 0 later
        int nDiff = Math.max(nMaxVal - nMinVal, 1);
        // this inverts the operation in Gray8Fft. The two must be kept in sync.
        Gray8Image imResult = new Gray8Image(nWidth, nHeight);
        byte bData[] = imResult.getData();
        if (bScale) {
            for (int i = 0; i < nWidth * nHeight; i++) {
                // magnitude is always guaranteed to be >= 0 so we only have to clamp
                // below Byte.MAX_VALUE
                bData[i] = (byte
View Full Code Here

                      ErrorCodes.IMAGE_NOT_GRAY8IMAGE,
                      image.toString(),
                      null,
                      null);
        }
        Gray8Image gray = (Gray8Image) image;
        int nSum = 0, nSumSq = 0;
        byte[] data = gray.getData();
        for (int i=0; i<gray.getHeight(); i++) {
            for (int j=0; j<gray.getWidth(); j++) {
                int pixel = (data[i*image.getWidth()+j]) - Byte.MIN_VALUE;
                nSum += pixel;
                nSumSq += pixel*pixel;
            }
        }
View Full Code Here

                    null);
        }
        if (this.imageOutput == null ||
          this.imageOutput.getWidth() != image.getWidth() ||
          this.imageOutput.getHeight() != image.getHeight()) {
          this.imageOutput = new Gray8Image(
              image.getWidth(),
              image.getHeight());
        }
        Gray16Image gray = (Gray16Image) image;
        short[] data = gray.getData();
View Full Code Here

                ErrorCodes.REDUCE_INPUT_IMAGE_NOT_MULTIPLE_OF_OUTPUT_SIZE,
                image.toString(),
                this.toString(),
                null);
        }
        Gray8Image gray = (Gray8Image) image;
        byte[] bIn = gray.getData();
        int cReducedHeight = image.getHeight() / this.cReduceHeight;
        int cReducedWidth = image.getWidth() / this.cReduceWidth;
        Gray8Image result = new Gray8Image(cReducedWidth, cReducedHeight);
        byte[] bOut = result.getData();
        for (int i=0; i<cReducedHeight; i++) {
            for (int j=0; j<cReducedWidth; j++) {
                int sum = 0;
                for (int k=0; k<this.cReduceHeight; k++) {
                    for (int l=0; l<this.cReduceWidth; l++) {
View Full Code Here

TOP

Related Classes of jjil.core.Gray8Image

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.