Class MarchingSquares


  • public class MarchingSquares
    extends java.lang.Object
    A simple implementation of the marching squares algorithm that can identify perimeters in an supplied raster.
    • Constructor Summary

      Constructors 
      Constructor Description
      MarchingSquares​(int width, int height, VoronoiCell cell, VoronoiOutputRaster outputRaster)
      Creates a new object that can locate perimeter paths in the supplied raster.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Path identifyPerimeter()
      A convenience method that locates at least one perimeter in the raster with which this object was constructed.
      Path identifyPerimeter​(int initialX, int initialY)
      Finds the perimeter between a set of cells which begins at the specified data element.
      • Methods inherited from class java.lang.Object

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

      • MarchingSquares

        public MarchingSquares​(int width,
                               int height,
                               VoronoiCell cell,
                               VoronoiOutputRaster outputRaster)
        Creates a new object that can locate perimeter paths in the supplied raster.
        Parameters:
        width - the width of the outputRaster matrix
        height - the width of the outputRaster matrix
        cell - the type of cell we are interested in
        outputRaster - the raster
    • Method Detail

      • identifyPerimeter

        public Path identifyPerimeter​(int initialX,
                                      int initialY)
        Finds the perimeter between a set of cells which begins at the specified data element. If no initial point is known, consider using the convenience method supplied. The paths returned by this method are always closed.
        Parameters:
        initialX - the column of the data matrix at which to start tracing the perimeter
        initialY - the row of the data matrix at which to start tracing the perimeter
        Returns:
        a closed, anti-clockwise path that is a perimeter of between a set of zero and non-zero values in the data.
        Throws:
        java.lang.IllegalArgumentException - if there is no perimeter at the specified initial point.
      • identifyPerimeter

        public Path identifyPerimeter()
        A convenience method that locates at least one perimeter in the raster with which this object was constructed. If there is no perimeter (ie. if all elements of the supplied array are identically zero) then null is returned.
        Returns:
        a perimeter path obtained from the raster, or null