Size filter by 3D Object Count and BoneJ-Particle Analyze

Dear imagej-user,

Sorry, I often ask questions in this forum recently. Because I’ve been studying image processing attentively for the past half month, I have another problem now… :sweat_smile:

I want to give my segmentation result clean up. The small isolated cluster of void and grain voxels may strongly distort the skeletonization process. So I need to do a size filter for my segmentation images. In this regard, I think of 3D Object Count or BoneJ-Particle Analyze can achieve this.

I would like to remove small isolated cluster grain voxels first. In 3D Object Count, I set the size filter is 10-2400000. But the result shows:

0 objects detected (Size filter set to 10-2400000 voxels, threshold set to 128).

I doubt it, because at least can be filter a few in Bonej-Particle Analyze.
And even if I set the size filter to 30-2400000 voxels, it also doesn’t work.
1. Why is that? Why can’t use 3D Object Count to do size filter?

Then I used BoneJ-Particle Analyze to make a size filter(10-2400000 pixel^3).

By comparison, at least it has come to an end, but it doesn’t feel perfect. Because I think it makes size filter only in the first slice.

2. So I want to ask you to confirm that the size filter in Bonej-Particle Analyze works for the whole stack? Or just one slice?

3. The size filter unit in Bonej-Particle Analyze is pixel^3. What is the unit in 3D Object Count? Because there is no specific description. If it’s also pixel^3, why it show not found in 3D Object Count?

This is my image package, upload it to you for reference.
all-otsu-roi.rar (22.7 KB)

My statement may not be clear. If you have any questions, don’t hesitate to ask me!

Thank you once again for your time and help.


I think that there is a pb with the background, I guess you want to detect black objects. Segmentation algorithms will take 0 as the background, check your objects have values > 0 . In your case just Invert your image, here the result with 3D Simple Segmentation.



Try Purify in BoneJ

Hi @ThomasBoudier
Thanks for your reply! :grinning:
Yes, later I’m going to remove small isolated black objects, too. But I also want to remove those little white objects that small than a specific size in black objects. For to remove white objects first, so I didn’t use the inverted image.
I don’t know why to treat white objects as target is unsuccessful.

Looking forward to your points.

Thank you for your advice.
I tried Purify in BoneJ. But I found it didn’t seem to be what I want because it couldn’t set the exact size…It filters a lot of what I want to save.

In BoneJ’s Particle Analyser you can set the exact particle size for particles to be shown in the map.

After the particle label image is produced you have to threshold to make a mask for particles vs. background, then invert and run again to filter out small particles in the background.

Hello @mdoube ,

I tried BonJ’s Particle Analyser. The “the particle label image” is the image named like “XXX_parts”?

This step, SORRY, I don’t how to do. I don’t quite understand this meaning. Please help me this step:-)

There’s another doubt. I found BonJ’s Particle Analyser seems to be work just in the first slice,like this

But in the next few slices, size filter doesn’t play a role, even a very small grain, for example(There are also very small grains in this slice, but I don’t think they have been filtered)

Sorry, I have a lot of questions. I’m sorry to bother you :hugs:
Thanks again!


Image>Adjust>Threshold and make sure the threshold is including every pixel > 0, then Apply.

The ‘small grains’ must be attached in 3D, which makes them part of the larger particle, even if it doesn’t look like it in 2D.

Dear @mdoube
The purpose of this step is to change the image after labeling from 32-bit to 8-bit binary image, and then carry out the following analysis, right?
If so, this is what I want. Maybe I didn’t know how to express it before.
I met two problems again ><.

1.After a size filter is applied to the original image “A”, we get the labeling image “B”. the color points(just two small particles that colored red and yellow, and a connecting large one colored green) in B are recognized to be the particles that larger than 10 pixels ^ 3. But why can’t I find the corresponding yellow and red dots in the VOLUME image “C”? Curious…




2.Follow your advice, I go the Image>Adjust>Threshold.
But the selection of that threshold is a little strange. It is not in the range of 0-255, because after all, this is not an 8-bit image, but a labeling image.

For this reason, I think the Min threshold should be in the range of (0,1],and I set the max threshold to the maximum. I think this way I can turn the image after the label into a binary image as much as possible without losing any objects.

But why does the slice of colored particles become binary will like this(image"E")? I can’t see other details except for two particles…But when I adjust the threshold bar , the window displays image"D", then click “Apply”, later the outcome becomes the image “E”…



Thanks very much!

It looks like you might have have thresholded the volume image to exclude the small particles.

The other way to filter out small particles is to show the volume image, then use Image > Adjust > Threshold to select only particles of a size that you want to keep.

Could you please record a macro and paste it here, so that we can see all the steps you are doing?

Please also change the settings in your Threshold window to highlight in red (you have it showing B&W). I wonder if the LUT of the image (B&W) is getting confused with the threshold overlay (also B&W).

Hey @mdoube

I tried this advice, and it works! The volume image can be binaries successfully.

Yes, I need to filter small size particles, and the size filter I set is more than 10 pixel^3. While the volume of red and yellow dots in “parts” image is more than 10 small particles. I think these two particles should be shown in volume image. But why the result not?

I also try to adjust the labeling image’s threshold and set the background highlight in red, but the result is also like the before image “E”.
This is my macro about this:

run(“Particle Analyser”, “surface_area enclosed_volume moments euler thickness mask ellipsoids min=10.000 max=Infinity surface_resampling=2 show_particle show_size show_centroids show_ellipsoids show_stack surface=Gradient split=0.000 volume_resampling=2”);
call(“”, “all-otsu-roi”);
call(“ij3d.ImageJ3DViewer.setCoordinateSystem”, “false”);
call(“”, “all-otsu-roi”);
call(“”, “all-otsu-roi”);
call(“”, “all-otsu-roi”);
setOption(“BlackBackground”, false);
run(“Convert to Mask”, “method=Default background=Light calculate”);

By the way, If I want to get rid of all the white objects in black, no matter how big or small, is there any way to achieve it quickly?

Thank you very much for every reply and answer! :smiling_face_with_three_hearts:

Both get their unit from the image’s calibration. Seeing pixel^3 is a sign that your image has no calibration. I think that’s also the reason 3D Object Count shows a warning.

Best regards,

hello @rimadoma,
Thank you for helping me solve my doubts about the unit!
Follow your reply, I adjust the image calibration, but the 3D Object Count shows a warning still, while the same size filter has results on BoneJ/Analyze Particles. So this should not be a calibration issue I think.

Be grateful for your attention :stuck_out_tongue_winking_eye:.

Best Regards.