java.lang.Object
ij.process.PolygonFiller
This class fills polygons using the scan-line filling algorithm
described at "http://www.cs.rit.edu/~icss571/filling/".
Note that by ImageJ convention, outline and pixel coordinates are shifted by 0.5:
Pixel (0,0) is enclosed by the rectangle between (0,0) and (1,1); thus all 0.5
is added to all polygon coordinates when comparing to pixel coordinates.
After applying this offset, rounding is done such that points
exactly on the left boundary are considered outside, points
exactly on the right boundary inside.
Points exactly on a horizontal boundary are considered ouside for
the boundary with lower y and inside for the boundary with the higher y.
(actually, the boundary is slightly shifted to the left (in x) to ensure
correct rounding in spite of the final numeric accuracy)
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a PolygonFiller.PolygonFiller
(float[] xf, float[] yf, int n, double xOffset, double yOffset) Constructs a PolygonFiller using the specified polygon with floating-point coordinates.PolygonFiller
(int[] x, int[] y, int n) Constructs a PolygonFiller using the specified polygon with integer coordinates. -
Method Summary
Modifier and TypeMethodDescriptionvoid
fill
(ImageProcessor ip, Rectangle r) Fills the polygon using the ImageProcessor's current drawing color.void
Fills the ByteProcessor with 255 inside the polygongetMask
(int width, int height) Returns a byte mask containing a filled version of the polygon.void
setPolygon
(float[] xf, float[] yf, int n, double xOffset, double yOffset) Specifies the polygon to be filled in case of float coordinates.void
setPolygon
(int[] x, int[] y, int n) Specifies the polygon to be filled.
-
Constructor Details
-
PolygonFiller
public PolygonFiller()Constructs a PolygonFiller. -
PolygonFiller
public PolygonFiller(int[] x, int[] y, int n) Constructs a PolygonFiller using the specified polygon with integer coordinates. -
PolygonFiller
public PolygonFiller(float[] xf, float[] yf, int n, double xOffset, double yOffset) Constructs a PolygonFiller using the specified polygon with floating-point coordinates.
-
-
Method Details
-
setPolygon
public void setPolygon(int[] x, int[] y, int n) Specifies the polygon to be filled. -
setPolygon
public void setPolygon(float[] xf, float[] yf, int n, double xOffset, double yOffset) Specifies the polygon to be filled in case of float coordinates. In this case, multiple polygons separated by one set of NaN coordinates each. -
fill
Fills the polygon using the ImageProcessor's current drawing color. -
getMask
Returns a byte mask containing a filled version of the polygon. -
fillByteProcessorMask
Fills the ByteProcessor with 255 inside the polygon
-