Examples of Gray8Image


Examples of jjil.core.Gray8Image

                    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

Examples of jjil.core.Gray8Image

        this.nMinY = (int) Math.min(p00.getY(), Math.min(p01.getY(), Math.min(p10.getY(), p11.getY())));
        this.nMaxY = (int) Math.max(p00.getY(), Math.max(p01.getY(), Math.max(p10.getY(), p11.getY())));
        this.nXOffset = -this.nMinX;
        this.nYOffset = -this.nMinY;
        if (this.eWarpOrder == WarpOrder.WARP_X_FIRST) {
            Gray8Image grayX = warpX((Gray8Image) image);
            //super.setOutput(new Gray8OffsetImage(grayX, this.nXOffset, this.nYOffset));
            Gray8Image grayY = warpY(grayX);
            super.setOutput(new Gray8OffsetImage(grayY, this.nXOffset, this.nYOffset));
        } else {
            Gray8Image grayY = warpY((Gray8Image) image);
            //super.setOutput(new Gray8OffsetImage(grayY, this.nXOffset, this.nYOffset));
            Gray8Image grayX = warpX(grayY);
            super.setOutput(new Gray8OffsetImage(grayX, this.nXOffset, this.nYOffset));
        }
    }
View Full Code Here

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
                // y does not change but is offset by nYOffset
                double fX = x * this.rdWarpX[0] +
                        this.rdWarpX[1] * (y + this.nYOffset) +
                        this.rdWarpX[2];
                double fXfloor = Math.floor(fX);
                double fXfrac = fX - fXfloor;
                int nX = (int) fXfloor;
                // interpolate to get point
                if (nX >= 0 && nX < grayIn.getWidth()-1) {
                    int bIn = bDataIn[y*grayIn.getWidth() + nX];
                    int bInP1 = bDataIn[y*grayIn.getWidth() + nX + 1];
                    int bOut = (int) ((bIn * (1.0d - fXfrac)) + (bInP1 * fXfrac));
                    bDataOut[grayOut.getWidth()*y + x-nMinX] = (byte) bOut;
                }
            }
        }
        this.nXOffset = nMinX;
        return grayOut;
View Full Code Here

Examples of jjil.core.Gray8Image

        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
                double fY = this.rdWarpY[0] * (x + this.nXOffset) +
                        this.rdWarpY[1] * y +
                        this.rdWarpY[2];
                double fYfloor = Math.floor(fY);
                double fYfrac = fY - fYfloor;
                int nY = (int) fYfloor;
                // interpolate to get point
                if (nY >= 0 && nY < grayIn.getHeight()-1) {
                    int bIn = bDataIn[nY*grayIn.getWidth() + x];
                    int bInP1 = bDataIn[(nY+1)*grayIn.getWidth() + x];
                    int bOut = (int) ((bIn * (1.0d - fYfrac)) + (bInP1 * fYfrac));
                    bDataOut[grayOut.getWidth()*(y-nMinY) + x] = (byte) bOut;
                }
            }
        }
        this.nYOffset = nMinY;
        return grayOut;
View Full Code Here

Examples of jjil.core.Gray8Image

            int nTargetHeight = (int) (imGray.getHeight() / fScale);
            int nStepHoriz = Math.max(1, nTargetWidth / this.nStep);
            int nStepVert = Math.max(1, nTargetHeight / this.nStep);
            Gray8Shrink gs = new Gray8Shrink(nTargetWidth, nTargetHeight);
            gs.push(imGray);
            Gray8Image imShrunk = (Gray8Image) gs.getFront();
            for (int i=0; i<imShrunk.getWidth()-this.hcc.getWidth(); i+=nStepHoriz) {
                // compute left coordinate in original image
                int nXPos = (i * imGray.getWidth()) / imShrunk.getWidth();
                for (int j=0; j<imShrunk.getHeight()-this.hcc.getHeight(); j+=nStepVert) {
                    // compute top coordinate of in original image
                    int nYPos = (j * imGray.getHeight()) / imShrunk.getHeight();
                    // compute rectangle center in original image
                    Point p = new Point(
                            nXPos + (this.hcc.getWidth() * imGray.getWidth()) /
                                        imShrunk.getWidth() / 2,
                            nYPos + (this.hcc.getHeight() * imGray.getHeight()) /
                                        imShrunk.getHeight() / 2);
                    // check if this point has already been tested
                    if (rc.contains(p) == null) {
                        // no, crop image to this rectangle
                        Gray8Crop gcc = new Gray8Crop(
                                i,
                                j,
                                this.hcc.getWidth(),
                                this.hcc.getHeight());
                        gcc.push(imShrunk);
                        // see if there's a face there
                        if (hcc.eval(gcc.getFront())) {
                            // there is, add scaled rectangle to rectangle list
                            Rectangle r = new Rectangle(
                                    nXPos,
                                    nYPos,
                                    (this.hcc.getWidth() * imGray.getWidth()) /
                                        imShrunk.getWidth(),
                                    (this.hcc.getHeight() * imGray.getHeight()) /
                                        imShrunk.getHeight());
                            System.out.println("Found something " + r.toString());
                            this.rc.add(r);
                        }
                    }
                }
View Full Code Here

Examples of jjil.core.Gray8Image

     */
        
    @Override
  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);
        }
       
        this.detect(imGray);

        // Zero the mask
        Gray8Image imMask = new Gray8Image(
                imGray.getWidth(),
                imGray.getHeight(),
                Byte.MIN_VALUE);
        for (Enumeration<Rectangle> e = rc.elements(); e.hasMoreElements();) {
            Rectangle r = e.nextElement();
View Full Code Here

Examples of jjil.core.Gray8Image

                      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

Examples of jjil.core.Gray8Image

        // note that we've not computed the final labels or
        // the sorted components yet
        this.bComponents = false;

        Gray8Image gray = (Gray8Image) image;
        byte[] bData = gray.getData();
        // for each pixel in the input image assign a label,
        // performing equivalence operations when two labels
        // are adjacent (8-connected)
        for (int i = 0; i < gray.getHeight(); i++) {
            int nRow = i * gray.getWidth();
            // we use sUpLeft to refer to the pixel up and to
            // the left of the current, etc.
            EquivalenceClass eUpLeft = null,eUp  = null,eUpRight  = null;
            // after first row, initialize pixels above and
            // to the right
            if (i > 0) {
                eUp = reClasses[nRow - gray.getWidth()];
                eUpRight = reClasses[nRow - gray.getWidth() + 1];
            }
            // starting a new row the pixel to the left is 0
            EquivalenceClass eLeft = null;
            // nBitPatt encodes the state of the pixels around the
            // current pixel. The pattern is
            // 8 4 2
            // 1 current
            int nBitPatt = ((eUp != null) ? 4 : 0) + ((eUpRight != null) ? 2 : 0);
            // (at left column eLeft and eUpLeft will always be 0)
            for (int j = 0; j < gray.getWidth(); j++) {
                if (bData[nRow + j] != Byte.MIN_VALUE) {
                    switch (nBitPatt) {
                        // the cases below are derived from the bit
                        // pattern illustrated above. The general
                        // rule is to choose the most recently-scanned
                        // label when copying a label. Of course, we
                        // also do unions only as necessary
                        case 0:
                            // 0 0 0
                            // 0 X
                            reClasses[nRow + j] =
                                    new EquivalenceClass();
                            this.sClasses++;
                            break;
                        case 1:
                            // 0 0 0
                            // X X
                            reClasses[nRow + j] = eLeft.find();
                            break;
                        case 2:
                            // 0 0 X
                            // 0 X
                            reClasses[nRow + j] = eUpRight.find();
                            break;
                        case 3:
                            // 0 0 X
                            // X X
                            eLeft.union(eUpRight);
                            reClasses[nRow + j] = eLeft.find();
                            break;
                        case 4:
                            // 0 X 0
                            // 0 X
                            reClasses[nRow + j] = eUp.find();
                            break;
                        case 5:
                            // 0 X 0
                            // X X
                            // we must already have union'ed
                            // eLeft and eUp
                            reClasses[nRow + j] = eLeft.find();
                            break;
                        case 6:
                            // 0 X X
                            // 0 X
                            // we must already have union'ed
                            // eUp and eUpRight
                            reClasses[nRow + j] = eUpRight.find();
                            break;
                        case 7:
                            // 0 X X
                            // X X
                            // we must already have union'ed
                            // eLeft and eUp, and eUp and eUpRight
                            reClasses[nRow + j] = eLeft.find();
                            break;
                        case 8:
                            // X 0 0
                            // 0 X
                            reClasses[nRow + j] = eUpLeft.find();
                            break;
                        case 9:
                            // X 0 0
                            // X X
                            // we must already have union'ed
                            // eLeft and eUpLeft
                            reClasses[nRow + j] = eLeft.find();
                            break;
                        case 10:
                            // X 0 X
                            // 0 X
                            eUpLeft.union(eUpRight);
                            reClasses[nRow + j] = eUpLeft.find();
                            break;
                        case 11:
                            // X 0 X
                            // X X
                            // we must already have union'ed
                            // eLeft and eUpLeft
                            eLeft.union(eUpRight);
                            reClasses[nRow + j] = eLeft.find();
                            break;
                        case 12:
                            // X X 0
                            // 0 X
                            // we must already have union'ed
                            // eUpLeft and eUp
                            reClasses[nRow + j] = eUp.find();
                            break;
                        case 13:
                            // X X 0
                            // X X
                            // we must already have union'ed
                            // eLeft and eUpLeft, and eUpLeft and eUp
                            reClasses[nRow + j] = eLeft.find();
                            break;
                        case 14:
                            // X X X
                            // 0 X
                            // we must already have union'ed
                            // eUpLeft, eUp, and eUpRight
                            reClasses[nRow + j] = eUpRight.find();
                            break;
                        case 15:
                            // X X X
                            // X X
                            // we must already have union'ed
                            // eLeft, eUpLeft, eUp, and eUpRight
                            reClasses[nRow + j] = eLeft.find();
                            break;
                    }
                }
                // shift right to next pixel
                eUpLeft = eUp;
                eUp = eUpRight;
                eLeft = reClasses[nRow + j];
                // if we're not at the right column and after the first
                // row read a new right pixel
                if (i > 0 && j < gray.getWidth() - 1) {
                    eUpRight = reClasses[nRow - gray.getWidth() + j + 2];
                } else {
                    eUpRight = null;
                }

                // compute the new bit pattern. This is the old pattern
                // with eUpLeft and eLeft and'ed off (& 6), shifted left,
                // with the new eLeft and eUpRight or'ed in
                nBitPatt = ((nBitPatt & 6) << 1) + ((eLeft != null) ? 1 : 0) +
                        ((eUpRight != null) ? 2 : 0);
            }
        }
        // initialize the labeled image
        this.imLabeled = new Gray16Image(gray.getWidth(), gray.getHeight(),
                (short) 0);
        short[] sLabels = this.imLabeled.getData();
        // assign label pixels their final values
        for (int i = 0; i < sLabels.length; i++) {
            if (reClasses[i] != null) {
View Full Code Here

Examples of jjil.core.Gray8Image

        int nMaxY = (int) Math.max(p00.getY(), Math.max(p01.getY(), Math.max(p10.getY(), p11.getY())));
        this.nXOffset = -nMinX;
        this.nYOffset = -nMinY;
        int nWidth = nMaxX - nMinX;
        int nHeight = nMaxY - nMinY;
        Gray8Image grayOut = new Gray8Image(nWidth, nHeight, Byte.MIN_VALUE);
        byte[] dataIn = grayIn.getData();
        byte[] dataOut = grayOut.getData();
        for (int x = nMinX; x<nMaxX; x++) {
            for (int y=nMinY; y<nMaxY; y++) {
                Vec2 p = new Vec2((double) x, (double) y);
                Vec2 pMap = affineTrans(this.rdInvWarp, p);
                double xFloor = Math.floor(pMap.getX());
                double yFloor = Math.floor(pMap.getY());
                int nX = (int) xFloor;
                int nY = (int) yFloor;
                if (nX >= 0 && nX < grayIn.getWidth()-1 &&
                        nY >= 0 && nY < grayIn.getHeight()-1) {
                    double xFrac = pMap.getX() - xFloor;
                    double yFrac = pMap.getY() - yFloor;
                    // interpolate x value
                    int x1 = (int) (
                            (1.0d-xFrac) * dataIn[nY*grayIn.getWidth() + nX] +
                            xFrac * dataIn[nY*grayIn.getWidth() + nX + 1]);
                    int x2 = (int) (
                            (1.0d-xFrac) * dataIn[(nY+1)*grayIn.getWidth() + nX] +
                            xFrac * dataIn[(nY+1)*grayIn.getWidth() + nX + 1]);
                    // interpolate y
                    dataOut[(y-nMinY)*grayOut.getWidth()+(x-nMinX)] = (byte) (
                            (1.0d-yFrac) * x1 + yFrac * x2);
                }
            }
        }
        return new Gray8OffsetImage(grayOut, this.nXOffset, this.nYOffset);
View Full Code Here

Examples of jjil.core.Gray8Image

      if (mHcc != null) {
        mVecRects.clear();
          RgbAvgGray rg = new RgbAvgGray();
          try {
            rg.push(rgb);
            Gray8Image gray = (Gray8Image) rg.getFront();
            Gray8Crop crop = new Gray8Crop(0, 0, mHcc.getWidth(), mHcc.getHeight());
            int nHorizSkip = Math.max(rgb.getWidth()/16, mHcc.getWidth() / 10);
            int nVertSkip = Math.max(rgb.getHeight()/16, mHcc.getHeight() / 10);
            for (int i=0;
              i<=gray.getHeight()-mHcc.getHeight() && mVecRects.size() == 0;
              i+=nVertSkip) {
              for (int j=0;
                j<=gray.getWidth()-mHcc.getWidth() && mVecRects.size() == 0;
                j+=nHorizSkip) {
                mRectCurrent = new Rect(j, i, mHcc.getWidth(), mHcc.getHeight());
                crop.setWindow(mRectCurrent);
                crop.push(gray);
                Gray8Image cropped = (Gray8Image) crop.getFront();
                boolean bRect = false;
                if (mHcc.eval(cropped) || bRect) {
                  Rect r = new Rect(j, i, mHcc.getWidth(), mHcc.getHeight());
                  mVecRects.add(r);
                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.