wiener1.m

来自「gaussian filter that is being and can be」· M 代码 · 共 44 行

M
44
字号
function resim = Wiener(ifbl, LEN, THETA, SNR)


%Preprocessing
%Performing Median Filter before restoring the blurred image
ifbl = medfilt2(abs(ifbl));


%Converting to frequency domain
fbl = fft2(ifbl);


%Create PSF of degradation
PSF = fspecial('motion',LEN,THETA);


%Convert psf to otf of desired size
%OTF is Optical Transfer Function
%fbl is blurred image in frequency domain
OTF = psf2otf(PSF,size(fbl));

%Conjugate for modulus aquisition
OTFC = conj(OTF);
modOTF = OTF.*OTFC;


%To avoid divide by zero error
for i = 1:size(OTF, 1)
    for j = 1:size(OTF, 2)
        if OTF(i, j) == 0
            OTF(i, j) = 0.000001;
        end
    end
end


%Deblurring image using WEINER FILTER formula
debl = ((modOTF./(modOTF+SNR))./(OTF)).*fbl;
lbed = ifft2(debl);


%Restored image
resim = lbed;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?