Package qupath.ext.braian
Class BoundingBoxHierarchy
java.lang.Object
qupath.ext.braian.BoundingBoxHierarchy
The class
BoundingBoxHierarchy
is data structure that helps in searching for specific
PathObject
based on their shape and in logarithmic time to the total number
of object stored. The cost is paid at construction time, but it should be worth it if the look-up
operation is performed at least two times.
BoundingBoxHierarchy
was build targeting images with lots (1000+) of
PathDetectionObject
, but works with all PathObject
.
For more information check Bounding volume hierarchy.
-
Constructor Summary
ConstructorDescriptionBoundingBoxHierarchy
(Collection<? extends qupath.lib.objects.PathObject> objects) Builds a top-down BVH of maximum 6 levels of hierarchy.BoundingBoxHierarchy
(Collection<? extends qupath.lib.objects.PathObject> objects, int maxDepth) Builds a top-down BVH -
Method Summary
Modifier and TypeMethodDescriptionboolean
contains
(qupath.lib.objects.PathObject object) getBox()
Returns a rectangle in which all objects' ROI are insideint
getDepth()
Compute the BoundingBoxHierarchy's maximum depthqupath.lib.objects.PathObject
getOverlappingObject
(qupath.lib.objects.PathObject object) Retrieves the object in the hierarchy whose centroid: is inside the specifiedobject
is the closest to the specifiedobject
's centroid It followsROI.contains(double, double)
definition of insideness for determining the overlap.Optional<qupath.lib.objects.PathObject>
getOverlappingObjectIfPresent
(qupath.lib.objects.PathObject object) Retrieves the object in the hierarchy whose centroid: is inside the specifiedobject
is the closest to the specifiedobject
's centroid It followsROI.contains(double, double)
definition of insideness for determining the overlap.boolean
isEmpty()
Stream<qupath.lib.objects.PathObject>
toStream()
Visits each element of the hierarchy and outputs all the objects contained asStream
.
-
Constructor Details
-
BoundingBoxHierarchy
Builds a top-down BVH of maximum 6 levels of hierarchy.- Parameters:
objects
- the given objects to insert into the hierarchy
-
BoundingBoxHierarchy
public BoundingBoxHierarchy(Collection<? extends qupath.lib.objects.PathObject> objects, int maxDepth) Builds a top-down BVH- Parameters:
objects
- the given objects to insert into the hierarchymaxDepth
- the maximum depth that that hierarchy can have. Below maxDepth, the recursive structure stops and lists all the remaining objects
-
-
Method Details
-
getOverlappingObject
public qupath.lib.objects.PathObject getOverlappingObject(qupath.lib.objects.PathObject object) Retrieves the object in the hierarchy whose centroid:- is inside the specified
object
- is the closest to the specified
object
's centroid
ROI.contains(double, double)
definition of insideness for determining the overlap. Which, in turn, relies onGeometry.contains(Geometry)
and DE-9IM intersection matrix.- Parameters:
object
- the object to search the overlap for- Returns:
- the closest PathObject in the hierarchy, or null if there is no overlap
- See Also:
-
ROI.getCentroidX()
ROI.getCentroidY()
getOverlappingObjectIfPresent(PathObject)
- is inside the specified
-
contains
public boolean contains(qupath.lib.objects.PathObject object) -
getOverlappingObjectIfPresent
public Optional<qupath.lib.objects.PathObject> getOverlappingObjectIfPresent(qupath.lib.objects.PathObject object) Retrieves the object in the hierarchy whose centroid:- is inside the specified
object
- is the closest to the specified
object
's centroid
ROI.contains(double, double)
definition of insideness for determining the overlap. Which, in turn, relies onGeometry.contains(Geometry)
and DE-9IM intersection matrix.- Parameters:
object
- the object to search the overlap for- Returns:
- the closest PathObject in the hierarchy as an
Optional
- See Also:
-
ROI.getCentroidX()
ROI.getCentroidY()
getOverlappingObject(PathObject)
- is inside the specified
-
isEmpty
public boolean isEmpty()- Returns:
- true if there are no
PathObject
inside
-
toStream
Visits each element of the hierarchy and outputs all the objects contained asStream
.- Returns:
- the stream of all saved objects
-
getBox
Returns a rectangle in which all objects' ROI are inside- Returns:
- the bounding box of all objects
-
getDepth
public int getDepth()Compute the BoundingBoxHierarchy's maximum depth- Returns:
- the maximum depth of the hierarchy. Returns -1 if the BoundingBoxHierarchy is empty.
-