Average of pixel difference from center pixel
조회 수: 2 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (2개)
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.
댓글 수: 0
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
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!