 # Measurement of lengths for 2k images

Hello Scholars,

I want to measure the length of bubbles from 2000 segmented images.

As attached here, the red part in the segmented image are the bubbles

, I want to measure the lengths of each bubble for 2000 images.

What’s the possible solution for this , ? response will be highly appreciated.

Thank you

If I were to use Matlab (or Python, or whatever you code in), for this, I would read only the red channel in your image, then I would take advantage of the fact that on your image, for each capillary, there is at least one pixel column that is contains within a given capillary. For each column, I would measure the number of consecutive individuals (pixels) that are red. Also, mind that when the first (or last) pixel of the column is red, then the bubble is truncated on this image.

I am sure there are other ways but this is a (hopefully good) start…

1 Like

https://imagej.nih.gov/ij/docs/guide/146-30.html#toc-Section-30
Paragraph:
30.7 Set Measurements…
(Feret’s diameter)

Then: have the RGB plugin —> CMYK. If yes then test this:

``````run("Duplicate...", "title=1");
run("Duplicate...", "title=2");
run("Invert");
run("RGB to CMYK");
selectWindow("CMYK_2");
run("Stack to Images");
close("K");close("Y");close("M");
setAutoThreshold("Li dark");
//run("Threshold...");
setOption("BlackBackground", true);
run("Set Measurements...", "area feret's add redirect=None decimal=4");
close("C");
close("2");
roiManager("Set Fill Color", "blue");
roiManager("Show All without labels");
``````

Greetings

1 Like

@LeChat , Thank you very much for your valuable comment. I will indeed try this way.

I will be back to you again.

@Mathew <3 , That is line to line guidance, I really appreciate the efforts and will try this way as well. I will be back to you soon. Thank you again

Hello
Here’s what I get from the left to the right:

• 2 bubbles (whole)
• two more bubbles
• then a bubble (whole)
• a bubble on the right (full)
Greetings 1 Like

A macro proposal for this treatment.

``````macro "Lane "
{
requires("1.52u");
setBackgroundColor(0,0,0);
setOption("BlackBackground",true);
img=getImageID();
//-------------------------
// Start batch mode
t0=getTime();
setBatchMode(true);
selectImage(img);
run("Duplicate...", "title=1");
close("\\Others");
run("Duplicate...", "title=2");
//--------------------------
// Start processing
run("Invert");
run("RGB to CMYK");
selectWindow("CMYK_2");
run("Stack to Images");
close("K");close("Y");close("M");
setAutoThreshold("Li dark");
//run("Threshold...");
run("Set Measurements...", "bounding display add redirect=None decimal=4");
h=getHeight();
l=getWidth();
a=0;
for(i=0;i<4;i++)
{
a++;
selectWindow("C");
makeRectangle(i*(l/4), 0, l/4, h);
//--------------------------------------------
// Change label of image and analyze
run("Duplicate...","title="+a );
run("Analyze Particles...", "size=10-Infinity display exclude add");
}
//------------------------------
run("Close All");
// End of processing
t1=getTime();
dt = t1-t0;
print("length of the procedure =",dt+" "+"ms" );
// End of batch mode
setBatchMode(false);
close("ROI Manager");
exit("All is done !");
}
``````

Respect Mathew,

I really appreciated your generosity of time and energy. The thing is, I have 2000 images. I want to follow the red area in the images only for its length. I can do that for single image manually.

I need a technique which can do that automatically, not necessarily on Image J. The code provided by you is indeed helpful for some cases but that again will work for particle.

Thank you very much.