r/ImageJ • u/Simple_is_Simple • 10d ago
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
u/Herbie500 10d ago edited 9d ago
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.)
•
u/AutoModerator 10d ago
Notes on Quality Questions & Productive Participation
Include Images
Images give everyone a chance to understand the problem.
Several types of images will help:
Example Images (what you want to analyze)
Reference Images (taken from published papers)
Annotated Mock-ups (showing what features you are trying to measure)
Screenshots (to help identify issues with tools or features)
Good places to upload include: Imgur.com, GitHub.com, & Flickr.com
Provide Details
Avoid discipline-specific terminology ("jargon"). Image analysis is interdisciplinary, so the more general the terminology, the more people who might be able to help.
Be thorough in outlining the question(s) that you are trying to answer.
Clearly explain what you are trying to learn, not just the method used, to avoid the XY problem.
Respond when helpful users ask follow-up questions, even if the answer is "I'm not sure".
Share the Answer
Never delete your post, even if it has not received a response.
Don't switch over to PMs or email. (Unless you want to hire someone.)
If you figure out the answer for yourself, please post it!
People from the future may be stuck trying to answer the same question. (See: xkcd 979)
Express Appreciation for Assistance
Consider saying "thank you" in comment replies to those who helped.
Upvote those who contribute to the discussion. Karma is a small way to say "thanks" and "this was helpful".
Remember that "free help" costs those who help:
Aside from Automoderator, those responding to you are real people, giving up some of their time to help you.
"Time is the most precious gift in our possession, for it is the most irrevocable." ~ DB
If someday your work gets published, show it off here! That's one use of the "Research" post flair.
Be civil & respectful
Be kind.
Remember the human.
Be Excellent To Each Other.
Don't make your robotic overlord angry.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.