This answer discusses and provides a link to an implementation of a similar adaptive median filter:
help Adaptive median filter !!
3 次查看(过去 30 天)
显示 更早的评论
a=imread('hh1.tif');
figure(1),imshow(a),title('origanal image');
b=imnoise(a,'salt & pepper',.02);
figure(2),imshow(b),title('noisy image');
Smax=9;
for i=1:254
for j=1:254
n=b(i:i+2,j:j+2)
Zmin=min(n(:));
Zmax=max(n(:));
Zmed=median(n(:));
sx=3;
sy=3;
A1=Zmed-Zmin;
A2=Zmed-Zmax;
if (A1>0) && (A2<0)
B1 = Zxy-Zmin;
B2 = Zxy-Zmax;
if (B1>0) && (B2<0)
b(i:i+2,j:j+2) = n(i, j);
break;
else
b(i:i+2,j:j+2) = Zmed;
break;
end
else
sx=sx+2;
sy=sy+2;
if (sx > Smax) && (sy > Smax)
b(i:i+2,j:j+2) = n(i, j);
end
end
end
end
figure(3),imshow(b),title('denoised image');
i have problem withe for and if
i have error
0 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Adaptive Filters 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!