MorphoLibJ erosion and dilation issue

When I tried to erode an image using MorphoLibJ.

run(“Morphological Filters”, “operation=Erosion element=Disk radius=5”);
close();

I get this result

Why is that. I mean in erosion it need to remove parts from the object according to the structuring element. according to this

Dear,

your image is shown with an inverted LUT but the operation acts on the image data which is just the inverse of the displayed image…

HTH

Herbie

PS: So you are still struggling with the old problem?

2 Likes

Hello @anon96376101 thank you very much. Since I am not much familiar with this macro programming now i am playing with those commands and getting familiar. Then I will consider the above matter. I didnt try that because of lack of scripting knowledge.

Best regards.

Dear @anon96376101,

I changed the inverted LUT but same issue is there. If you have time help me to solve this issue.

This is my sample macro.

run(“Duplicate…”);
setThreshold(0, 18);
run(“Convert to Mask”);
run(“Gray Scale Attribute Filtering”, “operation=Closing attribute=Area minimum=25000 connectivity=4”);
run(“Morphological Filters”, “operation=Dilation element=Disk radius=5”);

Here I have use attribute morphological operator to remove objects smaller than 25000 px. But same issue is there. theory says (MorpholibJ documentation),

" Attribute filtering
Attribute filters aim at removing components of an image based on a certain size criterion, rather than on intensity. The most common and useful criterion is the number of pixels/voxels (i.e., the area or volume). For example, a morphological size opening operation with a threshold value of 20 will remove all blobs containing fewer than 20 voxels. The length of the diagonal of the bounding box can also be of interest to discriminate elongated versus round component shapes."

But opening attribute does not work like that. But closing attribute gives the result.

Dear,

changing the LUT won’t help! I thought that I made this clear. LUTs are for display only but the pixel values don’t change. What you must do is invert the image.:

Edit >> Invert

To get what you want by

[…] playing with those commands and getting familiar.

will take longer than studying the ImageJ-manual and the Macro-introductions:
https://imagej.nih.gov/ij/docs/guide/index.html
https://imagej.nih.gov/ij/developer/macro/macros.html
https://imagej.nih.gov/ij/developer/macro/functions.html

Regards

Herbie

@Denuwan

Would you be able to post again your original image? That way - I can try running your macro code (the code below - yes?) on my system to see if I can replicate the issue. And the issue is just that you get the opposite result for erosion call - yes? Instead it seems to dilate?

run("Duplicate...");
setThreshold(0, 18);
run("Convert to Mask");
run("Gray Scale Attribute Filtering", "operation=Closing attribute=Area minimum=25000 connectivity=4");
run("Morphological Filters", "operation=Dilation element=Disk radius=5");

Also - have you tried just using another ‘dumby’ image - such as in Open Samples > Blobs (25K) - just create a quick threshold/mask and test the erosion/dilation filters in MorphoLibJ on those. For me - it worked fine.

eta :slight_smile:

Good day Ellen,

I’m quite sure I solved this really minor problem by just telling the original poster explicitely that

LUTs are for display only but the pixel values don’t change. What you must do is invert the image.:

Edit >> Invert

Regards

Herbie

@etadobson
The problem is not only erosion, it is for dilation and also for this step
run(“Gray Scale Attribute Filtering”, “operation=Closing attribute=Area minimum=25000 connectivity=4”);
According to the theory “attribute morphological operator opening” should remove objects less than a certain value. but to get the expected result i had to use attribute morphological closing operator.

Here are some of my my test images
https://drive.google.com/open?id=0B-7j83JaONx3VUpsUjhkZ1FaRzg

Thank you very much Herbie, The problem solved when I invert the image.

Thank you very much Herbie