java.lang.Object
ij.gui.Roi
ij.gui.PolygonRoi
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<Point>
- Direct Known Subclasses:
EllipseRoi,FreehandRoi,PointRoi,RotatedRectRoi
This class represents a polygon region of interest or polyline of interest.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected intprotected intprotected int[]protected int[]protected float[]protected float[]protected int[]protected int[]protected float[]protected float[]Fields inherited from class ij.gui.Roi
ANGLE, asp_bk, aspect, cachedMask, center, clipboard, clipHeight, clipWidth, clipX, clipY, COMPOSITE, constrain, CONSTRUCTING, defaultColor, defaultFillColor, FERET_ARRAY_POINTOFFSET, FERET_ARRAYSIZE, fillColor, flattenScale, FREELINE, FREEROI, HANDLE_SIZE, handleColor, ic, ignoreClipRect, imp, instanceColor, LINE, lineWidth, mag, MOVING, MOVING_HANDLE, nonScalable, NORMAL, NOT_PASTING, oldHeight, oldWidth, oldX, oldY, onePixelWide, OVAL, overlay, pasteMode, POINT, POLYGON, POLYLINE, previousRoi, RECTANGLE, RESIZING, ROIColor, stroke, strokeColor, TRACED_ROI, type, updateFullWindow, wideLine, xMax, yMax -
Constructor Summary
ConstructorsConstructorDescriptionPolygonRoi(float[] xPoints, float[] yPoints, int type) Creates a new polygon or polyline ROI from float x and y arrays.PolygonRoi(float[] xPoints, float[] yPoints, int nPoints, int type) Creates a new polygon or polyline ROI from float x and y arrays.PolygonRoi(int[] xPoints, int[] yPoints, int nPoints, int type) Creates a new polygon or polyline ROI from x and y coordinate arrays.PolygonRoi(int[] xPoints, int[] yPoints, int nPoints, ImagePlus imp, int type) Deprecated.PolygonRoi(int sx, int sy, ImagePlus imp) Starts the process of creating a new user-generated polygon or polyline ROI.PolygonRoi(FloatPolygon p, int type) Creates a new polygon or polyline ROI from a FloatPolygon.PolygonRoi(Polygon p, int type) Creates a new polygon or polyline ROI from a Polygon. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected intclone()Returns a copy of this PolygonRoi.booleancontains(int x, int y) Returns whether the center of pixel (x,y) is contained in the Roi.booleancontainsPoint(double x, double y) Returns whether coordinate (x,y) is contained in the Roi.voiddeleteHandle(double ox, double oy) protected voiddeletePoint(int index) voidvoidDraws the selection outline on the specified ImageProcessor.voidvoidvoidFits a spline, which becomes the new shape of this RoivoidfitSpline(int evaluationPoints) Fits a spline, which becomes the new shape of this RoivoidCreates a spline fitted polygon with (roughly) one pixel segment lengths and sets it as the Roi shape.doublegetAngle()Returns the angle in degrees between the first two segments of this polyline.protected intgetClosestPoint(double x, double y, FloatPolygon points) Returns this polygon or polyline as float arrays in image pixel coordinates.getInterpolatedPolygon(double interval, boolean smooth) Returns, as a FloatPolygon, an interpolated version of this selection with points spaced 'interval' pixels apart.doubleReturns the perimeter (for ROIs) or length (for lines).getMask()Always returns null for rectangular Roi'sintReturns the number of points that define this PolygonRoi.Returns this PolygonRoi as a Polygon.doubleint[]Obsolete; replaced by either getPolygon() or getFloatPolygon().int[]Obsolete; replaced by either getPolygon() or getFloatPolygon().protected voidgrow(int sx, int sy) protected voidhandleMouseUp(int sx, int sy) With segmented selections, ignore first mouse up and finalize when user double-clicks, control-clicks or clicks in start box.intisHandle(int sx, int sy) Returns a handle number if the specified screen coordinates are inside or near a handle, otherwise returns -1.booleanReturns 'true' if this selection has been fitted with a spline.protected voidmouseDownInHandle(int handle, int sx, int sy) voidprotected voidmoveHandle(int sx, int sy) voidprotected voidvoidsetLocation(double x, double y) Set the location of the ROI in image coordinates.intsize()Returns the number of points in this selection; equivalent to getPolygon().npoints.protected voidprotected voidwipeBack()Methods inherited from class ij.gui.Roi
abortModification, abortPaste, addRoiListener, convertLineToArea, convertToPolygon, copyAttributes, create, create, drawOverlay, drawPixels, endPaste, equals, getAngle, getAntiAlias, getBoundingRect, getBounds, getColor, getContainedFloatPoints, getContainedPoints, getContourCentroid, getConvexHull, getCornerDiameter, getCPosition, getCurrentPasteMode, getDefaultFillColor, getDefaultGroup, getDefaultHandleSize, getDefaultStrokeWidth, getDrawOffset, getFeretsDiameter, getFeretValues, getFillColor, getFloatAngle, getFloatBounds, getFloatConvexHull, getFloatHeight, getFloatPolygon, getFloatWidth, getGroup, getGroupName, getGroupNames, getHandleSize, getHashCode, getImage, getImageID, getInterpolatedPolygon, getInterpolatedPolygon, getInverse, getListeners, getMagnification, getName, getPasteMode, getPosition, getPreviousRoi, getProperties, getProperty, getPropertyCount, getPrototypeOverlay, getRotationCenter, getRoundRectArcSize, getScaledStroke, getScaleStrokeWidth, getState, getStatistics, getStroke, getStrokeColor, getStrokeWidth, getTPosition, getType, getTypeAsString, getXBase, getYBase, getZPosition, handleMouseDown, handleMouseDrag, hasHyperStackPosition, isActiveOverlayRoi, isArea, isCursor, isDrawingTool, isInteger, isLine, isLineOrPoint, isVisible, iterator, lineCircleIntersection, magnificationForSubPixel, magnificationForSubPixel, mouseDragged, mouseReleased, notifyListeners, nudge, nudgeCorner, offScreenX, offScreenXD, offScreenY, offScreenYD, removeRoiListener, resetDefaultHandleSize, saveGroupNames, screenX, screenXD, screenY, screenYD, setAntiAlias, setBounds, setColor, setCornerDiameter, setDefaultColor, setDefaultFillColor, setDefaultGroup, setDefaultStrokeWidth, setDrawOffset, setFillColor, setFlattenScale, setGroup, setGroupName, setGroupNames, setHandleSize, setIgnoreClipRect, setImage, setInstanceColor, setIsCursor, setLineWidth, setLocation, setName, setNonScalable, setPasteMode, setPosition, setPosition, setPosition, setPreviousRoi, setProperties, setProperty, setPrototypeOverlay, setRenderingHint, setRotationCenter, setRoundRectArcSize, setStroke, setStrokeColor, setStrokeWidth, setStrokeWidth, setUnscalableStrokeWidth, showStatus, startPaste, subPixelResolution, temporarilyHide, toFloat, toInt, toInt, toIntR, toString, translate, update, updateClipRect, updateWideLine, useLineSubpixelConvention, xorMethods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
maxPoints
protected int maxPoints -
xp
protected int[] xp -
yp
protected int[] yp -
xpf
protected float[] xpf -
ypf
protected float[] ypf -
xp2
protected int[] xp2 -
yp2
protected int[] yp2 -
nPoints
protected int nPoints -
xSpline
protected float[] xSpline -
ySpline
protected float[] ySpline -
splinePoints
protected int splinePoints
-
-
Constructor Details
-
PolygonRoi
public PolygonRoi(int[] xPoints, int[] yPoints, int nPoints, int type) Creates a new polygon or polyline ROI from x and y coordinate arrays. Type must be Roi.POLYGON, Roi.FREEROI, Roi.TRACED_ROI, Roi.POLYLINE, Roi.FREELINE or Roi.ANGLE. -
PolygonRoi
public PolygonRoi(float[] xPoints, float[] yPoints, int nPoints, int type) Creates a new polygon or polyline ROI from float x and y arrays. Type must be Roi.POLYGON, Roi.FREEROI, Roi.POLYLINE, Roi.FREELINE or Roi.ANGLE. -
PolygonRoi
public PolygonRoi(float[] xPoints, float[] yPoints, int type) Creates a new polygon or polyline ROI from float x and y arrays. Type must be Roi.POLYGON, Roi.FREEROI, Roi.POLYLINE, Roi.FREELINE or Roi.ANGLE. -
PolygonRoi
Creates a new polygon or polyline ROI from a Polygon. Type must be Roi.POLYGON, Roi.FREEROI, Roi.TRACED_ROI, Roi.POLYLINE, Roi.FREELINE or Roi.ANGLE. -
PolygonRoi
Creates a new polygon or polyline ROI from a FloatPolygon. Type must be Roi.POLYGON, Roi.FREEROI, Roi.TRACED_ROI, Roi.POLYLINE, Roi.FREELINE or Roi.ANGLE. -
PolygonRoi
Deprecated. -
PolygonRoi
Starts the process of creating a new user-generated polygon or polyline ROI.
-
-
Method Details
-
draw
-
drawPixels
Description copied from class:RoiDraws the selection outline on the specified ImageProcessor.- Overrides:
drawPixelsin classRoi- See Also:
-
grow
protected void grow(int sx, int sy) -
updatePolygon
protected void updatePolygon() -
mouseMoved
- Overrides:
mouseMovedin classRoi
-
wipeBack
protected void wipeBack() -
exitConstructingMode
public void exitConstructingMode() -
moveHandle
protected void moveHandle(int sx, int sy) - Overrides:
moveHandlein classRoi
-
resetBoundingRect
protected void resetBoundingRect() -
mouseDownInHandle
protected void mouseDownInHandle(int handle, int sx, int sy) - Overrides:
mouseDownInHandlein classRoi
-
deleteHandle
public void deleteHandle(double ox, double oy) -
deletePoint
protected void deletePoint(int index) -
getClosestPoint
-
fitSpline
public void fitSpline(int evaluationPoints) Fits a spline, which becomes the new shape of this Roi -
fitSpline
public void fitSpline()Fits a spline, which becomes the new shape of this Roi -
removeSplineFit
public void removeSplineFit() -
isSplineFit
public boolean isSplineFit()Returns 'true' if this selection has been fitted with a spline. -
fitSplineForStraightening
public void fitSplineForStraightening()Creates a spline fitted polygon with (roughly) one pixel segment lengths and sets it as the Roi shape. It can be retrieved using the getFloatPolygon() method. -
handleMouseUp
protected void handleMouseUp(int sx, int sy) With segmented selections, ignore first mouse up and finalize when user double-clicks, control-clicks or clicks in start box.- Overrides:
handleMouseUpin classRoi
-
addOffset
protected void addOffset() -
contains
public boolean contains(int x, int y) Returns whether the center of pixel (x,y) is contained in the Roi. The position of a pixel center determines whether a pixel is selected. Note the ImageJ convention of 0.5 pixel shift between outline and pixel centers, i.e., pixel (0,0) is enclosed by the rectangle spanned between (0,0) and (1,1). Points exactly at the left (right) border are considered outside (inside); points exactly on horizontal borders, are considered outside (inside) at the border with the lower (higher) y. This convention is opposite to that of the java.awt.Shape class. In x, the offset is chosen slightly below 0.5 to reduce the impact of numerical errors. -
containsPoint
public boolean containsPoint(double x, double y) Returns whether coordinate (x,y) is contained in the Roi. Note that the coordinate (0,0) is the top-left corner of pixel (0,0). Use contains(int, int) to determine whether a given pixel is contained in the Roi.- Overrides:
containsPointin classRoi
-
isHandle
public int isHandle(int sx, int sy) Returns a handle number if the specified screen coordinates are inside or near a handle, otherwise returns -1. -
getMask
Description copied from class:RoiAlways returns null for rectangular Roi's -
getLength
public double getLength()Returns the perimeter (for ROIs) or length (for lines). -
getUncalibratedLength
public double getUncalibratedLength() -
getAngle
public double getAngle()Returns the angle in degrees between the first two segments of this polyline. -
getNCoordinates
public int getNCoordinates()Returns the number of points that define this PolygonRoi.- See Also:
-
getXCoordinates
public int[] getXCoordinates()Obsolete; replaced by either getPolygon() or getFloatPolygon(). -
getYCoordinates
public int[] getYCoordinates()Obsolete; replaced by either getPolygon() or getFloatPolygon(). -
getNonSplineCoordinates
-
getNonSplineFloatPolygon
-
getPolygon
Returns this PolygonRoi as a Polygon.- Overrides:
getPolygonin classRoi- See Also:
-
getFloatPolygon
Returns this polygon or polyline as float arrays in image pixel coordinates.- Overrides:
getFloatPolygonin classRoi
-
size
public int size()Returns the number of points in this selection; equivalent to getPolygon().npoints. -
getInterpolatedPolygon
Description copied from class:RoiReturns, 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.- Overrides:
getInterpolatedPolygonin classRoi
-
clipRectMargin
protected int clipRectMargin()- Overrides:
clipRectMarginin classRoi
-
clone
Returns a copy of this PolygonRoi. -
setLocation
public void setLocation(double x, double y) Description copied from class:RoiSet the location of the ROI in image coordinates.- Overrides:
setLocationin classRoi
-
enableSubPixelResolution
public void enableSubPixelResolution()- Overrides:
enableSubPixelResolutionin classRoi
-
getDebugInfo
- Overrides:
getDebugInfoin classRoi
-