Package jjil.core

Examples of jjil.core.Gray8Image


        return new Vec2(x,y);
    }

    private Gray8Image warpX(Gray8Image grayIn) {
        // allocate image. it is implicitly offset by nMinX
        Gray8Image grayOut = new Gray8Image(
                nMaxX - nMinX,
                grayIn.getHeight(),
                Byte.MIN_VALUE);
        // pointer to input
        byte[] bDataIn = grayIn.getData();
        byte[] bDataOut = grayOut.getData();
        for (int x = nMinX; x<nMaxX; x++) {
            for (int y = 0; y<grayIn.getHeight(); y++) {
                // calculate x in original image.
                // nX is scaled by 2**16.
                // y does not change but is offset by nYOffset
                int nX = x * this.rnWarpX[0] +
                        this.rnWarpX[1] * (y + this.nYOffset) +
                        this.rnWarpX[2];
                // nXfloor is the integer value of nX, unscaled
                int nXfloor = nX >> 16;
                // nXfrace is the fractional component of nX, scaled by 2**16
                int nXfrac = nX - (nXfloor<<16);
                // interpolate to get point
                if (nXfloor >= 0 && nXfloor < grayIn.getWidth()-1) {
                    int bIn = bDataIn[y*grayIn.getWidth() + nXfloor];
                    int bInP1 = bDataIn[y*grayIn.getWidth() + nXfloor + 1];
                    int bOut = (bIn * ((1<<16)- nXfrac) +
                                bInP1 * nXfrac)>>16;
                    bDataOut[grayOut.getWidth()*y + x-nMinX] = (byte) bOut;
                }
            }
        }
        this.nXOffset = nMinX;
        return grayOut;
View Full Code Here


        return grayOut;
    }

    private Gray8Image warpY(Gray8Image grayIn) {
        // allocate image. it is implicitly offset by nMinY
        Gray8Image grayOut = new Gray8Image(
                grayIn.getWidth(),
                nMaxY - nMinY,
                Byte.MIN_VALUE);
        // pointer to input
        byte[] bDataIn = grayIn.getData();
        byte[] bDataOut = grayOut.getData();
        for (int y = nMinY; y<nMaxY; y++) {
            for (int x = 0; x<grayIn.getWidth(); x++) {
                // calculate y in original image
                // x does not change
                // nY is scaled by 2**16
                int nY = this.rnWarpY[0] * (x + this.nXOffset) +
                        this.rnWarpY[1] * y +
                        this.rnWarpY[2];
                // nYfloor is the integer portion of nY, unscaled
                int nYfloor = nY >> 16;
                // nYfrac is the fractional portion of nY, scaled by 2**16
                int nYfrac = nY - (nYfloor<<16);
                // interpolate to get point
                if (nYfloor >= 0 && nYfloor < grayIn.getHeight()-1) {
                    int bIn = bDataIn[nYfloor*grayIn.getWidth() + x];
                    int bInP1 = bDataIn[(nYfloor+1)*grayIn.getWidth() + x];
                    int bOut =  (bIn * ((1<<16) - nYfrac) +
                                 bInP1 * nYfrac)>>16;
                    bDataOut[grayOut.getWidth()*(y-nMinY) + x] = (byte) bOut;
                }
            }
        }
        this.nYOffset = nMinY;
        return grayOut;
View Full Code Here

                            ErrorCodes.IMAGE_NOT_GRAY8IMAGE,
                            imageInput.toString(),
                            null,
                            null);
        }
        Gray8Image grayInput = (Gray8Image) imageInput;
        byte[] bData = grayInput.getData();
        Gray8Image grayOutput = new Gray8Image(imageInput.getWidth(),imageInput.getHeight());
        byte[] bDataOut = grayOutput.getData();
        for (int i=1; i<grayInput.getHeight()-1; i++) {
            for (int j=1; j<grayInput.getWidth()-1; j++) {
                if (bData[i*grayInput.getWidth()+j] !=
                        Math.max(bData[(i-1)*grayInput.getWidth()+j-1],
                        Math.max(bData[(i-1)*grayInput.getWidth()+j],
View Full Code Here

       
        }
        RgbImage rgbInput = (RgbImage)imInput;
        int wInput[] = rgbInput.getData();
        int wBack[] = this.rgbBack.getData();
        Gray8Image grayOut = new Gray8Image(
                this.rgbBack.getWidth(),
                this.rgbBack.getHeight());       
        byte bGray[] = grayOut.getData();
        for (int i=0; i<imInput.getHeight(); i++) {
            for (int j=0; j<imInput.getWidth(); j++) {
                if (!this.rgbBack.isMasked(i,j)) {
                    int rIn = RgbVal.getR(wInput[i*grayOut.getWidth()+j]);
                    int gIn = RgbVal.getG(wInput[i*grayOut.getWidth()+j]);
                    int bIn = RgbVal.getB(wInput[i*grayOut.getWidth()+j]);
                    int rBack = RgbVal.getR(wBack[i*grayOut.getWidth()+j]);
                    int gBack = RgbVal.getG(wBack[i*grayOut.getWidth()+j]);
                    int bBack = RgbVal.getB(wBack[i*grayOut.getWidth()+j]);
                    int gRes = Math.max(Math.abs(rIn-rBack),
                            Math.max(Math.abs(gIn-gBack),
                            Math.abs(bIn-bBack)));
                    bGray[i*grayOut.getWidth()+j] =
                            (byte) Math.min(gRes, Byte.MAX_VALUE);
                } else {
                    bGray[i] = Byte.MIN_VALUE;
                }
            }
View Full Code Here

                            null,
                            null);
        }
        RgbImage rgb = (RgbImage) imageInput;
        int[] nData = rgb.getData();
        Gray8Image imageResult = new Gray8Image(rgb.getWidth(), rgb.getHeight());
        byte[] bData = imageResult.getData();
        for (int i=0; i<rgb.getWidth()*rgb.getHeight(); i++) {
            int nRCurr = RgbVal.getR(nData[i]) - Byte.MIN_VALUE;
            int nGCurr = RgbVal.getG(nData[i]) - Byte.MIN_VALUE;
            int nBCurr = RgbVal.getB(nData[i]) - Byte.MIN_VALUE;
            int nRDiff = nRCurr - this.nR;
View Full Code Here

                            ErrorCodes.IMAGE_NOT_RGBIMAGE,
                            imageInput.toString(),
                            null,
                            null);
        }
        Gray8Image grayInput = (Gray8Image) imageInput;
        Gray8MaskedImage grayOutput = new Gray8MaskedImage(grayInput);
        buildVector(grayInput.getWidth(), grayInput.getHeight());
        for (int i=0; i<grayInput.getHeight(); i++) {
            if (this.rnX[i] != null) {
                for (int j=0; j<this.rnX[i].length; j+= 2) {
                    for (int k = this.rnX[i][j]; k<this.rnX[i][j+1]; k++) {
                        grayOutput.setMask(i, k);
                    }
View Full Code Here

                    ErrorCodes.IMAGE_SIZES_DIFFER,
                    imageFirst.toString(),
                    imageSecond.toString(),
                    null);
       }
        Gray8Image gray1 = (Gray8Image) imageFirst;
        Gray8Image gray2 = (Gray8Image) imageSecond;
        byte[] data1 = gray1.getData();
        byte[] data2 = gray2.getData();
        for (int i=0; i<data1.length; i++) {
            int nD1 = data1[i] - Byte.MIN_VALUE;
            int nD2 = data2[i] - Byte.MIN_VALUE;
            data1[i] = (byte) Math.min(
                    Byte.MAX_VALUE,
View Full Code Here

                    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;
            }
View Full Code Here

                  ErrorCodes.IMAGE_NOT_GRAY8IMAGE,
                  image.toString(),
                  null,
                  null);
        }
        Gray8Image gray = (Gray8Image) image;
        RgbImage rgb = new RgbImage(image.getWidth(), image.getHeight());
        byte[] grayData = gray.getData();
        int[] rgbData = rgb.getData();
        for (int i=0; i<gray.getWidth() * gray.getHeight(); i++) {
            /* Convert from signed byte value to unsigned byte for storage
             * in the RGB image.
             */
            int grayUnsigned = (grayData[i]) - Byte.MIN_VALUE;
            /* Create ARGB word */
 
View Full Code Here

                    ErrorCodes.IMAGE_NOT_GRAY8IMAGE,
                    image.toString(),
                    null,
                    null);
        }
        Gray8Image input = (Gray8Image) image;
        byte[] bIn = input.getData();
        for (int i=0; i<bIn.length; i++) {
           bIn[i] = (byte) Math.min(Byte.MAX_VALUE, Math.abs(bIn[i]));
        }
        super.setOutput(input);
    }
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.