How to find the area of an irregular image?

I need to find the area of an irregular shape and I dont want to use “free hand” to select the border

s.

Hi
@Zeynab_Mousavi
Can such a result be suitable?

Yeah, I think blurring and thresholding -> Analyze particles is likely the best option. If you want to ignore intensity in the original image, you might want to threshold/binarize first (values 0 or 1), convert to 8bit again, multiple by 255 (values 0 or 255), then blur and threshold followed by analyze particles.

1 Like

Hello All,
Thanks for this excellent input. In that similar line I have some 256 images to be quantified. I have attached a representative image of it for your kind scrutiny. It is a brain section of a rat stained with ‘Weil myelin stain’. The ROI will be the myelinated areas (ROI’s stainned in black). I was successful enough to threshold the images and convert into a binary format and then tried to analyze the particles by auto thresholding them with phansalkar method, and the option black background was removed, so that the black myelinated ROI’s get converted into white structures and a black background.
The only issue is the tile edges project a false white particles along its border. I will try to upload another image in the next upload due to size.

Question- Is there any way to reduce the noise in the edges of the integrating tiles (each individual ones)
Thanks for the suggestions in advance

Those look like consistent edge frame effects that are best removed when taking the image. If you can rescan, I would recommend adjusting the background subtraction, or take a blank image and attempt to manually perform the background subtraction on each of the initial tiles prior to stitching.

Many problems are best fixed at acquisition!

Hi @Dayalan!

You will definitely benefit from performing a flat-field correction before stitching. Do you have the orginal tiles? If so, you can try to correct them using a flat-field estimate from the ensemble (instead of a flat-field acquired along with the samples, which is the proper way to go).

Cheers!
Nico

Thanks. I will try it out

@Mathew Hi Mathew Yes I think that would work but I dont want to use freehand selection for boundaries.

Hi
@Zeynab_Mousavi
just to help

// Macro "20191218_Find the area"

run("Duplicate...", "title=1");
run("Duplicate...", "title=2");
setAutoThreshold("Percentile dark");
//run("Threshold...");
setOption("BlackBackground", true);
run("Convert to Mask");
run("Gaussian Blur...", "sigma=5");
setAutoThreshold("Percentile dark");
//run("Threshold...");
run("Convert to Mask");
run("Analyze Particles...", "display add");
selectWindow("1");
roiManager("Select", 0);
roiManager("Show All without labels");
roiManager("Select", 0);
run("Enlarge...", "enlarge=-15");
roiManager("Add");
roiManager("Show None");
1 Like

@Mathew was very helpful. Thanks

By the way how can I change the threshold?

Read this:

https://imagej.nih.gov/ij/docs/guide/146-28.html#toc-Subsection-28.2

@Mathew I used the code you shared and it worked for some images but for this image it gives very strange result:


I attahced the given ROI.
RoiSet.zip (1.6 KB)

Hi @Zeynab_Mousavi

Please open a new thread on the forum.
Specify with a draw what you want to have. Is it this? .

@Mathew It is exactly what I am asking in this question: I need to find the border without using “free hand” selection so I need to ask it here.
Yes I am trying to find the borders similar to the image you presented. I use the code shared above and it worked for several images but it didnot work for this image and similar images attached (like a ribbon shape).

Hi @Zeynab_Mousavi

Test this:

// Macro 20191222_Area of an irregular image.jpeg
img=getImageID();
setBatchMode("true");
roiManager("Set Color", "red");
run("Duplicate...", "title=copy1");
run("Duplicate...", "title=copy2");
setAutoThreshold("Percentile dark");
//run("Threshold...");
//setThreshold(1, 255);
run("Convert to Mask");
run("Gaussian Blur...", "sigma=5");
setAutoThreshold("Percentile dark");
//run("Threshold...");
//setThreshold(1, 255);
run("Convert to Mask");
rename( "2");
run("Duplicate...", "1");
run("Analyze Particles...", "display add in_situ");
selectWindow("2");
run("Invert");
run("Analyze Particles...", "display add in_situ");
roiManager("Select", newArray(0,2));
roiManager("Add");
roiManager("Select", 3);
selectWindow("copy1");
roiManager("Show All without labels");
close("\\Others");
setBatchMode("false");
exit();
1 Like

@Mathew Thanks. I have a set of images which might have different types of geometries. My question is that why I can not use the previous code for this specific image (ribbon)?
It is not technically possible to separate the images to use this code for ribbon image and previous code for the rest.
I need a code to be general and applicable to all types of images.

I used this code and got this strange result:
1

@Zeynab_Mousavi
Is this another scenario?
Please upload an image.

1 Like

@Mathew
No it is not. It is exactly the same image I uploaded above and I ran the code you suggested and got super weird result (reported in the previous comment).
Thanks Mathew for your helps.