Module ij
Package ij.process

Class PolygonFiller


  • public class PolygonFiller
    extends java.lang.Object
    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

      Constructors 
      Constructor Description
      PolygonFiller()
      Constructs 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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void fill​(ImageProcessor ip, java.awt.Rectangle r)
      Fills the polygon using the ImageProcessor's current drawing color.
      void fillByteProcessorMask​(ByteProcessor mask)
      Fills the ByteProcessor with 255 inside the polygon
      ImageProcessor getMask​(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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • 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 Detail

      • 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

        public void fill​(ImageProcessor ip,
                         java.awt.Rectangle r)
        Fills the polygon using the ImageProcessor's current drawing color.
      • getMask

        public ImageProcessor getMask​(int width,
                                      int height)
        Returns a byte mask containing a filled version of the polygon.
      • fillByteProcessorMask

        public void fillByteProcessorMask​(ByteProcessor mask)
        Fills the ByteProcessor with 255 inside the polygon