How do we interpret bounding box slices? #94
-
(Important Preface: THANK YOU for sharing this software. I greatly appreciate you for doing this! I'm a hobbyist using CC3D for a personal project, and really enjoying it!) I'm unsure how to interpret the Examplearray(
{
"voxel_counts": array(
[2146482952, 177614, 187470, 203816, 206556, 225240], dtype=uint64
),
"bounding_boxes": [
(slice(0, 4096, None), slice(0, 128, None), slice(0, 4096, None)),
(slice(3873, 3888, None), slice(0, 128, None), slice(2647, 2935, None)),
(slice(1, 14, None), slice(0, 128, None), slice(1613, 2062, None)),
(slice(788, 800, None), slice(0, 128, None), slice(1696, 1992, None)),
(slice(3921, 3936, None), slice(0, 128, None), slice(3593, 3934, None)),
(slice(771, 784, None), slice(0, 128, None), slice(1693, 2118, None)),
],
"centroids": array(
[
[2047.59790422, 63.49990168, 2047.33163892],
[3881.70964564, 64.4173939, 2810.15527492],
[5.79887982, 63.79729557, 1856.19388702],
[793.57173137, 63.7300997, 1817.91493308],
[3928.47374562, 63.04395418, 3778.4389415],
[777.17011188, 63.67610549, 1830.16461552],
]
),
},
dtype=object,
) In this example, let's say I want to understand the bounding box for the final component (with voxel_counts = 225240). The corresponding bounding box is Thanks so much in advance for any clarification you may be able to offer! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Thank you for writing in! I really appreciate that you're getting a lot of use out of this library! The bounding boxes are designed to make it easy to obtain a cutout from the output connected component labels (let's call them Let's assume I want to access the cutout of connected component label 5: cc_labels, N = cc3d.connected_components(labels, return_N=True)
assert N >= 5, "Not enough connected components"
stats = cc3d.statistics(cc_labels)
bboxes = stats["bounding_boxes"]
cutout = cc_labels[bboxes[5]] This is kind of similar to how scipy does it: https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.find_objects.html However, a big difference is that scipy doesn't calculate the bounding box of the background value 0, so the index into the array is offset by -1. e.g. bboxes = scipy.ndimage.find_objects(cc_labels)
cutout = cc_labels[bboxes[5 - 1]] EDIT: Forgot to answer your question.
A Read more about |
Beta Was this translation helpful? Give feedback.
Thank you for writing in! I really appreciate that you're getting a lot of use out of this library!
The bounding boxes are designed to make it easy to obtain a cutout from the output connected component labels (let's call them
cc_labels
). The dimensions of the bounding boxes are a close crop (the minimum sized box) needed to enclose a label with a parallelepiped geometry.Let's assume I want to access the cutout of connected component label 5:
This is kind of similar to how scipy …