Class ObjectMerger
- All Implemented Interfaces:
ObjectProcessor
This is designed to be used for post-processing a segmentation, to help resolve tile boundaries.
- Since:
- v0.5.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectMerger
createIoMinMerger
(double iomThreshold) static ObjectMerger
createIoMinMerger
(double iomThreshold, MeasurementStrategy measurementStrategy) Create an object merger that can merge together any objects with sufficiently large intersection over minimum area (IoMin).static ObjectMerger
createIoUMerger
(double iouThreshold) static ObjectMerger
createIoUMerger
(double iouThreshold, MeasurementStrategy measurementStrategy) Create an object merger that can merge together any objects with sufficiently large intersection over union.static ObjectMerger
static ObjectMerger
createSharedClassificationMerger
(MeasurementStrategy measurementStrategy) Create an object merger that can merge together any objects with similar ROIs (e.g.static ObjectMerger
createSharedTileBoundaryMerger
(double sharedBoundaryThreshold) static ObjectMerger
createSharedTileBoundaryMerger
(double sharedBoundaryThreshold, double overlapTolerance) static ObjectMerger
createSharedTileBoundaryMerger
(double sharedBoundaryThreshold, double overlapTolerance, MeasurementStrategy measurementStrategy) Create an object merger that uses a shared boundary IoU criterion and overlap tolerance.static ObjectMerger
createSharedTileBoundaryMerger
(double sharedBoundaryThreshold, MeasurementStrategy measurementStrategy) Create an object merger that uses a shared boundary IoU criterion and default overlap tolerance.static ObjectMerger
static ObjectMerger
createTouchingMerger
(MeasurementStrategy measurementStrategy) Create an object merger that can merge together any objects with similar ROIs (e.g.merge
(Collection<? extends PathObject> pathObjects) Deprecated.process
(Collection<? extends PathObject> pathObjects) Calculate the result of applying the merging strategy to the input objects.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface qupath.lib.objects.utils.ObjectProcessor
andThen
-
Method Details
-
merge
Deprecated.Useprocess(Collection)
insteadMerge the input objects using the merging strategy.- Parameters:
pathObjects
- the input objects for which merges should be calculated- Returns:
- a list of objects, with the same number or fewer than the input
-
process
Calculate the result of applying the merging strategy to the input objects.The output list will contain the same number of objects or fewer. Objects that are not merged will be returned unchanged, while objects that are merged will be replaced by a new objects with a new ROI.
New objects will be assigned new IDs. Classifications will be preserved, but other measurements and properties will not be.
No guarantees are made about the mutability or ordering of the returned list.
- Specified by:
process
in interfaceObjectProcessor
- Parameters:
pathObjects
- the input objects for which merges should be calculated- Returns:
- a list of objects, with the same number or fewer than the input
-
createTouchingMerger
Create an object merger that can merge together any objects with similar ROIs (e.g. points, areas) that also touch one another.Objects must also have the same classification and be on the same image plane to be mergeable.
Note that this is a strict criterion following the Java Topology Suite definition of touching, which requires that the boundaries of the geometries intersect, but the interiors do not intersect.
This strictness can cause unexpected results due to floating point precision issues, unless it is certain that the ROIs are perfectly aligned (e.g they are generated using integer coordinates on a pixel grid).
If this is not the case,
createSharedTileBoundaryMerger(double, double)
is usually preferable, since it can include a small overlap tolerance.- Parameters:
measurementStrategy
- strategy for merging measurements from merged objects.- Returns:
- an object merger that can merge together any objects with similar ROIs and the same classification
- See Also:
-
createTouchingMerger
- See Also:
-
createIoUMerger
public static ObjectMerger createIoUMerger(double iouThreshold, MeasurementStrategy measurementStrategy) Create an object merger that can merge together any objects with sufficiently large intersection over union.Objects must also have the same classification and be on the same image plane to be mergeable.
IoU is calculated using Java Topology Suite intersection, union, and getArea calls.
This merger assumes that you are using an OutputHandler that doesn't clip to tile boundaries (only to region requests) and that you are using sufficient padding to ensure that objects are being detected in more than on tile/region request. You should probably also remove any objects that touch the regionRequest boundaries, as these will probably be clipped, and merging them will result in weirdly shaped detections.
- Parameters:
iouThreshold
- Intersection over union threshold; any pairs with values greater than or equal to this are merged.measurementStrategy
- strategy for merging measurements from merged objects.- Returns:
- an object merger that can merge together any objects with sufficiently high IoU and the same classification
-
createIoUMerger
- See Also:
-
createIoMinMerger
public static ObjectMerger createIoMinMerger(double iomThreshold, MeasurementStrategy measurementStrategy) Create an object merger that can merge together any objects with sufficiently large intersection over minimum area (IoMin). This is similar to IoU, but uses the minimum area of the two objects as the denominator.This is useful in the (common) case where we are happy for small objects falling within larger objects to be swallowed up by the larger object.
Objects must also have the same classification and be on the same image plane to be mergeable.
IoM is calculated using Java Topology Suite intersection, union, and getArea calls.
This merger assumes that you are using an OutputHandler that doesn't clip to tile boundaries (only to region requests) and that you are using sufficient padding to ensure that objects are being detected in more than on tile/region request. You should probably also remove any objects that touch the regionRequest boundaries, as these will probably be clipped, and merging them will result in weirdly shaped detections.
- Parameters:
iomThreshold
- Intersection over minimum threshold; any pairs with values greater than or equal to this are merged.measurementStrategy
- strategy for merging measurements from merged objects.- Returns:
- an object merger that can merge together any objects with sufficiently high IoM and the same classification
- Implementation Note
- This method does not currently merge objects with zero area. It is assumed that they will be handled separately.
-
createIoMinMerger
- See Also:
-
process(Collection)
instead