Complete MATLAB program. Need to complete the Wiener filter, suppose we know the power spectra of the noise S_n and the un-degraded image S_f. The data type of the output image should be uint8. Do not use the internal MATLAB function ‘wiener2’ for implementation.
Y=Wiener_filter_1(X,H,Sn,Sf) filters a noisy image X with Wiener filter. H defines the degradation function, Sn defines the power spectrum of the noise image and Sf defines the power spectrum of the undergraded image.
Code:
Function Im=wiener_filter_1(NoisyIm, H, Sn, Sf)
%check if the noisy image is grayscale and of uint8 datatype
assert_grayscale_image(NoisyIm);
assert_uint8_image(NoisyIm);
Im=?
%convert the image to uint8 datatype
Im=uint8(Im);
I = im2double(imread('cameraman.tif'));
imshow(I);
title('Original Image (courtesy of MIT)');
LEN = 21;
THETA = 11;
PSF = fspecial('motion', LEN, THETA);
blurred = imfilter(I, PSF, 'conv', 'circular');
figure, imshow(blurred)
noise_mean = 0;
noise_var = 0.0001;
blurred_noisy = imnoise(blurred, 'gaussian', ...
noise_mean, noise_var);
figure, imshow(blurred_noisy)
title('Simulate Blur and Noise')
estimated_nsr = 0;
wnr2 = deconvwnr(blurred_noisy, PSF, estimated_nsr);
figure, imshow(wnr2)
title('Restoration of Blurred,
estimated_nsr = noise_var / var(I(:));
wnr3 = deconvwnr(blurred_noisy, PSF, estimated_nsr);
figure, imshow(wnr3)
title('Restoration of Blurred, Noisy Image Using Estimated
NSR');
Get Answers For Free
Most questions answered within 1 hours.