Ask Your Question

Shadows on image (segmentation)

asked 2019-02-20 11:32:27 -0600

SylvainArd gravatar image

Hello everybody, I have segmented the leaflets By Otsu binarization but the shadows around the leaflets have been tagged leaflet, how do I correctly segment the leaflets please ? Thank you

image description

edit retag flag offensive close merge delete


I like to do some grabcut after getting the ROI from Otsu but actually I think to ride out of the shadow is a really difficult task.

gino0717 gravatar imagegino0717 ( 2019-02-20 19:27:32 -0600 )edit

A person on channel #opencv advised me to use saturation for grayscale transformation before Otsu binarization instead of luminosity , what do you think about this ? The kmeans seems not working because how to segment after ?

SylvainArd gravatar imageSylvainArd ( 2019-02-22 12:22:27 -0600 )edit

You can simply use a mask to segment image using labels images. with 4 labels you can extract :

mask =labels==1 connectComponnent(mask,...

LBerger gravatar imageLBerger ( 2019-02-23 03:34:46 -0600 )edit

if I tag the parts it is that I already know the parts but what I want to do is to discover them automatically

SylvainArd gravatar imageSylvainArd ( 2019-02-23 06:55:30 -0600 )edit

2 answers

Sort by ยป oldest newest most voted

answered 2019-02-21 02:04:18 -0600

LBerger gravatar image

updated 2019-02-24 02:57:46 -0600

You can use kmeans (BGR data) with 4 clusters :

image description

with false color in left image yellow color is only shadow. Yellow is only for shadow. Right image is connected components images

image description

source code

edit flag offensive delete link more


OK can you post some snippets or better a complete code program so I can see ?

SylvainArd gravatar imageSylvainArd ( 2019-02-23 14:02:02 -0600 )edit

the kmeans is done on what data : luminosity, saturation, hue ?... and look at the tooth upside there is a part of shadow which has been tagged leaflet

SylvainArd gravatar imageSylvainArd ( 2019-02-23 14:13:36 -0600 )edit

I coded kmeans with 4,5 and more clusters but it didn't work because parts of leaflet have been tagged background and parts of background (shadows) have been tagged leaflet, this is not the solution, another idea ? I think the solution is more complex like work with textures or nearest canny edges

SylvainArd gravatar imageSylvainArd ( 2019-02-27 09:14:16 -0600 )edit

answered 2019-02-23 06:49:10 -0600

SylvainArd gravatar image

the method with saturation doesn't works : leaflets parts are tagged background (which was not the case with luminosity) and some parts of background are tagged leaflet, it is worth than luminosity

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2019-02-20 11:32:27 -0600

Seen: 995 times

Last updated: Feb 24 '19