Calculation of area in a segmented image

Hello everyone,

I have segmented my images and in order to find the ROI (region of interest) which is pores, I used imagej. Can anybody help me how I can calculate the area, circularity and … both of the white/black portions. I tried to calculate the properties of the black portions but the result is incorrect (the total area of the space is 2500 and the calculated area by imagej is 2277!!!


Hello Esha -

More detail on what you did that didn’t work would be helpful.
(The best detail would be a complete, runnable script or macro
that reproduces your issue.)

How did you “segment?” Do you think your problem is with
the segmentation, or just the measurement, or both?

Are you trying to do your analysis by running commands from
the Fiji / ImageJ menu bar one by one? Or are you trying to
“automate” your analysis process by writing a script or macro?

Here is a complete, runnable IJM macro (created mostly with the
“Macro Recorder”, Plugins > Macros > Record...) that does
something similar to what I think you want with the “Blobs (25K)”
sample image:

run("Blobs (25K)");
setAutoThreshold("Default no-reset");
setOption("BlackBackground", true);
run("Convert to Mask");
run("Analyze Particles...", "display add in_situ");
run("Set Measurements...", "area centroid shape add redirect=None decimal=4");
saveAs("Results", "blobs_results.csv")
saveAs("PNG", "blobs_results")

(You should pretty much be able to figure out the menu commands
to run one by one, if that’s what you want, to get the same result as
running the macro.)

Here are the resulting measurements as a .csv file:

blobs_results.csv (6.5 KB)

For example, the circularity of each “particle” appears in the column
headed “Circ.” in the .csv file.

Here is the analyzed image, flattened and saved as a PNG file:


I’m not sure what you’re asking here (primarily because I’m not
sure what you actually did). Could you give more detail on what
you did, what you got, and what you wanted to get?

(As an aside, it would be helpful if instead of posting screen-shots
you could post original images, preferably in a non-lossy format
such as PNG or TIFF, rather than a lossy format such as JPEG.)

Thanks, mm

1 Like


As @mountain_man said… would you be able to share with us the original image you are trying to segment? That way - we can help you build a more tailored workflow…



I have segmented my image by Bernsen method (auto threshold) and then eroded in matlab. I was thinking if there are any commands or plugin in imagej for this purpose.
My image is one of the images from more than 1400 images of a soil column, I have segmented my images and calculated the porosity, now I need to do is:

  1. find the pores’ circularity, area, perimetere (for this I have set the scale and using analyze/analyze particles got the result but it is not true as it is shown in image “Drawing of 1.tif”) but I do not know the problem!
  2. make the 3-D of pore network and
  3. eliminate the isolated pores and the loops while differentiating the clusters based on their length and finding the tortuosity (shortest path from the surface to the bottom)

1.tif (64.8 KB)
Drawing of 1.tif (256.2 KB)


Thanks I have added some more images and details :slight_smile:

Hi Esha:
The black regions in your image are contiguous; so most of them are just one large, single particle (with many white inner holes). This is what you see in the output of “Analyze Particles” (image “Drawing of 1.tif”); that big particle is labeled with a red “1” in its center and it reaches to the edge in many places. If you want to measure the white particles, you have to invert either the image (Edit>Invert) or the Lookup table (Image>Lookup Table>Invert LUT), or you select “black background” in Process>Binary>Options.
Nevertheless, also many of the white particles are linked together; this might be real or due to insufficient resolution, where thin boundaries between the particles are not properly resolved

Thanks for your help, so it means that it is not possible to find the features of the pores in my image? (the white space between the space number 1)? and (probably) to find the area of the white space I should invert the image and by subtracting the area of black space (in inverted image) from the black space in the image, I can find the real area of the space “1”, did I get it correctly?
and how it is possible to find the radius of the pores?
Then if so, how can I find the exact area of the spaces like space number 1 in other images like this one?
141.tif (257.7 KB)

Hi Esha,
your new image is only the result of “Analyze Particles”, but with an input image different from the one above. So I don’t know what it refers to.
Anyhow, if you have a complex geometry like this, there is no well-defined radius. Imagine an arbitrary cross section of a mountain with caves in it, with long corridors and branches. In some places the cross section will cut a corridor just at the side, making it appear very narrow, in some places it will cut a corridor in the center (than the width could be considered 2 times a “radius”). Sometimes you can follow a corridor in the cross section (because it is parallel to that plane), sometimes you can’t, because the corridor is at an angle to the section plane. It is a 3D problem, and 2D cross sections give you only very limited answers (e.g. what fraction is stone and what is holes, and a rough idea about the length scales).
Since it seems you have a 3D stack, have a look at the BoneJ plugin (I have no experience with it, but it should give you some statistics that you can’t get from a 2D image).