Remove shadows near teeth of a leaf

I want to remove the little shadows near the teeth of this leaf (for segmenting good the leaf contours):

I tried adaptive thresholding, thresholding over saturation, Chan Vese, active contours, kmeans but none of them has worked
Thank you very much if you have a track.
Bye

Hello Sylvain_255,
The only problem with this image is the ‘Range of intensity’ of the image which cannot be adjusted easily with out going to the opposite of the problem. but,
Wand Tool_28thresh>Edit-Copy>File-New_image,(scale and choose background as white or black)
Edit>Paste
If the stem itself needs to be included in the data, then just use the wand tool again on it, Analyze>measure and use that data in your analysis.



Hope this helps,
Bob

1 Like

The result seems perfect, how you do “Wand Tool_28thresh” ?

I tested but there are pixels of leaf which are deleted and pixels of shadow wich remains another idea ?

and I would to automate programmatically the operation over a lot of leaves and if I take for example the center of the leaf for the wand tool the result is bad, it depends a lot of the pixel where we put the wand tool

Hello again,
Since it is needed that tight then it will have to be done on each color channel separately since the channels themselves overlap.(Image>Colors>Split Channels) and I see you must have found out how to change the settings for the Wand. Many times you have to adjust the settings up/down one pixel at a time until you are satisfied with the results. Once you know the settings you would like then Plugins>Macros>Record… it will then follow your every step and record it as a macro, save it . Then you should have what you need, even on future projects.

Good luck,

Bob

Convert your image to HSB, then use the Saturation channel to segment the image with one of the auto threshold methods. Since the background is white, it has little saturation. This might still generate some background pixels, that you can get rid of by doing Invert, Fill Holes, Invert.
Finally add the result to the original, so the purely white background is added to the colour image background and nothing to the object.
This is not a bullet proof method, as you have shown only one image and the shadows might depend on a number of unknown factors.
Also, do not use jpegs!

setBatchMode(true);
a=getTitle();
run("Duplicate...", " ");
run("HSB Stack");
setSlice(2);
setAutoThreshold("IJ_IsoData");
setOption("BlackBackground", true);
run("Convert to Mask", "method=IJ_IsoData background=Light calculate black");
run("Invert", "slice");
run("Fill Holes", "slice");
run("Invert", "slice");
run("Duplicate...", "title=background");
imageCalculator("Add create", a,"background");
setBatchMode(false);

Result%20of%20im2

2 Likes

In fact I want to program it in C++/OpenCV what threshold do you do over saturation, Otsu ?

Please read the script a bit more thoroughly.

1 Like