Package jjil.core

Examples of jjil.core.Rect


                   imMask = (Gray8Image) image;
                   GrayConnComp gcc = new GrayConnComp();
                   gcc.push(imMask);
                   if (gcc.getComponents()> 0) {
                       // found a face
                       Rect r = gcc.getComponent(0);
                       // calculate center of face in mask coordinates
                       int x = r.getLeft() + r.getWidth() / 2;
                       int y = r.getTop() + r.getHeight() / 2;
                       // convert from mask to original image
                       x = (x * this.imInput.getWidth()) / imMask.getWidth();
                       y = (y * this.imInput.getHeight()) / imMask.getHeight();
                       // (x,y) is the center of the detected face
                   }
View Full Code Here


            nRight ++;
        }
        if (nLeft > nRight) {
          return null;
        }
        return new Rect(nLeft+r.getLeft(), r.getTop(), nRight-nLeft, r.getHeight());
    }
View Full Code Here

            nBestStart = nStart;
        }     
        if (nBestLength <= 0) {
          return null;
        }
        return new Rect(r.getLeft(), nBestStart+r.getTop(), r.getWidth(), nBestLength);
    }
View Full Code Here

     * @param gray the gray
     *
     * @return the rect
     */
    public Rect push(Gray8Image gray) {
      Rect rAll = new Rect(0, 0, gray.getWidth(), gray.getHeight());
        Rect rVert = determineVerticalExtent(rAll, gray.getWidth(), gray.getData());
        if (rVert == null) {
          return null;
        }
        Rect rHoriz = determineHorizontalExtent(rVert, gray.getWidth(), gray.getData());
        // do it again to eliminate edge effects
        if (rHoriz == null) {
          return null;
        }
        rVert = determineVerticalExtent(rHoriz, gray.getWidth(), gray.getData());
View Full Code Here

    if (gcc.getComponentCount() == 0) {
      return false;
    }
    // get component which is largest than the minimum size and
    // closest to a 4/3 ratio of width to height
    Rect rReduced;
    int nBestDiff = Integer.MAX_VALUE;
    this.rDetected = null;
    for (int i=0; i<gcc.getComponentCount(); i++) {
      rReduced = gcc.getComponent(0);
      // we detected the barcode at reduced resolution
      // for speed. Stretch the rectangle back to its
      // original size
      Rect rThisDetected = new Rect(
          (rReduced.getLeft() * rgb.getWidth()) / nReducedWidth,
          (rReduced.getTop() * rgb.getHeight()) / nReducedHeight,
          (rReduced.getWidth() * rgb.getWidth()) / nReducedWidth,
          (rReduced.getHeight() * rgb.getHeight()) / nReducedHeight
          );
      if (rThisDetected.getArea() >= this.nMinArea) {
        int nRatio = 3 * rThisDetected.getWidth() / rThisDetected.getHeight();
        // the ratio should be close to 4 since in the ideal case
        // width = 4x and height = 3x so 3 * width / height = 4
        int nDiff = Math.abs(nRatio-4);
        if (nDiff < nBestDiff) {
          this.rDetected = rThisDetected;
View Full Code Here

    public int getComponentLabel(int n) {
        return this.rSortedLabels[n].getLabel();
    }

    public Enumeration getComponentPixels(int n) throws Error {
        Rect r = getComponent(n);
        // build a Vector of all points in the component
        Vector vPoints = new Vector();
        short[] sData = this.imLabeled.getData();
        int nLabel = this.rSortedLabels[n].nLabel;
        for (int i=r.getTop(); i<=r.getBottom(); i++) {
            for (int j=r.getLeft(); j<=r.getRight(); j++) {
                if (sData[i*this.imLabeled.getWidth()+j] == nLabel) {
                    vPoints.addElement(new Point(j, i));
                }
            }
        }
View Full Code Here

        private int nLabel = 0;
        private int nPixelCount = 0;
        private Rect rectBounding;

        public Label(Point p, int nLabel) {
            this.rectBounding = new Rect(p);
            this.nLabel = nLabel;
            this.nPixelCount = 1;
        }
View Full Code Here

              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);
                }
              }
            }
          } catch (jjil.core.Error er) {
View Full Code Here

        // check for intersection between two lists; if non-empty check
        // for contains
        Vector vHoriz = (Vector) tbtHorizProj.getValue();
        Vector vVert = (Vector) tbtVertProj.getValue();
        for (Enumeration e = vHoriz.elements(); e.hasMoreElements();) {
            Rect r = (Rect) e.nextElement();
            for (Enumeration f = vVert.elements(); f.hasMoreElements();) {
                Rect s = (Rect) f.nextElement();
                if (r == s) {
                    if (s.contains(p)) {
                        return s;
                    }
                }
            }
        }
View Full Code Here

     */
    public void split(RgbImage rgbImage) {
        this.rgbInput = rgbImage;
        Vector vecRNotOk = new Vector();
        this.vecROk = new Vector();
        vecRNotOk.addElement(new Rect(
                0,
                0,
                this.rgbInput.getWidth(),
                this.rgbInput.getHeight()));
        while (!vecRNotOk.isEmpty()) {
            Rect r = (Rect) vecRNotOk.elementAt(0);
            vecRNotOk.removeElementAt(0);
            if (r.getHeight() >= 2 && r.getWidth() >= 2) {
                MeanVar nVar = computeVariance(r);
                if (nVar.getRVar()>this.nRVar ||
                        nVar.getGVar()>this.nGVar ||
                        nVar.getB()>this.nBVar) {
                    // split horizontally or vertically, whichever
                    // is longer
                    if (r.getWidth() >= r.getHeight()) {
                        // split horizontally
                        int nHalfWidth = r.getWidth()/2;
                        Rect rNew =
                                new Rect(r.getLeft(),
                                r.getTop(),
                                nHalfWidth,
                                r.getHeight());
                        vecRNotOk.addElement(rNew);
                        rNew = new Rect(r.getLeft()+nHalfWidth,
                                r.getTop(),
                                r.getWidth() - nHalfWidth,
                                r.getHeight());
                        vecRNotOk.addElement(rNew);
                    } else {
                        // split vertically
                        int nHalfHeight = r.getHeight()/2;
                        Rect rNew = new Rect(r.getLeft(),
                                r.getTop(),
                                r.getWidth(),
                                nHalfHeight);
                        vecRNotOk.addElement(rNew);
                        rNew = new Rect(r.getLeft(),
                                r.getTop()+nHalfHeight,
                                r.getWidth(),
                                r.getHeight() - nHalfHeight);
                        vecRNotOk.addElement(rNew);
                    }
View Full Code Here

TOP

Related Classes of jjil.core.Rect

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.