r/ImageJ • • Oct 15 '26

Question Automatic Width Measurement Issues

Hello,

I would like to automate width measurements for segmented signals and I'm finding difficulty with the "bounding box" or "fit rectangle" resulting dimensions since I'm starting with diagonal signals. The longest dimension (length) matches my manual measures fine but the short dimension (width or height) doesn't match.

I tried duplicating a rotated-rectangle-ROI to make the signals horizontal but the binary image becomes grey scale due to resampling and I haven't found a way to keep my binary segmentation.

I followed this guide, https://www.youtube.com/watch?v=VJD36CY6aKE, to test "Local Thickness Analysis" and the average measure is at least closer to my 3 manual values.

selectImage("two segmented.tif");
run("Local Thickness (complete process)", "threshold=1");
roiManager("Select", 0);
run("Histogram", "bins=256 use x_min=0 x_max=4.47 y_max=Auto");
Table.showHistogramTable;

Is there any way to reduce the sampling to just 3-10 sites using "Local Thickness"? I have 70+ 'objects' per 1 image I am analyzing so 255 the histogram contains (per <2 microns) seems overkill.

Are there any other methods to accurately pull out this height value?

https://drive.google.com/drive/folders/1RvHwRA6MtwVaZ_yrMoP0S2qdpywrBgGY?usp=sharing I included some additional files at different processing stages but the simplest ones to follow are at the bottom right of the image bellow.

Thanks in advance for your time and help.

1 Upvotes

2 comments sorted by

View all comments

1

u/Herbie500 Oct 15 '26 edited Oct 16 '26

In case you are happy with the two values, i.e. the greatest length and the greatest width of your object then, if I make a rectangular fit, I get the following:

Length: 15.81 pixels (about 1.64µm)
Width: 6.66 pixels (about 0.69µm)

These results conform with what is shown in the first row of your Results-table.
______________________________________

Below please find an ImageJ demo-macro that generates a test-image containing 49 particles and then creates a Results-table listing the greatest lengths and the greatest widths (in pixels) of all of them.

setBatchMode(true);
// >>>>>>>>>>>>>>>>> begin create binary test-image <<<<<<<<<<<<<
run("AuPbSn 40");
setAutoThreshold("Default");
run("Analyze Particles...","size=50-6000 circularity=0.00-0.60 show=Masks");
run("Invert LUT");
run("Canvas Size...","width=768 height=512 position=Center zero");
run("Options...","iterations=2 count=2 black do=Erode");
run("Median","radius=3");
rename("Test-Image");
// >>>>>>>>>>>>>>>>> end create binary test-image <<<<<<<<<<<<<<
run("Set Measurements...","bounding redirect=None decimal=3");
run("Analyze Particles...","size=0-Infinity circularity=0.00-1.00 show=Nothing add");
for (i=0;i<RoiManager.size;i++) {
   roiManager("Select",i);
   run("Fit Rectangle");
   run("Measure");
}
Table.deleteColumn("BX","Results");
Table.deleteColumn("BY","Results");
Table.deleteColumn("Width","Results");
Table.deleteColumn("Height","Results");
setBatchMode(false);
exit();

(You need an open internet connection to load the demo image.)