QuadTreeRegion#
- class scarlet2.detect.QuadTreeRegion(bbox, capacity=5, sub_regions=None, boxes=None, depth=0, detect=None)[source]#
Bases:
objectA QuadTree that stores bounding boxes (rather than points).
Boxes that span sub-region boundaries are stored in all overlapping sub-regions so that
query()always returns the full set of overlapping boxes.- Parameters:
bbox (
Box) – The box that encloses this region.capacity (
int) – Maximum number of boxes before the region is split.sub_regions (
listofQuadTreeRegion, optional) – Pre-existing sub-regions (normally left asNone).boxes (
listofBox, optional) – Pre-existing boxes (normally left asNone).depth (
int) – Depth of this node in the full tree (used for debugging).detect (
array-like, optional) – Detection image; when provided enables debug visualisations.
- add_footprints(footprints)[source]#
Insert bounding boxes for a list of
Footprintobjects.Each box gets a
.footprintattribute pointing back to the originatingFootprintso it can be retrieved from a query.- Parameters:
footprints (
listofFootprint) – Footprints to add bounding boxes for.- Return type:
self
- footprint_image(bbox=None)[source]#
Return a 2-D image of all footprint masks in the tree.
- Parameters:
bbox (
Box, optional) – Output image bounding box. IfNone, the union of all footprint bounding boxes is used.- Returns:
image
- Return type:
ndarray
- query(other_box=None)[source]#
Return all boxes that overlap with
other_box.- Parameters:
other_box (
Box, optional) – Query box. Defaults to the full region bbox.- Returns:
results – Boxes that overlap with
other_box. Asetis used so that boxes stored in multiple sub-regions are only returned once.- Return type:
setofBox