/** Returns, as a FloatPolygon, an interpolated version * of this selection that has points spaced 1.0 pixel apart. */ public FloatPolygon getInterpolatedPolygon() { return getInterpolatedPolygon(1.0, false); }
/** Returns, as a FloatPolygon, an interpolated version * of this selection that has points spaced 1.0 pixel apart. */ public FloatPolygon getInterpolatedPolygon() { return getInterpolatedPolygon(1.0, false); }
public FloatPolygon getInterpolatedPolygon(double interval, boolean smooth) { FloatPolygon p = getFloatPolygon(); if (smooth && (type==TRACED_ROI || type==FREEROI || type==FREELINE)) { for (int i=1; i<p.npoints-2; i++) { p.xpoints[i] = (p.xpoints[i-1]+p.xpoints[i]+p.xpoints[i+1])/3f; p.ypoints[i] = (p.ypoints[i-1]+p.ypoints[i]+p.ypoints[i+1])/3f; } if (type!=FREELINE) { p.xpoints[0] = (p.xpoints[p.npoints-1]+p.xpoints[0]+p.xpoints[1])/3f; p.ypoints[0] = (p.ypoints[p.npoints-1]+p.ypoints[0]+p.ypoints[1])/3f; p.xpoints[p.npoints-1] = (p.xpoints[p.npoints-2]+p.xpoints[p.npoints-1]+p.xpoints[0])/3f; p.ypoints[p.npoints-1] = (p.ypoints[p.npoints-2]+p.ypoints[p.npoints-1]+p.ypoints[0])/3f; } } return super.getInterpolatedPolygon(p, interval, smooth); }
public FloatPolygon getInterpolatedPolygon(double interval, boolean smooth) { FloatPolygon p = getFloatPolygon(); if (smooth && (type==TRACED_ROI || type==FREEROI || type==FREELINE)) { for (int i=1; i<p.npoints-2; i++) { p.xpoints[i] = (p.xpoints[i-1]+p.xpoints[i]+p.xpoints[i+1])/3f; p.ypoints[i] = (p.ypoints[i-1]+p.ypoints[i]+p.ypoints[i+1])/3f; } if (type!=FREELINE) { p.xpoints[0] = (p.xpoints[p.npoints-1]+p.xpoints[0]+p.xpoints[1])/3f; p.ypoints[0] = (p.ypoints[p.npoints-1]+p.ypoints[0]+p.ypoints[1])/3f; p.xpoints[p.npoints-1] = (p.xpoints[p.npoints-2]+p.xpoints[p.npoints-1]+p.xpoints[0])/3f; p.ypoints[p.npoints-1] = (p.ypoints[p.npoints-2]+p.ypoints[p.npoints-1]+p.ypoints[0])/3f; } } return super.getInterpolatedPolygon(p, interval, smooth); }
/** Returns, as a FloatPolygon, an interpolated version of * this selection with points spaced 'interval' pixels apart. * If 'smooth' is true, traced and freehand selections are * first smoothed using a 3 point running average. */ public FloatPolygon getInterpolatedPolygon(double interval, boolean smooth) { FloatPolygon p = (this instanceof Line)?((Line)this).getFloatPoints():getFloatPolygon(); return getInterpolatedPolygon(p, interval, smooth); }
/** Returns, as a FloatPolygon, an interpolated version of * this selection with points spaced 'interval' pixels apart. * If 'smooth' is true, traced and freehand selections are * first smoothed using a 3 point running average. */ public FloatPolygon getInterpolatedPolygon(double interval, boolean smooth) { FloatPolygon p = (this instanceof Line)?((Line)this).getFloatPoints():getFloatPolygon(); return getInterpolatedPolygon(p, interval, smooth); }
/** Returns the coordinates of the pixels inside this ROI as an array of Points. * @see #getContainedFloatPoints() * @see #iterator() */ public Point[] getContainedPoints() { if (isLine()) { FloatPolygon p = getInterpolatedPolygon(); Point[] points = new Point[p.npoints]; for (int i=0; i<p.npoints; i++) points[i] = new Point((int)Math.round(p.xpoints[i]),(int)Math.round(p.ypoints[i])); return points; } ImageProcessor mask = getMask(); Rectangle bounds = getBounds(); ArrayList points = new ArrayList(); for (int y=0; y<bounds.height; y++) { for (int x=0; x<bounds.width; x++) { if (mask==null || mask.getPixel(x,y)!=0) points.add(new Point(this.x+x,this.y+y)); } } return (Point[])points.toArray(new Point[points.size()]); }
/** Returns the coordinates of the pixels inside this ROI as an array of Points. * @see #getContainedFloatPoints() * @see #iterator() */ public Point[] getContainedPoints() { if (isLine()) { FloatPolygon p = getInterpolatedPolygon(); Point[] points = new Point[p.npoints]; for (int i=0; i<p.npoints; i++) points[i] = new Point((int)Math.round(p.xpoints[i]),(int)Math.round(p.ypoints[i])); return points; } ImageProcessor mask = getMask(); Rectangle bounds = getBounds(); ArrayList points = new ArrayList(); for (int y=0; y<bounds.height; y++) { for (int x=0; x<bounds.width; x++) { if (mask==null || mask.getPixel(x,y)!=0) points.add(new Point(this.x+x,this.y+y)); } } return (Point[])points.toArray(new Point[points.size()]); }
/** Returns the coordinates of the pixels inside this ROI as a FloatPolygon. * @see #getContainedPoints() * @see #iterator() */ public FloatPolygon getContainedFloatPoints() { Roi roi2 = this; if (isLine()) { if (getStrokeWidth()<=1) return roi2.getInterpolatedPolygon(); else roi2 = Selection.lineToArea(this); } ImageProcessor mask = roi2.getMask(); Rectangle bounds = roi2.getBounds(); FloatPolygon points = new FloatPolygon(); for (int y=0; y<bounds.height; y++) { for (int x=0; x<bounds.width; x++) { if (mask==null || mask.getPixel(x,y)!=0) points.addPoint((float)(bounds.x+x),(float)(bounds.y+y)); } } return points; }
/** Returns the coordinates of the pixels inside this ROI as a FloatPolygon. * @see #getContainedPoints() * @see #iterator() */ public FloatPolygon getContainedFloatPoints() { Roi roi2 = this; if (isLine()) { if (getStrokeWidth()<=1) return roi2.getInterpolatedPolygon(); else roi2 = Selection.lineToArea(this); } ImageProcessor mask = roi2.getMask(); Rectangle bounds = roi2.getBounds(); FloatPolygon points = new FloatPolygon(); for (int y=0; y<bounds.height; y++) { for (int x=0; x<bounds.width; x++) { if (mask==null || mask.getPixel(x,y)!=0) points.addPoint((float)(bounds.x+x),(float)(bounds.y+y)); } } return points; }
adjust = gd.getNextBoolean(); int sign = adjust ? -1 : 1; FloatPolygon poly = roi.getInterpolatedPolygon(sign*interval, smooth); int t = roi.getType(); int type = roi.isLine()?Roi.FREELINE:Roi.FREEROI;
adjust = gd.getNextBoolean(); int sign = adjust ? -1 : 1; FloatPolygon poly = roi.getInterpolatedPolygon(sign*interval, smooth); int t = roi.getType(); int type = roi.isLine()?Roi.FREELINE:Roi.FREEROI;