Class ShapeSimplifier

java.lang.Object
qupath.lib.roi.ShapeSimplifier

public class ShapeSimplifier extends Object
Helper methods for simplifying shapes, such removing polygon points while retaining the a similar overall shape at a coarser level.

This can help manage storage and performance requirements when working with large numbers of ROIs, especially in terms of repainting speed.

Author:
Pete Bankhead
  • Constructor Details

    • ShapeSimplifier

      public ShapeSimplifier()
  • Method Details

    • simplifyPolygonPoints

      public static void simplifyPolygonPoints(List<Point2> points, double altitudeThreshold)
      Create a simplified polygon (fewer coordinates) using method based on Visvalingam's Algorithm. The input is a list of points (the vertices) belonging to a closed polygon. This list is modified in place.

      See references: https://hydra.hull.ac.uk/resources/hull:8338 https://www.jasondavies.com/simplify/ http://bost.ocks.org/mike/simplify/

      Parameters:
      points -
      altitudeThreshold -
    • simplifyPolygon

      public static PolygonROI simplifyPolygon(PolygonROI polygon, double altitudeThreshold)
      Create a simplified polygon (fewer coordinates) using method based on Visvalingam's Algorithm.

      See references: https://hydra.hull.ac.uk/resources/hull:8338 https://www.jasondavies.com/simplify/ http://bost.ocks.org/mike/simplify/

      Parameters:
      polygon -
      altitudeThreshold -
      Returns:
    • simplifyShape

      public static ROI simplifyShape(ROI shapeROI, double altitudeThreshold)
      Create a simplified shape (fewer coordinates) using method based on Visvalingam's Algorithm.

      See references: https://hydra.hull.ac.uk/resources/hull:8338 https://www.jasondavies.com/simplify/ http://bost.ocks.org/mike/simplify/

      Parameters:
      shapeROI -
      altitudeThreshold -
      Returns:
    • simplifyPath

      public static Path2D simplifyPath(Path2D path, double altitudeThreshold)
      Create a simplified path (fewer coordinates) using method based on Visvalingam's Algorithm.

      See references: https://hydra.hull.ac.uk/resources/hull:8338 https://www.jasondavies.com/simplify/ http://bost.ocks.org/mike/simplify/

      Parameters:
      path -
      altitudeThreshold -
      Returns:
    • smoothPoints

      public static List<Point2> smoothPoints(List<Point2> points)
      Apply a simple 3-point moving average to a list of points.
      Parameters:
      points -
      Returns: