1.Basic principles of DFT transformation
Find the Fourier transform of a simple continuous function:
f ( t ) = { A t ∈ [ − w / 2 , w / 2 ] 1 else f(t)= \begin{cases} A& t\in[-w/ 2, w/2]\\ 1& \text{else} \end{cases}f(t)={
A1t∈[−w/2,w/2]else
F ( u ) = ∫ − w / 2 w / 2 A e − j 2 π utdt = − A j 2 π u [ e − j 2 π ut ] − w / 2 w / 2 = − A j 2 π u [ e − j π uw − ej π uw ] \begin{align} F(u) =& \int_{-w/2} ^{w/2} Ae^{-j2\pi ut}dt \\ =& \ frac{-A}{j2\pi u}[e^{-j2\pi ut}]_{-w/2} ^{w/2} \\ =&\frac{-A}{j2\pi u }[e^{-j\pi uw} - e^{j\pi uw}] \end{align}F(u)===∫−w/2w/2Ae− j 2 π u t dtj 2 π u−A[e−j2πut]−w/2w/2j 2 π u−A[e− jπ u w−ejπ u w ]
Form: sin θ = ( ej θ − e − j θ ) / 2 j \sin \theta = (e^{j \theta} - e^{-j\theta}) /2jsini=(ejθ−e− j θ )/2j得
F ( u ) = A w sin ( π uw ) π uw F(u) = A w\frac{\sin(\pi uw)}{\pi uw}F(u)=Awπuwsin ( π u w )
The image is:
Typically, the Fourier transform contains complex terms, a convention for displaying the magnitude of the transform. This amplitude is called the Fourier spectrum or spectrum:
∣ F ( u ) ∣ = AW sin ( π uw ) π uw |F(u)| = AW\frac{\sin(\pi uw)}{\pi uw}∣F(u)∣=AWπuwsin ( π u w )
You can find it through the picture above
- F ( u ) F(u) F(u) 和 ∣ F ( u ) ∣ |F(u)| ∣ F ( u ) ∣ are inversely proportional to the width W of the box function
- The greater the distance to the origin, the height of the side lobe decreases with the increase of the distance from the origin.
- The function wants u to extend infinitely in the positive and negative directions.
1.1 Forward transformation:
F ( u , v ) = ∑ x = 0 M − 1 ∑ y = 0 N − 1 f ( x , y ) e − j 2 π ( μ x / M + v y / N ) (1.1) F(u,v) = \sum_{x=0}^{M-1}\sum_{y=0}^{N-1}f(x,y)e^{-j2\pi(\mu x/M + vy/N)} \tag{1.1} F(u,v)=x=0∑M−1y=0∑N−1f(x,and ) e− j 2 π ( μx / M + v y / N )(1.1)
- N N N represents the rows of the image
- M M M represents the column of the image
- f ( x , y ) f(x,y) f(x,y ) represents the pixel value
1.2 Inverse transformation:
f ( x , y ) = 1 M N ∑ u = 0 M − 1 ∑ v = 0 N − 1 F ( u , v ) e j 2 π ( u x / M + v y / N ) (1.2) f(x,y)=\frac{1}{MN}\sum_{u=0}^{M-1}\sum_{v=0}^{N-1}F(u,v)e^{j2\pi(ux/M+vy/N)} \tag{1.2} f(x,y)=MN1u=0∑M−1v=0∑N−1F(u,v ) ej 2 π ( ux / M + v y / N )(1.2)
1.3 Euler’s formula:
ej θ = cos θ + j sin θ (1.3) e^{j\theta} = \cos \theta + j \sin\theta \tag{1.3}ejθ=cosi+jsini( 1.3 )
Using Euler’s formula to deform the Fourier transform, we can obtain a complex form of the Fourier transform
1.4 Frequency domain analysis
Frequency domain analysis is to analyze F (u, v) F(u,v)F(u,v ) includes:
- ∣ F ( u , v ) ∣ |F(u,v)| ∣F(u,v ) ∣ : amplitude
- ej θ ( u , v ) e^{j\theta(u,v)}ej θ ( u , v ) : phase angle
- R ( u , v ) R(u,v) R(u,v ) : real part
- i I ( u , v ) iI(u,v)i I ( u ,v ) : imaginary part
The f amplitude spectrum of the two-dimensional function:
∣ F ( u , v ) ∣ = [ R 2 ( u , v ) + I 2 ( u , v ) ] 1 / 2 (1.4) |F(u,v)| = [R^2(u,v) + I^2(u,v)]^{1/2} \tag{1.4}∣F(u,v)∣=[R2(u,v)+I2(u,v)]1/2( 1.4 )
Fourier spectrum passes:lg ( 1 + ∣ F ( u , v ) ∣ ) \lg(1+|F(u,v)|)lg(1+∣F(u,v ) ∣ ) Display
phase:
φ ( u , v ) = tan − 1 [ I ( u , v ) / R ( u , v ) ] (1.5) \varphi(u,v) = \tan^{-1 }[I(u,v)/R(u,v)]\tag{1.5}φ ( u ,v)=tan−1[I(u,v)/R(u,v)]( 1.5 )
Equivalence:
E ( u , v ) = R 2 ( u , v ) + I 2 ( u , v ) (1.6) E(u,v) = R^2(u, v) + I^2 (u,v)\tag{1.6}E ( u ,v)=R2(u,v)+I2(u,v)(1.6)
1.5 Conjugation properties
2. Functions that implement DFT in OpenCV
- When the inputArray is in the form of two channels, the output must also be in two channels. Channel 0 represents the real part and channel 1 represents the imaginary part. Therefore, if it is an image (grayscale image), you need to construct a CV_32F2 object with two channels in which channel 1 is all 0 from the original image.
- When inputArray is in the form of a single channel, it must be a real array. At this time, the output is also a complex array of ccs format on a single channel, which can be used at this time.