100 likes | 217 Vues
This document provides an in-depth examination of image restoration methods utilizing Gaussian and Wiener filters. It includes MATLAB implementations for generating Gaussian functions, simulating image damage through noise, and applying inverse and Wiener filtering for restoration. The techniques are demonstrated with specific Gaussian parameters and Signal-to-Noise Ratio (SNR) adjustments. Key results are shown for cases involving motion blur and defocus blur, illustrating the efficacy of these filtering approaches in improving image quality.
E N D
ROZ2 – cvičení 2 Image restoration - výsledky
Maska gaussiánu function h = gauss(N, sigma) PI = 4*atan(1); npul = (N-1)/2; [x,y] = meshgrid(-1*npul:npul); h = 1/(2*PI*sigma^2) * exp(-1*(x.^2 + y.^2)/(2*sigma^2)); h = h / sum(h(:)); gauss(11,5) gauss(21,7)
Poškození obrázku function g = poskod(f, h, SNR) g1 = conv2(f, h); MinI = min(g1(:)); MaxI = max(g1(:)); var_f = var(f(:)); var_n = var_f / 10^(SNR / 10); g = g1 + var_n*randn(size(g1)); g(g<MinI) = MinI; g(g>MaxI) = MaxI;
Výsledky gauss(11,3) gauss(21,7) BSNR 1/0 60 50
Inverzní filtr SNR 200 150 function f = inverz(g, h) G = fft2(g); H = fft2(h, size(g,1), size(g,2)); F = G ./ H; f = ifft2(F); 120 130 140
Wienerův filtr Gauss(11,3) SNR 60 function f = wiener(g, h, konst) G = fft2(g); H = fft2(h, size(g,1), size(g,2)); R = conj(H) ./ (abs(H).^2 + konst); F = R .* G; f = ifft2(F); konst 0,1 0,01 0,001 0,0001
Rozmazání pohybem h = ones(1,10);
Rozmazání pohybem m1 = log(abs(fft2(f).^2)); m2 = real(fft2(m1)); mi = min(m2(:)); m3 = m2 < 0.9*mi; m3 m1 fftshift+výřez
Rozmazání defokusací h =kruh(20,10);
Rozmazání defokusací m1 = log(abs(fft2(f).^2)); m2 = real(fft2(m1)); mi = min(m2(:)); m3 = m2 < 0.9*mi; fftshift(m3) fftshift(m1)