0% found this document useful (0 votes)
13 views8 pages

BE244 Image Enhancement Frequency Domain

The document covers advanced topics in image enhancement, focusing on spatial filtering and Fourier transforms, including their properties and applications. It explains convolution, discrete Fourier transforms, and the significance of various filters such as Gaussian and median filters. Additionally, it discusses the implications of sampling and convolution in the Fourier domain, providing mathematical formulations for both 1D and 2D cases.

Uploaded by

djermane ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views8 pages

BE244 Image Enhancement Frequency Domain

The document covers advanced topics in image enhancement, focusing on spatial filtering and Fourier transforms, including their properties and applications. It explains convolution, discrete Fourier transforms, and the significance of various filters such as Gaussian and median filters. Additionally, it discusses the implications of sampling and convolution in the Fourier domain, providing mathematical formulations for both 1D and 2D cases.

Uploaded by

djermane ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Image Enhancement II Image Enhancement II

 Spatial Filter (continued)


 Fourier Transforms (1D and 2D)
 Discrete Fourier Transform (1D and 2D)
BE 244 Lecture 2  Properties of Fourier Transform

Kio Kim
 Sampling
 Low-pass and High-pass Filters

1 2

Spatial Filtering—continued Spatial Filtering—continued


 Famous linear kernel functions:

Filtering = Convolution Gaussian Sinc (‘ideal’) Rectangle Delta (impulse)

Convolution: f g x =  f  g  x d 




(Opposite of cross-correlation)

– And Kalman filter, Wiener filter

 Nonlinear filters:
– Median filter
– Particle filter etc.

3 4

Fourier Transforms Fourier Transforms



 Basic idea:
Fourier Transform: F (u )  f x exp  j 2ux dx
Any periodic function can be decomposed into sine and cosine functions. 


Inverse Fourier Transform: f ( x )  F u exp j 2ux du





FT using Euler’s Formula: F (u )  f x cos 2ux  j sin 2ux dx



 

 f x cos 2ux dx  j f x sin 2ux dx


 

Ideal Discrete Function R (u)  jI (u)

F  u=F u exp [ j u]


* How much magnitude for each frequency?
* How much phase shift for each frequency? 1
1 I u P (u )  F (u )
2
F (u )  R 2 (u )  I 2 (u ) 2
u = tan  
-->You can figure it out R u
by Fourier transformation. Fourier Spectrum Phase Angle Spectral Density
(magnitude) (phase) (power spectrum)
5 6
Fourier Transform (1D Example) Fourier Transform (2D)


1D Fourier Transform: F (u )  f x exp  j 2ux dx


A for u 0 
A for  32  x  32 F ( u)  sin u
f (x)  
0 otherwise otherwise
u 1D Inverse Fourier Transform: f ( x )  F u exp j 2ux du


Space Domain Fourier Domain (magnitude)  

2D Fourier Transform: F (u , v )  f x, y exp  j 2(ux  vy ) dxdy


  

 

2D Inverse Fourier Transform: f ( x, y )  F u, v exp j 2u(ux  vy ) dudv


  

Fourier Spectrum, Phase Angle, and Power Spectrum are all


calculated in the same manner as the 1D case

7 8

Fourier Transform (2D Example) Fourier Transform (2D Example)

9 10

Fourier Transform (2D Example)

11

http://www.ajronline.org/cgi/content/figsonly/190/5/1396
Discrete Fourier Transform

N=512 samples (pixels) N=128 pix


K=64 pixels K=14 pix

x = 25/512 x=25/128
= 0.05 mm/pixel =0.2 mm/pix

25mm 25mm
K (Matlab does not apply 1/N to the FT)

u = 1/Nx u = 1/Nx
= 1/25 =1/25
= 0.04 mm-1 = 0.04mm-1

Subsampling changes peak height (DC value) of FT (Matlab only) but the rate of zero crossings
is the same for both. 14
Functions are the same, but represented by a different number of frequency points => loss of
high frequency information.

Properties Properties
Translation:

[  ] [ ]
M 1 N 1
F  uu0, v v 0=
1
MN

x=0 y=0
f  x , y exp j 2 
u0 x v0 y
M

N
exp  j 2 
ux vy

M N  2D Function (Image)
u x v y
f ( x, y ) exp j 2 0  0  F (u  u0 , v  v0 ) Shifting Property
M N
u0 x v 0 y
f ( x  x 0 , y  y0 )  F (u, v ) exp  j 2 
M N

FT of Image
Special Case: for u0 = M/2 exp j 2
u0 x v 0 y
 1
x y
Useful for
v0 = N/2 M N centering FT or
x y M N IFT at the origin
f ( x, y )  1  F u ,v 
2 2
M N xy Shifted FT of Image
f x ,y  F (u , v )  1
2 2
15 16

(back of ‘moon blade’ shown in FT) (Spokes in spatial domain and wrapping (aliasing; Moire pattern) shown.)

Properties Properties
M 1N1
1 ux vy
Separability: F (u, v) 
MN

x 0 y  0
f ( x , y ) exp  j 2 
M N
for u = 0,1,2, ,M-1
v = 0,1,2, ,N-1

M 1 N1
1 j 2ux 1 j 2vy

M
 exp 
x 0 M N

y 0
f ( x, y ) exp 
N

M 1
1 j 2ux

M
 F ( x, v) exp 
M
1D row FT
x 0

N1
1 j 2vy
where F ( x, v ) 
N
 f ( x, y) exp  N
1D column FT
y 0

17 18
http://www.ajronline.org/cgi/content/figsonly/190/5/1396
Properties Properties
1 M 1N1
ux vy Rotation: x r cos  u cos  polar coordinates
Periodicity: F (u, v) 
MN

x 0 y  0
f ( x , y ) exp  j 2 
M N
for u = u+M
v = v+N y r sin  v sin 
f ( r ,  0 )  F (,  0 )

M 1N1
1 Mx Ny ux vy  [ f 1  x , y  f 2  x , y ]=  [ f 1 x , y  ][ f 2  x , y ]
F (u  M , v  N ) 
MN
 f ( x, y ) exp j 2
M

N
exp  j 2 
M N
Distributivity: Addition YES!
x 0 y  0
 [ f 1  x , y f 2  x , y ]  [ f 1 x , y  ][ f 2  x , y ] Multiplication NO!
M 1N1
1 ux vy

MN
 f ( x , y ) exp  j 2 
M N
F (u , v )
x 0 y  0

Scaling: af ( x , y )  aF (u , v )
1 u v
f ( ax , by )  F ,
ab a b
Conjugate
F (u , v )  F * ( u ,  v )
Symmetry:
M 1N1
1 ux vy
Average Value: F (u, v) 
MN

x 0 y  0
f ( x , y ) exp  j 2 
M N
M 1N 1
1
Magnitude F (u, v )  F (  u , v )
for u = v = 0 (origin) F (0,0) 
MN
 f ( x, y ) The average of f(x,y) is the
Symmetry: x 0 y  0 value at the center of the
19 frequency matrix 20
(Think what ‘zero frequency’ means---it’s flat!)

Convolution in Fourier Domain Convolution in Fourier Domain




Convolution: f ( x )  g ( x )  f g ( x  )d Recall, if the FT is used to



compute the convolution
(ie product of the FT of
Convolution Theorem: f ( x)  g ( x)  F (u )G (u ) f(x,y) and g(x,y)) the
assumption is that f and g
f ( x ) g ( x )  F (u )  G (u )
are periodic. If the images
are not padded to extend
the FT computation
window, wrap error will
occur as shown.

21 22

Convolution in Fourier Domain Convolution in Fourier Domain


Continuous 2D Convolution: f ( x, y )  g ( x, y)  f (, ) g ( x  , y  ) dd
Discrete Functions: f ( x )  f (0), f (1), f ( 2),..., f ( A  1) 

g ( x )  g ( 0), g (1), g (2),..., g ( B  1) Discrete 2D Convolution:

To perform a convolution, we assume f(x) and g(x) are periodic with a period P ! A  B  1 f(x,y); 0  x  A-1 & 0  y  B-1
The resulting convolution will have the same period (P) and the individual f’(x,y) =
periods will not overlap, ie no aliasing 0; AxP or B yQ
f ( x ); 0  x  A  1 g ( x ); 0 x B  1
f ( x )  g ( x )  Zero-padded functions
g(x,y); 0  x  C-1 & 0  y  D-1
0; A  x P  1 0; B x  P  1
g’(x,y) =
0; CxP or DyQ
P1
1
f ( x )  g ( x )   f  p g ( x  p)
P p 0
for x = 0,1,2, ,P-1
P1 Q 1
1
f ( x , y )  g ( x, y )  
PQ p 0
 f  p, q g ( x  p, y  q ) for x = 0,1,2, ,P-1
y = 0,1,2, ,Q-1
q 0
Convolution Theorem: f ( x )  g ( x )  F (u)G (u )
f ( x ) g ( x )  F (u)  G (u )
Convolution Theorem: f ( x, y)  g ( x, y )  F (u, v)G (u, v)
23 f ( x , y ) g ( x , y )  F (u, v )  G (u , v ) 24
Convolution in Fourier Domain Sampling Distortion
 x0
Dirac Delta Function, (x): ( x  x0 ) dx  ( x  x0 ) dx 1 Band-limited Functions:
  x 0
Sampling is • Infinite in spatial domain

simply a • Only defined on the frequency interval [-W,W]
convolution with f ( x )( x  x 0 ) dx f ( x 0 ) Sifting Property • Must be sampled at the Nyquist rate to avoid aliasing: x  1/(2W)

an impulse
function (x - x0)
f() g() - comb filter f(x)*g(x)
f(x) F(u)

x u
-W W

  x
a -T T -T a T

Under periodic boundary,


pixel size (x, space) determines bandwidth (Nu1/x, Fourier)
# of pixels (A,B, space) = # of samples (C,D, Fourier) 25 26

Sampling Distortion Sampling Distortion


 How can we avoid aliasing?
Finite sampling with a window function:
• Window function that is finite in space (eg rect – By suppressing high-frequency structures.
function) has infinite frequency components
• Infinite window function, H(u), and finite sampled (or, by smoothing the image)-->Gaussian filtering
function, s(u)*F(u), introduces distortion
• Limits full recovery of original function, f(x), from a
finite number of samples file:///mnt/home/tmp/images/Moire_p file:///mnt/home/ file:///mnt/home/tmp/images/Moire_gf file:///mnt/home/
attern_of_bricks.jpg tmp/images/Moir .jpg tmp/images/Moir
• Complete recovery is only possible if f(x) is band- e_res.jpg e_gf_res.jpg
limited and periodic with a period X where

Spatial Domain: Nx  X


1 1 Moire Pattern
Frequency Domain:N u  u 
x 0 Nx 0

Narrow down the bandwidth (reduce sample #) too much


--> Aliasing!

27 28
http://upload.wikimedia.org/wikipedia/commons/3/31/Moire_pattern_of_bricks.jpg

Properties

2D Function (Image)

FT of Image

Shifted FT of Image ‘Siemens Star’ http://www.imatest.com/docs/testcharts.html

(Or, http://www.youtube.com/watch?v=Dyisg9-Mwjw
to see how sampling can distort what you see.)
29 30

(back of ‘moon blade’ shown in FT) (Spokes in spatial domain and wrapping (aliasing; Moire pattern) shown.)
Frequency Domain Filters Frequency Domain Filters
Gaussian-based filters
• Frequency filter H(u,v) suppresses certain frequency components in an image
u2
• Low-pass filters smooth images by suppressing high frequency components (rapidly H (u )  A exp  h( x )  2 A exp  2u 2 2 2
x
changing intensities) 2 2
• High-pass filters highlight edges by suppressing low frequency components (near-
constant intensities)
• Spatial filters are applied to the image with a 2D convolution. By the convolution • Gaussian filters are real in both the frequency
theorem and spatial domains, ie computation is
simpler than other filters
• We use Gaussian functions often in
f ( x, y )  h( x , y )  F (u, v ) H (u , v ) where the prime indicates analyzing biological data because it best
that the images are padded appropriately describes the normal distribution of
observations that scientists make during an
• PRO: Filtering in the frequency domain is often more intuitive, experiment. Because of this, the properties
Faster if your kernel image is big (O(N 2) vs O(N log N) for FFT) of the Gaussian are more intuitive to us (as Analogous
spatial filters
scientists) than other functions.
• CON: Slower if your kernel image is small
• Because these two functions form an FT pair,
• Decide on the filter characteristics in the frequency domain but perform the filtering their behavior is reciprocal
in the spatial domain

31 32

Frequency Domain Filters


Correspondences
Basic Matlab steps in DFT filtering to image f
1. Compute the transform F(u,v) : fft2(f)
 Famous linear kernel functions:
2. Generate a filter function H(u,v) of size A+C-1, B+D-1 using fspecial and freqz2. Use Gaussian Sinc (‘ideal’) Rectangle Delta (impulse)
fftshift, if necessary, to be consistent with position of F(u,v)
(*. freqz2 is not available in OCTAVE.)

3. Multiply the transform by the filter G(u,v) = H(u,v)F(u,v): G = H.*F


4. Obtain the real part of the inverse FT of G(u,v): g = real(ifft2(G))
5. Crop the top left rectangle to the original size of f: g = g(1:size(f,1), 1:size(f,2))

 Correspondences in Fourier domain:

(Imagine squeezing sinc to 0)

33 34

Low Pass Filters ‘Ideal’ Low Pass Filter


Find the appropriate H(u,v) to suppress high frequency components in F(u,v) and
generate G(u,v) with smoother intensities and/or reduced noise

G (u , v )  F (u, v ) H (u, v )

1; D(u, v )  D0
Ideal low-pass filter H (u , v )  where Do is a specified cutoff frequency
0; D(u, v ) " D0

Recall reciprocal behavior with h(x,y).


Narrowing in frequency is widening in
space (eg larger smoothing kernel).
Both result in increased blur.

ILPFs are not ideal!


35 Ringing occurs in the spatial domain due to 36
truncation artifacts
‘Ideal’ LPF Butterworth LPF
Butterworth LPF of order n 1
H (u , v )  2n
1  D(u, v ) / D0

Note how higher orders


approximate ILPF.

What do you think is


Source of ringing in images happening in the
filter with ILPF spatial domain?

• Smoother transition band


• Typically define cutoff (D0) as the value when the function is a certain fraction of
the maximum value (eg D0 is defined at H(u,v) = 0.5 in the figure)

37 38

Butterworth LPF Butterworth LPF


Effect of 2nd order BLPF
with same cutoffs shown
for ILPF

No ringing!

39 40

Gaussian LPF Gaussian LPF


Gaussian LPF D (u , v ) 2 D (u , v ) 2
H (u, v ) exp  exp  2
2 2 2 D0

Note how lower values of


D0 approximate ILPF.

How do you expect


these filters to
compare with BLPF?

D0 is the standard deviation of the Gaussian distribution, therefore, it is defined


at 67% of maxH(u,v)

41 42
High Pass Filters HPF - Spatial Representations
Find the appropriate H(u,v) to suppress low frequency components in F(u,v) and
generate G(u,v) with sharper intensity transitions (edges)

G (u , v )  F (u, v ) H (u, v ) IHPF still


has ringing
artifacts
Ideal
A common method for HPF
generating a HPF is
to take the inverse of
a LPF
BHPF can
have ringing
artifacts also
Butterworth
H HP (u, v ) 1  H LP (u , v ) HPF

Gaussian
HPF

43 44

Ideal HPF Butterworth HPF


0; D(u, v )  D0
Ideal HPF H (u , v )  Butterworth HPF of order n 1
1; D(u, v ) " D0 H (u , v )  2n
1  D0 / D(u , v )

Ringing at small
D0

Small spot size in frequency


means large spot size in Smoother behavior (less ringing) than IHPF but edges are still
space blurred at smaller D0

45 46

Gaussian HPF
Gaussian HPF D(u , v ) 2
H (u, v ) 1  exp  2
2 D0

Minimal ringing and cleaner edges at small D0 than BHPF

47

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy