remove salt and pepper from an image then convert to binary

4 views (last 30 days)
How can I convert the first image to the second image? I used the code below but it didn't help, and I didn't convert it to binary because it makes it look worse due to the salt and pepper. Also, using medfilt2 making my image blurry.
RGB = imread('center.png');
imshow(RGB);
I=im2gray(RGB);
k=medfilt2(I,[22,22]);
imshow(k)

Answers (1)

Image Analyst
Image Analyst on 17 Sep 2022
See my attached demos. You might be able to adapt them.
But you don't have what is called classical salt and pepper noise. I suggest you call adapthisteq then threshold to get blobs brighter and darker than the mean gray level. You also need to fix your horrible lighting situation. Try to avoid the reflection of the overhead light. If you can't arrange the geometry, then use polarizers.

Community Treasure Hunt

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

Start Hunting!

Translated by