http://www.ee.unlv.edu/~b1morris/ecg782/ Professor Brendan Morris, SEB 3216, brendan.morris@unlv.edu
ECG782: Multidimensional Digital Signal Processing Filtering in - - PowerPoint PPT Presentation
ECG782: Multidimensional Digital Signal Processing Filtering in - - PowerPoint PPT Presentation
Professor Brendan Morris, SEB 3216, brendan.morris@unlv.edu ECG782: Multidimensional Digital Signal Processing Filtering in the Frequency Domain http://www.ee.unlv.edu/~b1morris/ecg782/ 2 Outline Background Concepts Sampling and
Outline
- Background Concepts
- Sampling and Fourier Transform
- Discrete Fourier Transform
- Extension to Two Variables
- Properties of 2D DFT
- Frequency Domain Filtering Basics
- Smoothing
- Sharpening
- Selective Filtering
- Implementation
2
Motivation
- Complicated signals
(functions) can be constructed as a linear combination of sinusoids
β« Mathematically compact representation with complex exponentials ππππ’
- Introduced as Fourier series
by Jean Baptiste Joseph Fourier
β« Initially considered periodic signals β« Later extended to aperiodic signals
- Powerful mathematical tool
β« Can go between βtimeβ and βfrequencyβ domain processing
3
Preliminary Concepts
- Complex numbers
β« π· = π + ππ½ β« π·β = π β ππ½ β« π· = π· πππ
ο Using Eulerβs formula ο πππ = cos π + π sin π
- Fourier Series
β« Express a periodic signal as a sum of sines and cosines β« π π’ = πππππ0ππ’
π
β« ππ =
1 π π π’ πβππ0ππ’ π
ο π0 = 2π/π
- Fourier Transform
β« πΊ π = β± π π’ = π π’ πβπ2πππ’ππ’
ο π : continuous frequency variable
β« π π’ = β±β1 πΊ π = πΊ π ππ2πππ’ππ β« Notice for real π π’ this generally results in a complex transform
4
Rectangle Wave Example
- πΊ π = π΅π
sin πππ πππ
β« Rectangle in time gives sinc in frequency β« See book for derivation
- Frequency spectrum
β« πΊ π = π΅π sin πππ
πππ
ο Consider only a real portion
- Note zeros are inversely proportional to width of box
β« Wider in time, narrow in frequency 5
Convolution Properties
- Very important input-output relationship
between a input signal π π’ and an LTI system β(π’)
- π π’ β β π’ = π π β π’ β π ππ
- Dual time-frequency relationship
β« π π’ β β π’ β πΊ π πΌ π β« π π’ β π’ β πΊ π β πΌ π β« Convolution-multiplication relationship
6
Sampling
- Convert continuous signal to a
discrete sequence
β« Use impulse train sampling
- π
π’ = π π’ π‘Ξπ π’ = π π’ π(π’ β πΞπ)
π
β« π π’ β πΞπ - impulse response at time π’ = πΞπ
- Sample value
β« π
π = π(πΞπ)
7
Fourier Transform of Sampled Signal
8
- πΊ
π = β± π π’ = πΊ π β π(π)
β« π π =
1 Ξπ π π β π Ξπ π
β« FT of impulse train is an impulse train
ο See section 4.2.3 in the book for details ο Note spacing between impulses are inversely related
- πΊ
π =
1 ΞT πΊ π β π Ξπ π
β« Sampling creates copies of the original spectrum β« Must be careful with sampling period to avoid aliasing (overlap of spectrum)
Sampling Theorem
- Conditions to be able to recover
π π’ completely after sampling
- Requires bandlimited π(π’)
β« πΊ π = 0 for |π| > πmax β« Can isolate center spectrum copy from its neighbors
- Sampling theorem
β«
1 Ξπ > 2πmax
ο Nyquist rate 2πmax
- Recovery with lowpass filter
β« πΌ π = Ξπ for π β€ πmax 9
Aliasing
- Corruption of recovered signal
if not sampled at rate less than Nyquist rate
β« Spectrum copies overlap β« High frequency components corrupt lower frequencies
- In reality this is always present
β« Most signals are not bandlimited β« Bandlimited signals require infinite time duration
ο Windowing to limit size naturally causes distortion
β« Use anti-aliasing filter before sampling
ο Filter reduces high frequency components 10
Discrete Fourier Transform
- Discussion has considered continuous signals (functions)
β« Need to operate on discrete signals
- DFT is a sampled version of the sampled signal FT in one
period
β« πΊ π = π
ππβπ2πππΞπ π
β« Sample in frequency evenly (π) over a period
ο π =
π πΞπ
β« πΊ
π = π ππβπ2πππ/π π
ο π = 0,1,2, β¦ , π β 1
β« π samples of π π’ , π
π , results in π DFT values
β« Note: implicitly assumes samples come from one period of periodic signal
- Inverse DFT
β« πΊ
π = 1 π
πΊ
πππ2πππ/π π
11
Sampling/Frequency Relationship
- π samples of signal with sample period Ξπ
β« Total time ο π = πΞπ
- Spacing in discrete frequency
β« Ξπ£ =
1 πΞπ = 1 π
ο Note the switch to π£ for discrete frequency
β« Total frequency range ο Ξ© = πΞπ£ =
1 Ξπ
- Resolution of DFT is dependent on the duration
π of the sampled function
β« Generally the number of samples
- See fft.m in Matlab to test this
12
Extensions to 2D
- All discussions can be extended to two variables
easily
β« Add second integral or summation for extra variable
- 2D rectangle
β« πΊ π, π = ATZ
sin πππ πππ sin πππ πππ
13
Image Aliasing
- Temporal aliasing appears in video
β« Wheel effect β looks like it is spinning opposite direction
- Spatial aliasing is the same as the previous
discussionο now in two dimensions
14
Image Interpolation and Resampling
- Used for image resizing
β« Zooming β oversample and image β« Shrinking β undersample an image
ο Must be careful of aliasing ο Generally smooth before downsample
15
Fourier Spectrum and Phase Angle
- πΊ π£, π€ = πΊ π£, π€ πππ π£,π€
β« Magnitude, spectrum
ο πΊ π£, π€ = π2 π£, π€ + π½2 π£, π€
1/2
β« Phase angle
ο πππ π£,π€ = arctan
π½ π£,π€ π π£,π€
- Spectrum is component we
naturally specify while phase is a bit harder to visualize
- Spectrum
16
Spectrum
- Translation does not affect
spectrum
β« Wide in space ο narrow in frequency
- Orientation clearly visible
in spectrum
17
Phase
- Difficult to describe phase given image content
β« a) centered rectangle β« b) translated rectangle β« c) rotated rectangle
18
Spectrum Phase Manipulation
- Both spectrum and phase are important for image
content
19
Frequency Domain Filtering Basics
- Generally complicated relationship between image and
transform
β« Frequency is associated with patterns of intensity variations in image
- Filtering modifies the image spectrum based on a
specific objective
β« Magnitude (spectrum) β most useful for visualization (e.g. match visual characteristics) β« Phase β generally not useful for visualization
20 45 degree lines Off center line
Fundamentals
- Modify FT of image and inverse for result
β« π π¦, π§ = β±β1[πΌ π£, π€ πΊ π£, π€ ]
ο π(π¦, π§) : output image [π Γ π] ο πΊ(π£, π€) : FT of input image π π¦, π§ [π Γ π] ο πΌ(π£, π€) : filter transfer function [π Γ π] ο β±β1 : inverse FT (iFT)
β« Product from element-wise array multiplication
21 Remove DC (0,0) term from πΊ(π£, π€)
Example Filters
22 Addition of small offset to retain DC component after HP
DFT Subtleties
- Multiplication in frequency is convolution in time
β« Must pad image since output is larger
ο Will pad π(π¦, π§) image but not β(π¦, π§) ο πΌ(π£, π€) designed and sized for padded πΊ(π£, π€)
β« DFT implicitly assumes a periodic function
23
Phase Angle
- Generally, a filter can affect the phase of a signal
- Zero-phase-shift filters have no effect on phase
β« Focus of this chapter
- Phase is very important to image
β« Small changes can lead to unexpected results
24
Frequency Domain Filtering Steps
1. Given image π(π¦, π§) of size π Γ π, get padding (π, π )
β« Typically use π = 2π and π = 2π
- 2. Form zero-padded image π
π(π¦, π§) of size π Γ π
- 3. Multiply π
π(π¦, π§) by β1 π¦+π§ to center the
transform
- 4. Compute DFT πΊ(π£, π€)
- 5. Compute π» π£, π€ = πΌ π£, π€ πΊ(π£, π€)
β« Get real, symmetric filter function πΌ(π£, π€) of size π Γ π with center at coordinates
π 2 , π 2
- 6. Obtain (padded) output image from iFT
β« ππ π¦, π§ = {real β±β1 π» π£, π€ β1 π¦+π§
- 7. Obtain π(π¦, π§) by extracting π Γ π region from top
left quadrant of ππ(π¦, π§)
25
Steps Example
26
Relationship to Spatial Filtering
- Frequency multiplication ο convolution in
spatial domain
β« β(π¦, π§) β πΌ(π£, π€) β« Use of a finite impulse response
- Generally use small filter kernels which are more
efficient to implement in spatial domain
- Frequency domain can be better for the design
- f filters
β« More natural space for definition β« Use iFT to determine the βshapeβ of the spatial filter
27
Smoothing
- High frequency image content comes from edges
and noise
- Smoothing/blurring is a lowpass operation that
attenuates (removes) high frequency content
- Consider three smoothing filters
β« Ideal lowpass β sharp filter β« Butterworth β filter order controls shape β« Gaussian β very smooth filter
28
Ideal Lowpass Filter
- πΌ π£, π€ = 1
πΈ π£, π€ β€ πΈ0 πΈ π£, π€ > πΈ0
β« πΈ π£, π€ = π£ β
π 2 2
+ π€ β
π 2 2
β« Pass all frequencies πΈ0 distance from DC
ο πΈ0 is the cuttoff frequency
29
Ideal Lowpass Example
30 blurring ringing
LP Spectrum View
31
Butterworth LP Filter
- πΌ π£, π€ =
1 1+ πΈ π£,π€ /πΈ0 2π
β« π β order of the filter (controls sharpness of transition) β« Cutoff generally specified as the 50% of max (D0 = 0.5)
32
Butterworth LP Example
- No ringing is visible because of
the gradual transition from high to low frequency in filter
β« May be visible in higher-
- rder filters (π > 2)
β« Trade-off frequency narrow main lobe with sidelobe height
33
Gaussian Lowpass Filter
- πΌ π£, π€ = πβπΈ2 π£,π€ /2π2
β« π β measure of spread
ο π = πΈ0 is the cutoff frequency
β« iFT is also a Gaussian
ο No ringing because of smooth function
β« A favorite filter for smoothing
34
Gaussian LP Example
- No ringing
- Not as much smoothing as
Butterworth 2
- Best for use when ringing is
unacceptable
- Butterworth better when tight
control of transition between high and low frequency is required
35
Sharpening
- Use a highpass filter
β« πΌπΌπ π£, π€ = 1 β πΌππ(π£, π€)
- Ideal
β« πΌ π£, π€ = 0 πΈ π£, π€ β€ πΈ0 1 πΈ π£, π€ > πΈ0
- Butterworth
β« πΌ π£, π€ =
1 1+ πΈ0/πΈ π£,π€
2π
- Gaussian
β« πΌ π£, π€ = πβπΈ2 π£,π€ /2π2
36
Highpass Examples
37 Same ringing artifacts as ideal lowpass
HP Spectrum View
38
Selective Filtering
- Bandpass/reject β operate on a ring in the
frequency spectrum
β« See Table 4.6 for definitions
- Notch filters β operate on specific regions in the
frequency spectrum
β« Move center of HP filter appropriately
39
Notch Examples
40
Notch Examples II
41
BP Spectrum View
42
Implementation Issues
- DFT is separable
β« Can compute first a 1D DFT over rows followed by the 1D DFT over columns β« Simplifies computations in 1D
- Practically use Fast Fourier Transform (FFT) to
computer all DFT
β« Computationally efficient algorithm that simplifies problem by halving sequence repeatedly β« Efficiency requires π and π (size of image) to be multiples of 2
43