Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Removal Greenish Shadows from Background

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?