Posted by
Michael Schmid on
Nov 16, 2020; 11:25am
URL: http://imagej.273.s1.nabble.com/Problem-using-ImageJ-tp5024184p5024185.html
Hi Odeline,
the 'perimeter' reported by ImageJ is only the outer perimeter of a
particle, it does not include the perimeter of inner holes or particles
in these holes.
Here is a macro that measures the total perimeter, including the inner
perimeters. It does that inverting the particles to reveal the inner
holes. this process is repeated to revel particle in the inner holes,
etc., until nothing is left.
saveSettings();
run("Clear Results");
run("Create Mask");
id=getImageID();
do {
run("Set Measurements...", "perimeter redirect=None");
run("Analyze Particles...", " show=Masks display include");
run("Create Selection");
close();
selectImage(id);
run("Restore Selection");
run("Invert");
getStatistics(area, mean, min, max);
} while (max != 0);
selectImage(id);
close();
totalPerim=0;
for (i=0; i<nResults(); i++)
totalPerim = totalPerim + getResult("Perim.", i);
print("total perimeter = "+totalPerim);
restoreSettings();
Note that the total perimeter measured this way also includes the
perimeter at the borders of the image, although these are usually not
true particle borders. Unless the density of particle borders in the
image is high, this can make a substantial difference, and one should
correct for it. The most simple approximation would be subtracting the
pixel length for each edge pixel.
For your test image, my macro reports a total perimeter of 39545; this
overestimates the perimeter per area by about 2%. So it should not be an
issue; the errors due to pixel quantization noise and the simple
algorithm used for measuring the perimeter are worse.
[As a side remark, in the future please use more verbose subject lines
on the mailing list; something like "perimeter including inner holes"
would make it easier to find it on the list server. I did not change the
subject because this would make it more difficult to follow which post
is which thread.]
Michael
________________________________________________________________
On 16.11.20 10:59, Odeline Dumas wrote:
> Dear reader,
>
> I don't know if I'm in the right place to ask a question. My colleagues don't know how to answer it, so I didn't have many more possibilities than to contact you. I would like to measure the total perimeter of the interface between the red phase and the black phase (see here attached). As you can see on the attached picture, I have some issues. More precisely, an area on the left is not taken into account and all the black grains surrounded by red (or vice versa) are not taken into account even though I ticked 'include holes'. Can you help me?
>
> Thank you in advance,
>
> Odeline Dumas
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html