如何回答这个Matlab图像处理作业?

时间:2018-05-09 06:33:06

标签: matlab

我被困在这里,我多次尝试但无法得到我的最终答案。

Image

代码:

I = imread('C:\Users\Ahsan\Desktop\pears.png');
H = fspecial('average', [3 3]);
J = imfilter(I, H);
figure, imshow(I);
figure, imshow(J);

1 个答案:

答案 0 :(得分:1)

试试这个: (也许你必须改变门槛);

threshold = 126;

image = imread('C:\Users\Ahsan\Desktop\pears.png');

%   Apply the filder
filterImage = conv2(image, ones(3)/9, 'same');

%   Check which pixels are equal or greater than the threshold
masked = filterImage >= threshold;

%   Replace all pixels of the filteredImage which are below the threshold
%   with the original pixels.
filterImage(~masked) = image(~masked);

%   Display result
figure(1);

subplot(1,2,1);
imshow(image, []);

subplot(1,2,2);
imshow(filterImage, []);