Statistical Signal Processing - Image Restoration Using Wiener Filtering and Inverse Filtering - Matlab Simulation - Code Attached

  1. Restoration of Noisy Images Using Wiener Filtering

  1. Introduction to Topics and Filtered Image Restoration

  1. topic

Apply Wiener filtering to image restoration, assuming that the degraded image is an image polluted by additive Gaussian white noise, try the inverse filtering method and Wiener filtering method to restore the image, and compare their effects; consult the literature, try to use iterative Wiener filtering method to further improve the effect, pay attention to constructing the correct correction item.

  1. Introduction to Inverse Filtering for Image Restoration

The inverse filtering method is a technique to restore the original image from the noise-added image, and its basic idea is to use the filter and the inverse filter of the filter. In this method, the contaminated image is first filtered with an appropriate filter (such as a Wiener filter), and then the filtered image is filtered using the inverse filter of the filter to restore the original image. Since the effect of noise is canceled out in the inverse of the filter, the original image can be effectively restored.

  1. Introduction to Wiener Filtering for Image Restoration

Wiener filtering is an iterative filtering algorithm based on a signal model, which assumes that the signal is a combination of noisy linear system dynamic response and additive Gaussian noise. The basic idea of ​​Wiener filtering is to first estimate the model parameters of signal and noise, then construct a filter according to the model parameters, and finally use the filter to eliminate noise.

Wiener filtering can restore the noisy image because it can construct a filter according to the model parameters of the signal and noise, and then eliminate the noise through the filter to restore the noisy image.

  1. The principle of inverse filtering and Wiener filtering

  1. The principle of inverse filtering

In general, the degradation model of an image can be expressed as

Among them, g(x,y) represents the degraded image, h(x,y) is the point spread function, f(x,y) is the original image, and n ( x , y ) is the introduced noise. In the frequency domain, it can be expressed as

Transforming it into the frequency domain gives

so

The restored image can be obtained by performing inverse Fourier transform on it.

  1. The principle of Wiener filtering

Wiener filtering is another common image restoration method, the computational complexity is relatively small and the influence of noise is considered. Usually, assuming that the image and noise are independent of each other and there is at least one mean value of zero, when the gray levels of the restored image and the blurred image are linear, Wiener filtering can be expressed as

Among them, Sn(u,v) is the noise power spectrum, and Sf(u,v) is the original image power spectrum.

  1. Matlab simulation results

  1. Inverse filtering simulation results

As can be seen from the above figure, the original image is an aurora scene without visible noise to the naked eye. After adding Gaussian white noise, small white spots appear in random positions in the image. After inverse filtering and restoration, the noise in the image is significantly reduced. But at the same time, it will also filter out the stars similar to the noise of the original image.

  1. Wiener filtering simulation results

After restoration by Wiener filtering, the noise in the image is significantly reduced, but unlike inverse filtering, the stars in the image after Wiener filtering are not considered as noise and completely filtered out.

  1. Iterative Wiener filtering simulation results

As shown in the figure above, iterative Wiener filtering has a good effect on image restoration and can filter out most of the noise. After several iterations, the image has recovered well. After the number of iterations reaches a certain upper limit, the effect does not change significantly.

the code

% Load image
img = imread('C:\Users\songy\OneDrive\Pictures\sample.png');
% Convert to grayscale
img_gray = rgb2gray(img);
% Add Gaussian white noise
noisy_img = imnoise(img_gray, 'gaussian', 0, 0.01);
% Perform Wiener filtering
filtered_img = wiener2(noisy_img, [5 5]);
% Display the filtered image
subplot(1,3,1)
imshow(img_gray)
title('原图')
subplot(1,3,2)
imshow(noisy_img)
title('加入高斯白噪声的图像')
subplot(1,3,3)
imshow(filtered_img)
title('维纳滤波后的图像')

%迭代部分,单独执行
img1=wiener2(noisy_img, [5 5]);
img2=wiener2(img1, [5 5]);
img3=wiener2(img2, [5 5]);
img4=wiener2(img3, [5 5]);
subplot(2,2,1)
imshow(noisy_img)
title('带噪声图')
subplot(2,2,2)
imshow(img1)
title('第一次迭代')
subplot(2,2,3)
imshow(img2)
title('第二次迭代')
subplot(2,2,4)
imshow(img3)
title('第三次迭代')
%% 加载图像
I=imread('C:\Users\songy\OneDrive\Pictures\sample.png');
%% 生成维纳滤波器
% Convert to grayscale
img_gray = rgb2gray(I);
% Add Gaussian white noise
noisy_img = imnoise(img_gray, 'gaussian', 0, 0.01);
N=5; % 维纳滤波器大小
sigma=2; % 标准差
h=fspecial('gaussian',N,sigma);
%% 逆滤波处理
J=imfilter(noisy_img,h,'symmetric');
%% 显示结果
figure;
subplot(1,3,1);
imshow(img_gray);
title('原始图像');
subplot(1,3,2);
imshow(noisy_img);
title('加入高斯白噪声');
subplot(1,3,3);
imshow(J);
title('逆滤波恢复后的图像');

Guess you like

Origin blog.csdn.net/qq_22471349/article/details/129168394