필터 지우기
필터 지우기

How to apply Median FIlter To a color image with out using 'rgb2gray' ? Program please.

조회 수: 2 (최근 30일)
How to add noise and eliminate it using filters (in this case salt and pepper and Median filters respectively) by using without the conversion to gray scale.?

채택된 답변

Guillaume
Guillaume 2017년 9월 23일
Just loop over the colour channels:
processedimage = zeros(size(yourimage), 'like', yourimage));
for channel = 1:3
processedimage(:, :, channel) = somefunction(yourimage(:, :, channel));
end

추가 답변 (1개)

Image Analyst
Image Analyst 2017년 9월 23일
See my attached demos for applying salt and pepper noise to color and gray scale images and then removing it. It should do exactly what you want in a fancy demo. Adapt it as needed.
  댓글 수: 3
Image Analyst
Image Analyst 2020년 4월 25일
Well I guess you could - if you were willing to accept more of a color change. The different color channels can have drastically different values. Imagine you were looking at a tomato with values of (200, 40, 20) with salt and pepper noise. Consider if the 3-D 3x3x3 filter window was processing the green channel so it also brings in values of the red and blue channels into the moving window. So if we ignore values of 0 and 255 and take the median value of what's left, you might be left with a value of 200 for the green instead of 40, depending on how much noise was in each channel. Or it might get a value of 20 if the blue channel was the channel with the least noise. So you're assigning colors from a different color channel to it, which would dramatically change the color if the color is not a neutral shade. Doing it one color channel at a time would avoid that. I suppose the red and blue channels might be ok with the 3-D median IF the window shrunk as it got to the edge of the array, meaning you basically ignore values that are off the edge of the image. (I'm not sure how the median filter deals with edge effects - the common ways are to shrink the window or assume values outside the array are zero). But in that case (shrinking window), it's reverted to a 2-D filter window on one color channel alone. So, bottom line, I think doing it channel-by-channel will give more accurate colors.
RMT
RMT 2020년 4월 25일
Thanks a lot for your response.
Best regards.

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

Community Treasure Hunt

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

Start Hunting!

Translated by