function imOut = medianFilter(imIn,windowWidth)
if mod(windowWidth, 2 ) == 0
disp('Window has even size');
return
end
imageSize = size(imIn);
imOut = imIn;
windowBreadth = (windowWidth - 1)/2;
for m=windowBreadth+1:imageSize(1) - windowBreadth
for n=windowBreadth+1:imageSize(2) - windowBreadth
t1 = imIn(m-windowBreadth:m+windowBreadth,n-windowBreadth:n+windowBreadth);
t2 = reshape(t1,windowWidth*windowWidth,1);
t3 = median(t2);
imOut(m,n) = t3;
end
end
我的解释:
函数 medianFilter 将图像(imIn)作为输入,以及中值滤波器窗口的宽度
那么我不确定为什么我们需要 if 语句
之后,我们获取输入图像的大小并将其保存在一个名为 imageSize 的变量中
然后我们将 imIn 的所有值复制到 imOut
然后我迷路了
什么是窗宽?宽度和宽度不是一回事吗?
谢谢!