MATLAB - How to eliminate a shaded background in an image

I am trying to process an image. There is a photograph of the RGB leaves, and I want to extract only the sheet.

The following procedure is

  • I read an image from a file
  • Convert to Grayscale
  • Apply a 5x5 median filter.
  • Convert to BW

enter image description here

enter image description here

As you can see, the shadow in the lower right corner is attached to the BW image. Is there a way to select only a sheet.

I = imread(files{404}); hcsc = vision.ColorSpaceConverter; hcsc.Conversion = 'RGB to intensity'; Ig = step(hcsc, I); medFilt= vision.MedianFilter([ff]); Ig = step(medFilt, Ig); at = vision.Autothresholder; Ibw = step(at, Ig); 
+5
source share
1 answer

Instead of converting to a grayscale image, I convert it to HSV and take it V. Now the result is better.

 I = imread(files{404}); I = rgb2hsv(I); Ig = I(:,:,3); medFilt= vision.MedianFilter([ff]); Ig = step(medFilt, Ig); at = vision.Autothresholder; Ibw = step(at, Ig); 

enter image description here

+1
source

All Articles