(1) To customize the frequency domain Gaussian low-pass filter processing function of an image, it is required that the input parameters of the function include the image IMA before processing and the distance D0 (cutoff frequency) from the center of the frequency rectangle, and the output parameter is the image im2 after filtering processing.
Custom Gaussian low-pass filter:
The%pho parameter is the path of the input image
%d0 parameter is the cutoff frequency
function im2 = MYGLPF (pho,d0)
ima = imread (pho);% read input image
% get Gaussian low pass filter
[r c] = size (IMA); % gets the rows and columns of the input image
d = zeros (r,c);%d (u,v) is the distance from the center of the frequency rectangle for
i=1:r for
j=1:c
D (i,j) =sqrt ((I-R/2) ^2+ (J-C/2) ^2) ;
End
End
H=exp (-(d.^2)/(2*d0*d0));% calculation filter, get Gaussian lowpass filter
f=fft2 (Ima,size (h,1), size (h,2));% Fourier transform the original image
F=fftshift (f);% shifts the center shift
of the Fourier transform F F1=IFFT2 (Ifftshift (h.*f)); % after the center shift F uses the Gaussian low-pass filter to perform an inverse FFT movement (remember to do an anti-FFT move, otherwise the input result picture background will be dimmed), and the inverse transform
im2=real (F1);% gets the amplitude (or frequency spectrum) from the result
im2= Uint8 (IM2);
(2) According to the custom frequency domain Gaussian low-pass filter function, set up the appropriate filter parameters, processing the experimental image exp5-1.tif, so that the text document containing the break character is preprocessed to achieve the purpose of bridging the break character.
Parameter setting of Gaussian low-pass filter and processing of input image exp5-1.tif
Set a number of different cutoff frequencies to obtain different Gaussian low-pass filters. To process the input image USEMYGLPF (' Exp5-1.tif '):
function [] = USEMYGLPF (PHO)
ima=imread (pho);% input Image
subplot (231);% display input image
imshow (IMA);
Title (' Input image ');
D0=[60 80 100 120 140]; % set multiple cutoff frequencies to compare for
i=1:size (d0,2)
G=MYGLPF (pho,d0 (i)) and% to obtain the results of a Gaussian lowpass filter using different cutoff frequencies
subplot (2,3,i+1);% Display Results
Imshow (g);
Title ([' D0 = ', Num2str (D0 (i))]);
End
The output results are as follows:
(3) Please use the above custom frequency domain filter and the previously described definition of the spatial domain smoothing filter (http://blog.csdn.net/qq_15096707/article/details/50061003), The exp5-2.jpg of the experimental image with noise pollution is processed and the filtering effect is observed/compared.
Comparison of processing efficiency of frequency domain and spatial domain filter (experimental image is exp5-2. jpg)
Call the above USEMYGLPF (' exp5-2.jpg ') and the result is as follows:
Using the defined spatial domain smoothing filter described previously, the results are as follows:
Here I compare a Gaussian low-pass filter with a cutoff frequency of D0 80 and a 3x3 Gaussian mean filter:
From the results, the filtering results of both are fuzzy, and the filter result of the Gaussian lowpass filter with D0 80 is smoother than that of the 3x3 Gaussian mean filter, and the effect of the 3x3 Gaussian mean filter is not better than that of the Gaussian low-pass filter with D0 80, from the visual effect. At the same time, the cutoff frequency of the Gaussian low-pass filter in the frequency domain can be controlled, and a better filtering result can be selected selectively.
Knowledge Points:
Referring to the frequency domain knowledge, to tell the truth in class when not all understand, there is always a vague place, after all, the frequency domain involved in the knowledge is mostly theoretical aspects, and the theoretical knowledge of the lack of basic support for themselves. In addition, the operation of the frequency domain without the spatial domain is intuitive and more abstract.
Therefore, in the experiment class spent some time, looked at the ppt--frequency domain filter.
For the "Frequency domain Filtering" knowledge of learning, we need to remember the following several points of knowledge (even if the principle does not understand, but also to remember, because these points of knowledge to facilitate our understanding):
(1) Any periodic function can be expressed as a sine and/or cosine of different frequencies, and each sine and/or cosine is multiplied by a different coefficient (now called the Fourier series). No matter how complex the function, as long as it is periodic, and satisfies some moderate mathematical conditions, can be expressed in such a and. From here we can also think of why discrete points (input image matrices) in space can be transformed into Fourier functions, but this is the discrete point that satisfies the Fourier function. Corresponds to a point in the spatial domain.
(2) We use the amplitude (amplitude or frequency spectrum) to present it in a grayscale image, from which we cannot infer from this gray scale the image of what is or what is in the spatial domain of the original. When actually operating in the frequency domain, the amplitude is also manipulated.
(3) The light and dark spots on the spectrum map are actually the difference between a certain point in the image and the gray value of the neighborhood point.
(4) The frequency of the image to characterize the intensity of the changes in the image of the index.
(5) The energy of the image is generally concentrated in the low frequency region (highlights).
(6) The basic properties of the frequency domain:
The slowest changing frequency component (origin) corresponds to the average gray level of the image;
The lower frequency corresponds to the slow-changing component of the image;
The higher frequency corresponds to the fast changing component of the image.
(7) The basic steps of frequency domain filtering:
(with ( -1) x+y multiplied by the input image for central transformation)