help Adaptive median filter !!

3 ビュー (過去 30 日間)
aliah aljohani
aliah aljohani 2017 年 10 月 13 日
回答済み: DGM 2023 年 9 月 29 日
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

回答 (1 件)

DGM
DGM 2023 年 9 月 29 日
This answer discusses and provides a link to an implementation of a similar adaptive median filter:

カテゴリ

Help Center および File ExchangeAdaptive Filters についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by