필터 지우기
필터 지우기

Average of pixel difference from center pixel

조회 수: 6 (최근 30일)
Nataliya
Nataliya 2015년 9월 13일
답변: Image Analyst 2015년 9월 13일
I want to replace the value of center pixel by the average value of the pixel difference of its 3x3 neighboring pixels. How to do it? Please guide me. Thanks

답변 (2개)

Image Analyst
Image Analyst 2015년 9월 13일
Walter's right - your definition of "difference" is not precise enough. Please clarify. If you mean the color difference, delta E, then you can run the attached demo that computes the local color difference, in a moving window, between a pixel and its neighbors in a window around it.

Walter Roberson
Walter Roberson 2015년 9월 13일
conv2(YourImage, [1 1 1;1 -8 1; 1 1 1]/8, 'same')
This might not be valid on the outside border, but you did not define the behavior for the outside border.
  댓글 수: 2
Nataliya
Nataliya 2015년 9월 13일
Thanks for the response. I am working with rgb images and conv2 function does not work for 3-D images. Please suggest what can I do in this case. Thanks
Walter Roberson
Walter Roberson 2015년 9월 13일
You are going to need to write out the formula. Take the case of a 3 x 3 image that is RGB, so 3 x 3 x 3. Write out the formula you would use to calculate the average for the pixel at the center, location (2,2,:).
I need you to write out the formula because there are a lot of different possible meanings to "pixel difference" and "average" for RGB. Is the difference to be taken in Hue? In Saturation? In grayscale intensity? In a* coordinates in La*b* colorspace? In Z coordinates in XYZ colorspace? Should the RGB values be taken as representing 3 dimensional coordinates and the "pixel difference" be interpreted as the cos of the vector angle for the rays between (0,0,0) and the two different RGB triples?

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

Community Treasure Hunt

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

Start Hunting!

Translated by