Frequency domain transform of image and its application in frequency domain transformation of __ Images

Source: Internet
Author: User
Tags abs

Image frequency domain Transform and its application

1. Noun Explanation: (1) Spatial domains: English: Spatial domain. Encyclopaedia: Also known as image Space (imagespace). A space composed of image pixels. In the image space, it is called spatial domain processing to deal with the pixels directly with the length (distance) as the independent variable. (2) Frequency domain: English: Spatial frequency domain. Encyclopaedia: The characteristic of the image is described by the spatial frequency (i.e. the wave number) as the independent variable. It is possible to decompose the spatial variation of a picture image element into a linear superposition of Jianzhen functions with different amplitude, spatial frequency and phase, and the composition and distribution of various spatial frequency components in the image is called spatial spectrum. It is called spatial frequency domain processing or wave number domain processing to decompose, process and analyze the spatial frequency characteristics of the image. (3) The relationship between the two:

The spatial domain and frequency domain can be converted to each other. In the space frequency domain can refer to the already very mature frequency domain technology, the processing general step is:

A two-dimensional discrete Fourier transform or wavelet transform is applied to the image to transform the image from the image space to the frequency domain space (①).

② is used to analyze the spectrum of the image in frequency domain to change the frequency characteristic of the image. The different digital filters are designed to filter the spectrum of the image. Frequency domain processing is mainly used in the processing of image spatial frequency. such as image restoration, image reconstruction, radiation transformation, edge enhancement, image sharpening, image smoothing, noise suppression, spectral analysis, texture analysis and other processing and analysis. Note that the space frequency (wave number) unit is M-l or (mm)-1.

2. Application: (1) The image under the test directory: viewing the Fourier transform image of different images;
View the DCT (discrete cosine) transform of different images, (2) enhance the effect by using the spatial domain image enhancement method in the transformed image, compare 5.bmp and 10.bmp, 6.bmp and 9.bmp frequency domain images, (3) Use Low-pass filters to view the results; (4) Use High-pass filters To view the results. 3. Common functions: (1) Frequency domain processing function: ① Fourier transform fft2 (), ② Fourier inverse transform ifft2 () ③ discrete cosine transform dct2 () ④ frequency domain Filter function: dftfilt (f,h). (2) Spatial domain image enhancement ① linear transformation transfor (); ② exponential transformation exp (); ③ logarithmic transformation log (); ④ Power Transformation () ⑤ view histogram imhist (); ⑥ Using histogram equalization Histeq (), ⑦ using smoothing filter (IMFilter to realize function filtering), ⑧ using sharpening filter.
(3) Fourier transform process:

f = fft2 (f)
     S = ABS (f); Fourier spectrum
 Fc = Fftshift (f); quadrant transform
 S2 = log (1+abs (Fc)); Log transform
 im2uint8 (Mat2gray (g))

4.matlab Source: All Files screenshot as follows:


(1) adjusttoday.m

function Adjusttoday (strFileName);

I = Imread (strFileName);
J = Imadjust (i,[0.3 0.7],[0.1 0.9],[]);

J = Uint8 (I);

Imshow (J);

(2) DCTTODAY.M

function Dcttoday (strFileName);

RGB = Imread (strFileName);
I = Rgb2gray (RGB);
J = Dct2 (I);
Figure, Imshow (ABS (J)), []);

ColorMap (Jet ());
Colorbar;

(3) DFTFILT.M

function g = Dftfilt (f, H)
%dftfilt performs frequency domain filtering.
%   G = dftfilt (f, H) filters F in the frequency domain using the
%   filter transfer function H. The output, G, is the filtered
%   image, which has the same size as F.  Dftfilt automatically pads
% F to is the   same size as H.  Function Paddedsize can is used to
%   determine a appropriate size for H.
%
%   Dftfilt assumes that F are real and that H are real, uncentered
%   circularly-symmetric filter func tion. 

%   Copyright 2002-2004 Gonzalez, R. Woods, & L. Eddins
%   Digital Image processing Using Matl  AB, Prentice-hall,
%   $Revision: 1.5 $  $Date: 2003/08/25 14:28:22 $

% obtain the FFT of the padded Input.
f = fft2 (f, size (h, 1), Size (H, 2));

% perform filtering. 
g = Real (ifft2 (h.*f));

% crop to original size.
g = g (1:size (f, 1), 1:size (F, 2));

(4) FFTSHOW.M

function Fftshow (strFileName);

I=imread (strFileName);
I=rgb2gray (I);
Figure,imshow (I);

Str=strcat (strFileName, ' FFT ');
F = fft2 (I);
 F2 = log (ABS (F));
Figure,imshow (f,[-1 5], ' notruesize '), Title (str); ColorMap (Jet); Colorbar

D=dct2 (I);
 D2 = log (ABS (D));
Figure,imshow (d2,[-1 5], ' notruesize ');  %colormap (Jet); Colorbar
(5) FFTTODAY.M

function Ffttoday (strFileName);

I = Imread (strFileName);
F = fft2 (I);
S = ABS (F);
Fc = Fftshift (F);
S2 = log (1+abs (Fc));
outcome = Im2uint8 (Mat2gray (S2));

Subplot (221); Imshow (I);
Subplot (222); Imshow (F);
Subplot (223); Imshow (S);
Subplot (224); Imshow (Fc);

Figure, Imshow (S2);
Figure, imshow (outcome);

(6) freq.m

function Fftshow (strFileName);

I=imread (strFileName);
%   I=rgb2gray (I);
Figure,imshow (I);

F = fft2 (I);
 F2 = log (ABS (F));
Figure,imshow (f2,[-1 5], ' notruesize '), Title (strfilename+ ' FFT ');% ColorMap (Jet); Colorbar

D=dct2 (I);
% D2 = log (ABS (D));
Figure,imshow (d,[-1 5], ' notruesize '); % ColorMap (Jet); Colorbar
(7) HPFILTER.M

function H = Hpfilter (type, M, N, D0, n)%hpfilter computes frequency domain highpass filters. % H = Hpfilter (TYPE, M, N, D0, N) creates the transfer function of% a highpass filter, H, the specified TYPE and s
Ize (m-by-n).  % Valid values for TYPE, D0, and N are:% ' ideal ' ideal highpass filter with cutoff frequency D0. n% need not is supplied.
D0 must be positive.  % ' BTW ' butterworth highpass filter of order n, and cutoff% D0. The default value for N is 1.0.
D0 must be% positive. %% ' Gaussian ' Gaussian highpass filter with cutoff (standard% deviation) D0. n need not to be supplied.

D0 must be% positive. % Copyright 2002-2004 R. Gonzalez, R. Woods, & L. Eddins% Digital Image processing Using MATLAB, prentic E-hall% $Revision: 1.4 $ $Date: 2003/08/25 14:28:22 $% The transfer function Hhp of a highpass filter is 1-h LP,% where HLP is the transfer function ofThe corresponding lowpass% filter.

Thus, we can use a function lpfilter to generate highpass% filters. if Nargin = = 4 N = 1;
% Default value of N. End% Generate highpass filter.
HLP = Lpfilter (type, M, N, D0, N);
 H = 1-hlp;
(8) LPFILTER.M

function H = Lpfilter (type, M, N, D0, n)%lpfilter computes frequency domain lowpass filters. % H = Lpfilter (TYPE, M, N, D0, N) creates the transfer function of% a lowpass filter, H, the specified TYPE and s Ize (m-by-n).  
To% view the filter as a image or mesh plot, it should be centered% using H = Fftshift (h). % Valid values for TYPE, D0, and N are:%% ' ideal ' ideal lowpass filter with cutoff frequency D0.  n need% is supplied. 
D0 must be positive.  % ' BTW ' butterworth lowpass filter of order n, and cutoff% D0.  The default value for N is 1.0. 
D0 must be% positive.  %% ' Gaussian ' Gaussian lowpass filter with cutoff (standard% deviation) D0.  n need not to be supplied.  
 
D0 must be% positive. % Copyright 2002-2004 R. Gonzalez, R. Woods, & L. Eddins% Digital Image processing Using MATLAB, Prenti Ce-hall% $Revision: 1.7 $ $Date: 2003/10/13 00:46:25 $% use function DFTUV to set up the meshgrid arrays needed for% computing the required. 
%[u, V] = Dftuv (M, N); U = M; 
v= N; 
% Compute The distances D (U, V). 
 
D = sqrt (u.^2 + v.^2); 
% Begin filter computations. 
Switch type case ' ideal ' H = double (D = D0);	 
   Case ' BTW ' if nargin = = 4 N = 1; 
End H = 1./(1 + (d./d0). ^ (2*n)); 
Case ' Gaussian ' H = exp (-(d.^2)./(2* (d0^2))); 
Otherwise error (' Unknown filter type. ') 
 End
(9) PADDEDSIZE.M

function PQ = Paddedsize (AB, CD, PARAM)%paddedsize computes padded sizes for useful fft-based.   % PQ = paddedsize (AB), where AB is a two-element size vector,% computes the two-element size vector PQ = 2*ab.%
PQ = paddedsize (AB, ' PWR2 ') computes the vector PQ such that percent PQ (1) = PQ (2) = 2^nextpow2 (2*m), where M is MAX (AB).  % PQ = paddedsize (AB, CD), where AB and CD are two-element size% vectors, computes the two-element size vector PQ.
The elements% of PQ are the smallest even integers greater or than to% AB + equal. % PQ = paddedsize (AB, CD, ' PWR2 ') computes the vector PQ such that percent PQ (1) = PQ (2) = 2^nextpow2 (2*m), where M is

MAX ([AB CD]).
if Nargin = = 1 PQ = 2*ab;
   ElseIf Nargin = = 2 & ~ischar (CD) PQ = AB + CD-1;
PQ = 2 * ceil (PQ/2); ElseIf Nargin = = 2 m = max (AB);

   % Maximum dimension.
   % find power-of-2 at least twice m.
   P = 2^nextpow2 (2*m);
PQ = [P, p]; ElseIf Nargin = = 3 m = max ([AB CD]); %maximumDimension.
   P = 2^nextpow2 (2*m);
PQ = [P, p];
 else error (' Wrong number of inputs. ') End
(10) Test Pictures: Testing






Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.