利用matlab给图像进行中值滤波...
发布网友
发布时间:2022-10-08 09:53
我来回答
共1个回答
热心网友
时间:2023-11-09 00:13
x=imread('2_5.tif');
y=uint8(x);
u1 = imnoise(y,'salt & pepper', 0.02);figure,imshow(uint8(u1));
[h w]=size(x);
for i=2:h-1
for j=2:w-1
y1=u1(i-1:i+1,j-1:j+1);%取3x3窗口
y1=reshape(y1,1,9);
for m=1:9
for n=m+1:9
if y1(n)>y1(m)
t=y1(n);y1(n)=y1(m);y1(m)=t;
end
end
end
u1(i,j)=y1(5);
end
end
figure,imshow(uint8(u1));