Calculate Bounding Box

fiji
imagej
#1

Hi,

I’m writing a macro to extract 3d geometric data from segmented image stacks using 3D Roi manager.

I have an image stack segmented into a number of 3d objects, and I can read geometrical data from each ROIs (the data displayed in the 3D Results window, such as vol and feret), using the Ext.Manager3D_Measure3D() function.

However I am having trouble obtaing the vol bounding box value displayed in the 3d results window. I cannot read this value directly, and I cannot figure out how it is calculated, and cannot find any information on how it is calculated. Does anyone have this info?

Cheers

Ian

0 Likes

#2

Based on the information I found here, it looks like CX, CY, CZ are the coordinates of the center of the bounding volume (which can also be obtained via Ext.Manager3D_Centroid3D). There also appears to be Ext.Manager3D_Bounding3D which should do exactly what you are looking for. However, I am not sure why they have the first argument as 0.

0 Likes

#3

Andrew,

Thanks for the reply.

I have tried the Ext.Manager3D_Bounding3D, but this function returns the coordinates of the bounding box, not the volume of it. Furthermore, I have tried to calculate the volume using these coordinates, but to no avail. I thought it would be as simple as [(Xmax-Xmin) * (Ymax-Ymin) * (Zmax - Zmin)] but this approach gives a bounding box that is smaller in volume than that reported in the results. The first is 0 as it is referring to the 0th object in the ROI manager, as far as I know.

Cheers

Ian

1 Like

#4

I see. Is it possible that you have a scale set in your image that is being applied to one result but not the other?

0 Likes

#5

Maybe the formula should be (Xmax - Xmin +1) * (Ymax - Ymin +1) * (Zmax - Zmin +1)?
I don’t fully understand what you mean with the first 0 and the 0th object in the ROI manager… But perhaps it is because you’re having Xmax == Xmin ?

In your formula, in this case you get a 0 in multiplication, whereas with mine, you assume the size is 1 pixel in that dimension.

1 Like

#6

I will clarify with my results:

For example, for object 1, I am trying to extract or calculate the 7,525 value for a macro.

I tried by calculation:
[(Xmax-Xmin) * (Ymax-Ymin) * (Zmax - Zmin)] = (517-483) * (279 - 237) * (4-0) = 5712

Also, the function:
Ext.Manager3D_Measure3D(i,“Vol”,measure); can be used to extract volume, and other metrics, but not volbounding box.

Ian

0 Likes

#7

That’s it. With the formula I posted you get
(517-483+1) * (279-237+1) * (4-0+1)=7525!

The key is to think that e.g. if in axes X the bounding box starts at voxel 200 and ends at 250, it is not 50 voxels wide, but 51.

1 Like

#8

Fergarcia,

You’re as sharp as a tack! Thats it.

Thanks

Ian

0 Likes

#9

My pleasure, Ian :smiley:
Just let me ask you to mark the post as solved. There should be some ticker to do so, and this way others can benefit by focusing on unsolved ones.

0 Likes