1): Add Gaussian noise and salt and pepper noise to the image respectively.
2): spatially filter the central area of the noisy image (100* 100) to eliminate the noise as much as possible.
3): Filter the central area of the noisy image (100* 100) in frequency domain to eliminate the noise as much as possible.
Technical description:
Gaussian noise and salt and pepper noise are added to the image; The image containing Gaussian noise and salt and pepper noise is processed to make the processed image clearer than the original image.
Technologies to be applied, including:
a> Add noise to the picture
b> Select the central area
c> Denoising the selected area.
d> Regenerate the image.
e> Gauss formula: exp (-(u 2+v 2)/(2 * (d0 2)) is used when constructing Gaussian low-pass filter.
Results discussion:
The following are the test results of different filters for different noise processing.
Refer to the following test results for discussion:
A(0 1 1) is the effect of using fspecial('gaussian') to smooth the spatial domain, but the effect is not the best, and the image is blurred due to the maximum noise reduction;
A(0 12) is the result of frequency domain filtering. Because Gaussian low-pass filter is used, there will be a black line, which is generally processed.
A(02 1) is the effect of using medfilt2 2 () spatial median filter, which has a good noise reduction effect and a clear image.
A(022) is the result of frequency domain filtering, which is the same as A(0 12). Because of the Gaussian low-pass filter, there will be a black line, and the effect is average.
Test results:
Gaussian noise and salt and pepper noise processing diagrams are as follows:
As shown in figure:
Figure (A00): Original drawing
Figure (A0 1): Gaussian noise addition
Figure (A0 1 1): center 100* 100 spatial filtering is performed on the figure (A0 1).
Graph (A0 12): filter the graph (A0 1) in frequency domain of center 100* 100.
(A0) (A0 1)
(A0 1 1) (A0 12)
As shown in figure:
Figure (A00): Original drawing
Figure (A02): Salt and pepper noise.
Figure (A02 1): center 100* 100 spatial filtering is performed on figure (A02).
Figure (A022): Filter the figure (A02) in the frequency domain of center 100* 100.
(A00) (A02)
(A02 1) (A022)
Appendix:
Source code 1: processing of Gaussian noise
f=imread('moon.tif');
J=imnoise(f,'gaussian',0.05,0.05); % Add Gaussian noise
% spatial filtering
r=[2 19 3 19 3 19 2 19];
c=[ 129 129 229 229];
BW=roipoly(J,c,r);
h=fspecial('gaussian',[5 5]);
A0 1 1=roifilt2(J,h,BW);
figure,imshow(A0 1 1);
% frequency domain filtering
f 1=imcrop(fn,[ 129 2 19 99 100]);
% Intercept the window picture with the size of 100* 100.
f2=[255 255];
% Create a new image
f2=uint8(f2);
f2=padarray(f2,[50 49],255);
% Expand the new image to the black image of 100* 100.
f2=padarray(f2,[2 18 129],0);
% Add white around the new picture to make it the size of the moon picture.
fn=fn-f2;
% got the moon picture in black in the center 100* 100 area.
PQ=paddedsize(size(f 1));
[u,v]=dftuv(PQ( 1),PQ(2));
D0=0.2*PQ(2);
hh=exp(-(u.^2+v.^2)/(2*(D0^2)));
% construct Gaussian low-pass filter
h 1=dftfilt(f 1,hh);
A0 12=padarray(h 1,[2 18 129],0);
% expands h 1 to the size of the moon picture.
A0 12=uint8(A0 12)+fn;
% got the moon picture processed in the center 100* 100 area.
figure,imshow(A0 12);
Source code 2: Processing of Salt and Pepper Noise
f=imread('moon.tif');
fn=imnoise(f,'salt & pepper',0.05);
% Add salt and pepper noise
% spatial filtering
f 1=imcrop(fn,[ 129 2 19 99 100]);
% capture the window image with the size of 100* 100.
f2=[255 255];
% Create a new image
f2=uint8(f2);
f2=padarray(f2,[50 49],255);
% Expand the new image to the black image of 100* 100.
f2=padarray(f2,[2 18 129],0);
% Add white around the new picture to make it the size of the moon picture.
fn=fn-f2;
% got the moon picture in black in the center 100* 100 area.
h=medfilt2(f 1,'symmetric');
% median processing of f 1
A02 1=padarray(h,[2 18 129],0);
% expands h to the size of the moon picture.
A02 1=A02 1+fn;
% got the moon picture processed in the center 100* 100 area.
figure,imshow(A02 1);
% frequency domain filtering
f 1=imcrop(fn,[ 129 2 19 99 100]);
% Intercept the window picture with the size of 100* 100.
f2=[255 255];
% Create a new image
f2=uint8(f2);
f2=padarray(f2,[50 49],255);
% Expand the new image to the black image of 100* 100.
f2=padarray(f2,[2 18 129],0);
% Add white around the new picture to make it the size of the moon picture.
fn=fn-f2;
% got the moon picture in black in the center 100* 100 area.
PQ=paddedsize(size(f 1));
[u,v]=dftuv(PQ( 1),PQ(2));
D0=0. 1*PQ(2);
hh=exp(-(u.^2+v.^2)/(2*(D0^2))); % construct Gaussian low-pass filter
h 1=dftfilt(f 1,hh);
A022=padarray(h 1,[2 18 129],0);
% expands h 1 to the size of the moon picture.
A022=uint8(A022)+fn;
% got the moon picture processed in the center 100* 100 area.
figure,imshow(A022);