ImageJ items recognition

Hi guys.

I need to proccess the image of those items: https://i.imgur.com/LhZ6gUT.jpg
So far, I’ve come to the point that it looks like that: https://i.imgur.com/yMY5OJK.jpg using macro below:

run("Despeckle");
run("Enhance Contrast...", "saturated=0.8");
run("Find Edges");
run("Sharpen");
run("8-bit");
setAutoThreshold("Shanbhag");
setOption("BlackBackground", false);
run("Convert to Mask");
run("Close");
run("Make Binary");
run("Fill Holes");
run("Erode");
run("Invert");

And here comes the problem - I need to leave holes of those nuts and washers, but I don’t know how to achieve this. I tried to avoid Fill Holes but it haven’t worked for me in any case.
I’d like to add that I’m new to ImageJ and I’m not aware of all options so there is a possibility that I’m missing something.

Cheers!

Hi kubuscnie,

try this version on our image:
(no guarantee that it works on others)

run("Despeckle");
run("Enhance Contrast...", "saturated=0.8");
run("Find Edges");
run("Sharpen");
run("8-bit");
setAutoThreshold("Shanbhag");
setOption("BlackBackground", false);
run("Convert to Mask");

run("Make Binary");
run("Invert");
run("Fill Holes");
run("Erode");

run("Analyze Particles...", "add");

Thanks for that, but after running this macro I’m getting full black image. (https://prnt.sc/rw6buo)

Check your settings.
Process>Binary>Options>Black background = OFF
And try again.

If that does not help:
Do the processing steps manually, step by step, and see at which stage the image becomes black. Then the image must be inverted before this step.

Well, I’ve got to this point, but my problem was that I need to leave holes of items I’ve pointed with red arrow - https://prnt.sc/rw7izq
I do know how to analyze particle, but in that case I was told that those holes can’t be filled - it’s not up to me.