Estimating object area size

Hello friends,

I have been following this forum for a while now but this is my first post since I couldn’t find anything similar in the previous asks. Hope someone has a good idea.

I have a black and white cross section image of a uCT scan of a bone (see example image). As I have a couple of thousands of them I would like to automate measuring the object area size. However, the outline of the bone is in most cases interrupted. Basically I would like to have a fitted area around the outer most pixels (see second image). Is there any way to automate this so I can run it on my 10.000+ images?

Please feel free to point out a thread if this has been asked previously.

Thanks in advance!!!

40812984_fe_rec1327.tif (9.8 MB)

1 Like

Fitting a convex hull may be a starting point, but the indentations would be problem.
Good luck,
Volko

Hi @ArneK, welcome to the forum!

The image you posted is very nice and since you have a significant number of them at such high resolution it must be a challenge to work with them in the ImageJ framework.

Have you checked out CLIJ2 and CLIJx plugins? These are great for X-ray tomography image sets since the plugin utilizes a dedicated or integrated graphics card to perform image processing steps. This speeds up these types of things very nicely if you need to use the ImageJ platform. Check out the website here https://clij.github.io/, the plugin is maintained by @haesleinhuepf and it has its own sub-category in the forum.image.sc here: https://forum.image.sc/tag/clij

I don’t have much experience with BoneJ and it may do exactly what you need it to. I did play around with your image a little bit in CLIJ2. Basically just performed a median smoothing of the slice, then Otsu’s thresholding, then a closing operation with a very high number of iterations (see the steps from ImageJ’s macro recorder below.

This result is close to what you have done with clicking points around some “edge”. I’m not sure how you decided on some of the points as there is no clear edge in the unprocessed slice so it’s either rather arbitrary or informed from your experience.

BTW, MorphoLib is a plugin that has some nice morphological operations (closing, opening, erosion, dilation, etc.) and I would suggest checking that out too.

Since your data sets are rather large, I suggest trying things out on a small subset of slices (10-20) first, then seeing if you can adapt things to your large image stack. There are plenty of examples of scripts on the CLIJ forum to help with setting things up in an ImageJ macro scripting language to get you started on that.

run("CLIJ2 Macro Extensions", "cl_device=[Quadro P3200]");

// median
image1 = "40812984_fe_rec1327.tif";
Ext.CLIJ2_push(image1);
image2 = "median1583229316";
radius_x = 3.0;
radius_y = 3.0;
Ext.CLIJ2_median2DSphere(image1, image2, radius_x, radius_y);
Ext.CLIJ2_pull(image2);

// threshold otsu
Ext.CLIJ2_push(image2);
image3 = "threshold_otsu173268586";
Ext.CLIJ2_thresholdOtsu(image2, image3);
Ext.CLIJ2_pull(image3);

// closing
Ext.CLIJ2_push(image3);
image5 = "closing1324974869";
number_of_dilations_and_erotions = 175.0;
Ext.CLIJ2_closingDiamond(image3, image5, number_of_dilations_and_erotions);
Ext.CLIJ2_pull(image5);

Let me know if you have any questions, and good luck with your analyses!

1 Like

It would be super-hard for an algorithm (or even a person) to reliably make this line, given the sparse trabeculae to lower left, although convex hull may approximate it. Have you already masked out the cortical bone? (I guess not, because it looks as though there is a bunch of cutting swarf left behind on upper right - you should get rid of that prior to making measurements) If so, you may be able to segment based on the endosteal surface of the cortex, rather than of the trabeculae as you are showing here, using some logical operations.

Try the Interpolate ROIs command in the ROI manager. Add an ROI every 20 slices or so, using [t] on the keyboard, then in the ROI Manager find the Interpolate ROIs command. It is stupid (no fancy image guidance, pixel weighting, AI, or anything), but may save you quite a bit of time.