Hole diameter Analysis


  • I’m fairly new to image processing and quantitative analysis so I’m hoping to get some assistance here. I’m trying to use Fiji to get hole diameter measurements for most of the holes in the image; it doesn’t have to be all the holes however. The ultimate goal is to create a macro for this image that will process it to give it the best chance of accurately discerning where the edge of the hole (black) is and when it stops (greyish/whiteish) rim. The challenge is that I don’t know the right sequence of steps in image processing before the Analyze Particles step. There’s lighter areas towards the edge of the image that I’m guessing would need to be corrected as well as the exclusion of the holes on the edges that are not complete holes.

Would this

be good enough.

In any case, you should try to improve the image acquisition process, i.e. lighting and perhaps even camera and optics.
What camera do you use?

Furthermore, JPG-compression is a no-no because it introduces artifacts that can’t be removed. If you encounter problems with posting better images, please consider cloud services or post parts of your images.

Thank you! I guess there is room for to improve the acquisition process. I think what you have is good. Would you mind sharing what you did to process the image? This is the step I get hung up on. I’ve looked at adjusting the following but I never know the right sequence is and what’s really worth doing.

find edges
enhance contrast

What camera do you use?

Most steps you’ve posted appear not really necessary.
You shall see a short macro that does most of the processing.
Please tell us what you mean by diameter, because the holes aren’t circular.

Here is a possible ImageJ-macro:

run("Find Edges");
run("Convert to Mask");
run("Analyze Particles...", "size=2000-Infinity circularity=0.50-1.00 show=Outlines");

(Paste the macro code to a macro window (Plugins >> New >> Macro).)

You need to modify the last command (Analyze Particles…) according to your needs, i.e. most probable you will need the “Display results”-option with the right measurement setting (fit ellipse, feret’s diameter, etc).

I use a Nikon Z7 with a Nikkor 105mm lens.
The diameters of interest are the vertical and horizontal.

The equipment sounds good.

If you can use a more homogeneous and diffuse lighting this would help. Best is a ringlight around the optics.

“Fit ellipse” and “Feret’s diameter” don’t give you these values but “Bounding rectangle” does.

Thank you I’ll try your suggestions and the macro.

Would you have a way to contact you directly to go over some of this?

It is good practice to continue the discussion etc. on the Forum.
Others may profit from it, except any details are classified or the like.

Feel free to ask …

I just can’t replicate your results with the macro.

I’ve just again downloaded your sample image and run the macro on it. It results in the following outlines:

Make sure that in
“Process >> Binary >> Options”
“Black background” is checked.

Yup it was already checked. When I run the macro it outputs just a completely blank Drawing of the image.

Try to replace this line


setAutoThreshold("Intermodes dark");

the Drawing is still blank and now the image itself turned completely dark with random white specs all over

Final attempt:

run("Find Edges");
setOption("BlackBackground", true);
run("Convert to Mask");
run("Analyze Particles...", "size=2000-Infinity circularity=0.50-1.00 show=Outlines");

Make sure that no scale is set to your image.
You can check this in the image’s subtitle on the left top.
For me it reads:
8189x4208 pixels; RGB; 131MB

That was the issue, it did have a scale. Why would having a scale cause that? It can’t display the correct Feret units now.

Please inspect the “Analyze Particles…”-dialog.
If you have an image with a set scale, you need to check “Pixel units” or change the “Size”-entry (here 2000), otherwise the “Size”-filter will filter incorrectly.

For the macro you may use the following last command:

run("Analyze Particles...", "size=2000-Infinity pixel circularity=0.50-1.00 show=Outlines");

Thank you! seems to be working now. Definitely a powerful tool, I appreciate all your help.