在matlab中应用并显示均值滤波器

时间:2015-11-24 08:35:27

标签: matlab image-processing

我运行此代码但由于某种原因输出是带有黑色右边框的白色屏幕。有谁知道为什么会这样?

image=imread('lena.jpg');
image=rgb2gray(image);
[rows,cols]=size(image);
paddedimage=padarray(image,[1 1]);
newimage=zeros(rows,cols);
tot=0;
for i=2:(rows-1)

   for j=2:(cols-1)
    for i1=i-1:i+1
        for j1=j-1:j+1
            jk=image(i1,j1);
            tot=tot+jk;
        end

    end
    tot=tot/9;
    newimage(i-1,j-1)=tot;
   end
    tot=0;
end

imshow(newimage);

1 个答案:

答案 0 :(得分:2)

您需要告诉Matlab使用哪个显示范围。您可以使用imshow(newimage, []);自动选择。 内置演示图像office_1.jpg的输出:

imshow(newimage);

enter image description here

imshow(newimage, []);

enter image description here