Removal Greenish Shadows from Background

asked 2017-12-05 06:12:08 -0600

Tarcisioflima gravatar image

I have an image of a leaf on a poorly white screen and need to find out just the leaf.

Leaf Example

The problem is that it contains greenish shadows, so simple color-based methods are not enough. Thus, I need some preprocessing to achieve an uniform background and to enhance important features. The goal is to delete undesired noise and distortions to apply an Expectation Maximization algorithm to segment the image.

HSV Domain

I already have find out that when segmenting with color it is imperative to use the right color domains that exclude undesired noise. So I used Saturation and Value color components for leaf segmentation. This was useful for posterior segmentation using Expectation-Maximization (EM). I used OpenCV to convert the original images into the HSV domain. Then, using cv2.split, I extracted the Saturation and Value components, which were fed to the EM algorithm. As you can see below:

image = cv2.cvtColor( image, cv2.COLOR_BGR2HSV )
if image.dtype != 'float64':
    image = image.astype( 'float64' )
else:
    image = np.copy( image )

_, s, v = cv2.split( image )

# Stack the S and V values together 
samples = np.hstack( zip( s, v )).transpose()

em = cv2.ml.EM_create()
em.setClustersNumber( 2 )
em.setCovarianceMatrixType( cv2.ml.EM_COV_MAT_DIAGONAL )
em.trainEM( samples )

return em

Once images were converted to HSV and the desired channels were extracted, I applied EM to the color domain in order to cluster the pixels into one of 2 possible groups: leaf and non-leaf groups. However, due to that greenish the EM is returning a wrong result.

Example Result

I found out in one paper that: "Once images are acquired, the next phase consist of preprocessing the image to enhance important features. This step includes gray scale conversion, noise reduction and other color domain conversions. The goal is to delete undesired noise and distortions that may affect the following phases." However, I'm not understand what I need to do.

Could someone help me?

edit retag flag offensive close merge delete

Comments

have you tried simple edge detection ? I think that some blurring (GaussianBlur), threshold and findContours should be enough

procton gravatar imageprocton ( 2017-12-05 15:05:05 -0600 )edit

Where are the greenisch components on your white background? Are you hallucinating? :D

StevenPuttemans gravatar imageStevenPuttemans ( 2017-12-08 04:38:11 -0600 )edit

Expectation Maximization is founding it on the background!

Tarcisioflima gravatar imageTarcisioflima ( 2018-03-15 21:52:30 -0600 )edit