필터 지우기
필터 지우기

how to replace the center pixel of a 3X3 window with the min difference among its surronding pixels in matlab?

조회 수: 1 (최근 30일)
I want to replace the center pixel of a 3x3 window filter with the minimum difference among its surrounding pixels. I want to run this process for all pixels of the image.
Then I want to calculate the mean square of the minimum differences of all pixels in the entire image.
Would you please give me some suggestion or code snippet to solve my problem. I am new in matlab.
Please response..
  댓글 수: 2
Walter Roberson
Walter Roberson 2013년 8월 25일
If two pixels have the same value, then would the minimum difference be 0? Or should the minimum difference be only amongst the unique values (unless all the values are the same)?
Are you wanting the minimum difference comparing the center pixel with the others, or the minimum difference between all pixels in the window compared to all other pixels in the window?
shimul
shimul 2013년 8월 25일
편집: shimul 2013년 8월 25일
Thanks for your response Walter Roberson. Actually I want to replace the center pixel with the minimum difference between its surrounding pixels. That is if the center pixel is (x,y). Then I want to find the min difference of its 8 neighbors taking two neighbors at a time. Here (x,y+1)-(x,y+2) is one such difference. But I don't want to take the difference between a neighbor and the center

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

채택된 답변

Image Analyst
Image Analyst 2013년 8월 25일
I think you're going to have to do it manually by using conv2() 8 times with a [-1 1] kernel that rotates around the 8 neighbors, and then take the min of the 8 images. Then square, sum, and sqrt.
image1 = conv2(grayImage, [-1, 0, 0; 0, 1, 0; 0, 0, 0], 'same');
image2 = conv2(grayImage, [0, -1, 0; 0, 1, 0; 0, 0, 0], 'same');
image3 = conv2(grayImage, [0, 0, -1; 0, 1, 0; 0, 0, 0], 'same');
image4 = conv2(grayImage, [0, 0, 0; -1, 1, 0; 0, 0, 0], 'same');
image5 = conv2(grayImage, [0, 0, 0; 0, 1, -1; 0, 0, 0], 'same');
image6 = conv2(grayImage, [0, 0, 0; 0, 1, 0; -1, 0, 0], 'same');
image7 = conv2(grayImage, [0, 0, 0; 0, 1, 0; 0, -1, 0], 'same');
image8 = conv2(grayImage, [0, 0, 0; 0, 1, 0; 0, 0, -1], 'same');
allImages = cat(3, image1, image2, image3, image4, image5, ...
image6, image7, image8);
minDiffImage = min(allImages, [], 3);
minDiffImage = minDiffImage .^2; % Square it.
mse = mean(minDiffImage (:));
Try that untested code and see how it works.
  댓글 수: 5
shimul
shimul 2013년 8월 25일
I want to highlight the noise pixels. I have executed it for the three (R G B) different channels and I am getting a very high value, possibly my image containing a lot of noise.
Actually I am trying to implement a journal named "Reference less image evaluation for whole slide imaging" .
How can I have the implementation or the training samples, input images and corresponding results of the paper.

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2013년 8월 25일
You could do it easily with blockproc()

Community Treasure Hunt

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

Start Hunting!

Translated by