필터 지우기
필터 지우기

How do you apply a 3x3 median filter on an image that is noisy (salt and pepper) , and what is it supposed to do?

조회 수: 15 (최근 30일)
is this correct?
inpict = imread('Q1_noisy_image (1).tif');
A = medfilt2(inpict,[3 3]);
imshow(A)

답변 (2개)

Image Analyst
Image Analyst 2023년 12월 2일
If inpict is a gray scale image, that would apply a median filter to ALL pixels in the image, not just the impulse/salt&pepper noise.
A median filter's claim to fame is that it smooths noisy areas but leaves true edges sharp (it doesn't blur step edges).
If you want a median filter to operate on only salt and pepper noise, you have to
  1. First median filter the whole image
  2. Get a mask of the salt and papper noise, where values are either 0 or 255 or whatever values you want to use.
  3. Replace the original image with the median filtered values but ONLY within the noise mask, not everywhere.
Something like
filteredImage = medfilt2(grayImage, [3,3]);
mask = (grayImage == 0) | (grayImage == 255);
grayImage(mask) = filteredImage(mask);
For a full demo, see my attached demos. For a color image, do it one color channel at a time.

DGM
DGM 2023년 12월 2일
편집: DGM 2023년 12월 2일
  댓글 수: 2
Hind Aljallaf
Hind Aljallaf 2023년 12월 2일
I thought i asked the question wrong, and i want to see what other codes are there to experiment with.
DGM
DGM 2023년 12월 2일
편집: DGM 2023년 12월 2일
In the future, try to keep things about one question in a common thread so that efforts don't get divided. It's okay to revise your question either by editing it or by using comments.
FWIW, the link I'd provided in 2054999 includes a link to the demos that Image Analyst also posted above.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by