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

2 次查看(过去 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()

类别

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