Class ShapeSimplifier
This can help manage storage and performance requirements when working with large numbers of ROIs, especially in terms of repainting speed.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Path2D
simplifyPath
(Path2D path, double altitudeThreshold) Create a simplified path (fewer coordinates) using method based on Visvalingam's Algorithm, processing all segments.static Path2D
simplifyPath
(Path2D path, double altitudeThreshold, int segmentPointThreshold, double discardBoundsLength) Create a simplified path (fewer coordinates) using method based on Visvalingam's Algorithm, optionally skipping segments with few points.static PolygonROI
simplifyPolygon
(PolygonROI polygon, double altitudeThreshold) Create a simplified polygon (fewer coordinates) using method based on Visvalingam's Algorithm.static void
simplifyPolygonPoints
(List<Point2> points, double altitudeThreshold) Create a simplified polygon (fewer coordinates) using method based on Visvalingam's Algorithm.static ROI
simplifyROI
(ROI roi, double altitudeThreshold) Simplify a ROI using either polygon or general shape methods.static ROI
simplifyShape
(ROI shapeROI, double altitudeThreshold) Create a simplified shape (fewer coordinates) using method based on Visvalingam's Algorithm.smoothPoints
(List<Point2> points) Apply a simple 3-point moving average to a list of points.
-
Constructor Details
-
ShapeSimplifier
public ShapeSimplifier()
-
-
Method Details
-
simplifyPolygonPoints
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
-
-
simplifyShape
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
Create a simplified path (fewer coordinates) using method based on Visvalingam's Algorithm, processing all segments.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:
- See Also:
-
simplifyPath
public static Path2D simplifyPath(Path2D path, double altitudeThreshold, int segmentPointThreshold, double discardBoundsLength) Create a simplified path (fewer coordinates) using method based on Visvalingam's Algorithm, optionally skipping segments with few points.This method introduces
segmentPointThreshold
because simplifying multipolygons can produce a 'jagged' effect when the simplification is applied to segments that contain only a few vertices. This was particularly noticeable in QuPath's viewer, where a high altitude threshold is used.See references: https://hydra.hull.ac.uk/resources/hull:8338 https://www.jasondavies.com/simplify/ http://bost.ocks.org/mike/simplify/
- Parameters:
path
- the path to simplifyaltitudeThreshold
- the altitude thresholdsegmentPointThreshold
- the minimum number of points in a closed segment for simplification to be applied; segments with fewer points (after removing duplicates) will be retained unchanged.discardBoundsLength
- discard segments if bounding box dimensions are both smaller than this value; if ≤ 0, no segments are discarded based on bounding box size. This can be important when simplification is use to help render very large shapes at a low resolution.- Returns:
- the path with vertices (and possibly some segments) removed
- Since:
- v0.6.0
- See Also:
-
smoothPoints
Apply a simple 3-point moving average to a list of points.- Parameters:
points
-- Returns:
-
simplifyPolygon
Create a simplified polygon (fewer coordinates) using method based on Visvalingam's Algorithm.See references: Hydra Jason Davies Mike Bostock
- Parameters:
polygon
-altitudeThreshold
-- Returns:
-
simplifyROI
Simplify a ROI using either polygon or general shape methods.- Parameters:
roi
- the input ROI- Returns:
- a simplified copy of the input
-