?? kuan.m
字號:
%Kuan filter for speckle noise reduction
%Usage - kuan(I)
%I is the noisy image (gray level image m x n x 1)
function [kn]=kuan(I)
[x y z]=size(I)
I=double(I);
for i=1:x
i
for j=1:y
% Checking first and last pixel of first row%
if (i==1 & j==1)
mat(1)=0;
mat(2)=0;
mat(3)=0;
mat(4)=0;
mat(5)=I(i,j);
mat(6)=I(i,j+1);
mat(7)=0;
mat(8)=I(i+1,j);
mat(9)=I(i+1,j+1);
end
if (i==1 & j==y)
mat(1)=0;
mat(2)=0;
mat(3)=0;
mat(4)=I(i,j-1);
mat(5)=I(i,j);
mat(6)=0;
mat(7)=I(i+1,j-1);
mat(8)=I(i+1,j);
mat(9)=0;
end
% Checking first and last pixel of last row%
if (i==x & j==1)
mat(1)=0;
mat(2)=I(i-1,j);
mat(3)=I(i-1,j+1);
mat(4)=0;
mat(5)=I(i,j);
mat(6)=I(i,j+1);
mat(7)=0;
mat(8)=0;
mat(9)=0;
end
if (i==x & j==y)
mat(1)=I(i-1,j-1);
mat(2)=I(i-1,j);
mat(3)=0;
mat(4)=I(i,j-1);
mat(5)=I(i,j);
mat(6)=0;
mat(7)=0;
mat(8)=0;
mat(9)=0;
end
% Checking rest of the image%
if (i>1 & i<x & j>1 & j<y)
mat(1)=I(i-1,j-1);
mat(2)=I(i-1,j);
mat(3)=I(i-1,j+1);
mat(4)=I(i,j-1);
mat(5)=I(i,j);
mat(6)=I(i,j+1);
mat(7)=I(i+1,j-1);
mat(8)=I(i+1,j);
mat(9)=I(i+1,j+1);
end
y1=I(i,j);
ybar=mean(mean(mat));
ystad=std2(mat);
ENL=(ybar/ystad)^2;
sx2=((ENL*(ystad)^2)-(ybar)^2)/(ENL+1);
xcap=ybar+(sx2*(y1-ybar))/(sx2+((ybar^2+sx2)/ENL));
N(i,j)=xcap;
end
end
kn=uint8(N);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -