erosion only pixels with value 50 and 51 in grayscale image

7 vues (au cours des 30 derniers jours)
nm
nm le 28 Mar 2016
Modifié(e) : nm le 2 Avr 2016
I have a grayscale image with pixels values 2, 3, 4, 50 and 51. I need to erode only a pixels with value 50 and 51(it represents the clouds). The result should be picture with pixels values 2,3 and 4. Can you please help me with this.

Réponse acceptée

Image Analyst
Image Analyst le 28 Mar 2016
Try this:
windowSize = 3; % Whatever you want
erodedImage = imerode(grayImage, true(windowSize));
% Get map of where the 50 and 51 are
mask = grayImage >= 50;
% Replace only those locations with the eroded pixels.
grayImage(mask) = erodedImage(mask);
Of course, you will still have 50 and 51 in the output image if those regions are larger than your mask regions.
  3 commentaires
Image Analyst
Image Analyst le 28 Mar 2016
You did something wrong. I just tried it and it works. See my attached demo. Then attach your demo.
nm
nm le 2 Avr 2016
Modifié(e) : nm le 2 Avr 2016
Thank you very much, it was my fault, it really works :D

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by