Class PolygonSampler

java.lang.Object
imagingbook.common.geometry.fd.PolygonSampler

public class PolygonSampler extends Object

This class is used to re-sample 2D polygons by interpolation. See Sec. 2.1.1 (Alg. 26.1) if [1] for details. Note that this class has no public constructor, use getInstance() instead.

[1] W. Burger, M.J. Burge, Digital Image Processing – An Algorithmic Introduction Using Java, 2rd ed, Springer (2016).

Version:
2022/10/26
  • Method Details

    • getInstance

      public static PolygonSampler getInstance()
    • samplePolygon

      public Pnt2d[] samplePolygon(Pnt2d[] V, int M)
      Samples the closed polygon path specified by V at M equidistant positions.
      Parameters:
      V - the vertices of the (closed) polygon.
      M - the number of sample points.
      Returns:
      the sample points as an array of Point objects.
    • samplePolygon

      public Pnt2d[] samplePolygon(Pnt2d[] V, int M, double startFrac)
      For testing only: allows to choose an arbitrary start point by setting 'startFrac' in [0,1].
      Parameters:
      V - the vertices of the (closed) polygon.
      M - the number of sample points.
      startFrac - the position of the first sample as a fraction of the polggon's circumference in [0,1].
      Returns:
      the sample points as an array of Point objects.