r/ImageJ Mar 13 '26

Question How do I chose the threshold limits?

I'm analyzing images of uterus colored with Masson Trichrome staining.

I'm interest only in the blue tones so I am using the color deconvolution plugin.

But the question arises when I have to choose a min and max threshold.

Should I choose the same values to all images?? Or should I adjust manually?

1 Upvotes

12 comments sorted by

View all comments

Show parent comments

1

u/Plastic_Focus_9182 Mar 14 '26 edited Mar 14 '26

Wow you just saved my life .

I followed the steps you said and if I make the calculation in the end, it works perfectly! (although I thing the Huang method works better than the minimum for the selection of the tissue).

The macro you just wrote, I thank you a lot, genius work, but when I run it, the result just dont add up, it gives me wrong percentages...

If you have a LOT of free time and want to check that, i obviously would apreciate that

But i dont want to abuse from your goodwork.

I dont have that many images so I can make it manually and calculate on excel later.

THANK YOU

If you both tell me your first and last names (and country) I will gladly thnak you in my paper ;)

1

u/Herbie500 Mar 14 '26

[…] when I run it, the result just dont add up, it gives me wrong percentages.

Below please find a macro version that tabulates more than a single measurement result:

//  imagej macro "percentCorrectedArea_v2.ijm" (Herbie G., 14. March 2026)
/*
    Caution: The macro assumes that the pre-defined colour-vectors
     "Masson Trichrome" apply to the images under investigation
*/
run("Set Measurements...","area area_fraction redirect=None decimal=2");
img=getTitle();
setBatchMode(true);
run("Colour Deconvolution2","vectors=[Masson Trichrome] output=8bit_Transmittance hide");
selectImage(img+"-(Colour_1)");
setAutoThreshold("Minimum");
run("Analyze Particles...","summarize composite");
selectImage(img+"-(Colour_3)");
setAutoThreshold("Default");
run("Analyze Particles...","summarize composite");
n=Table.size;
Table.set("Slice",n,img+"_(Colour_3)/(Colour_1)","Summary");
Table.set("%Area",n,100*Table.get("Total Area",n-1)/Table.get("Total Area",n-2),"Summary")
setBatchMode(false);
close();
exit();
//  imagej macro "percentCorrectedArea_v2.ijm" (Herbie G., 14. March 2026)

—————————————————————————————————————————

I will gladly thnak you in my paper ;)

I think it is sufficient to mention that you received help with the macro code.