Algorithms - University of Michigan

advertisement
EECS 373
Design of Microprocessor-Based Systems
Farhan Hormasji
Matthew Diffenderfer
University of Michigan
Efficient Algorithms
November 27, 2012
1
Outline
• Overview
• DFT algorithms
–
–
–
–
FFT
Cooley–Tukey FFT
Bluestein's FFT
Goertzel
• Edge Detection Algorithms
–
–
–
–
Canny
Sobel
Prewitt
Roberts Cross
• Questions
2
Algorithms
What to look for:
• Usefulness
• Methodology
• Implementation
Tradeoffs:
• Cost
• Code Size
• Runtime
• Availability
3
Outline
• Overview
• DFT algorithms
–
–
–
–
FFT
Cooley–Tukey FFT
Bluestein's FFT
Goertzel
• Edge Detection Algorithms
–
–
–
–
Canny
Sobel
Prewitt
Roberts Cross
• Questions
4
Discrete Fourier Transform (DFT):
Overview
• What?
– Converts a sampled function from time domain to
frequency domain
• Use?
– DFTs reveal periodicities in input data as well as the
relative strengths of any periodic components
5
Discrete Fourier Transform (DFT):
Mathematical Interpretation
6
Discrete Fourier Transform (DFT):
Applications
• Spectral Analysis
– Most signals are sinusoidal
– DFT tells you frequency, phase, and amplitude
components
• Frequency Response of Systems
– All input and output signals can be represented as
cosine waves
– By observing change in magnitude and phase, any linear
system can be described
• Convolution in the Frequency Domain
– Convolution in time domain is multiplication in
frequency domain
– Speed of computation greatly reduced
7
Fast Fourier Transform (FFT):
Overview
• What?
– An efficient algorithm to compute the DFT and its
inverse
• Why use it?
– O(Nlog2N)
• Tradeoff
– Input data must be a power of 2
– If it’s not, data is either truncated or padded with
zeros
• Many different types
8
FFT: Cooley-Tukey algorithm
• Most common FFT algorithm
– Divide and conquer algorithm
• Methodology
– Breaks up DFT of N samples into N=N1N2
• Benefit
– Can be combined with any other DFT algorithm
– What Matlab fft function does for optimization
9
FFT: Cooley-Tukey algorithm
Methodology
10
Fast Fourier Transform (FFT): Bluestein
• Also called chirp z-transform algorithm
• Methodology
– Expresses DFT as a convolution
• Benefit
– Computes DFT of arbitrary sizes
– Can be used to compute more general transforms
• Tradeoff
– Only O(Nlog2N) complexity for prime-sized DFTs
11
Fast Fourier Transform (FFT): Bluestein
Methodology
12
Goertzel Algorithm
13
Goertzel Algorithm
• Tradeoff
– O(NM)
– N is number of DFT terms, M is the set of DFT terms to
calculate
• Benefit
– Simple structure of algorithm makes it well suited to
small processors
– More efficient than FFT for small number of
frequencies ( if M < log2N)
• Applications
– Used to recognize DTMF tones produced by buttons on
telephone keypad
– Call progress (dial tone, busy)
14
Runtime Performance Comparison
15
Runtime Performance Comparison:
Matlab
16
Outline
• Overview
• DFT algorithms
–
–
–
–
FFT
Cooley–Tukey FFT
Bluestein's FFT
Goertzel
• Edge Detection Algorithms
–
–
–
–
Canny
Sobel
Prewitt
Roberts Cross
• Questions
17
Edge Detection
Overview
• Use
– Tool used in image processing
– Goal is to identify points in a digital image where
image brightness changes sharply or has discontinuities
– Reduce amount of data in image so that further image
processing may occur
– Reduce images to shapes
• Applications
– Most image processing
18
Edge Detection: Canny
• Use
– Optimal edge detection
• the algorithm should mark as many real edges in the image as
possible
• edges marked should be as close as possible to the edge in the
real image
• a given edge in the image should only be marked once
• image noise should not create false edges
• Benefits
– Adaptable to most images
– Generally has short runtime, well-suited for real time
implementations in FPGAs
• Constraints
– Size of Gaussian filter
– Calibration of thresholds
19
Edge Detection: Canny
Methodology
• Convolves image with Gaussian filter
– To eliminate noise
• Uses other types of edge detection to determine
intensity gradient vertically, horizontally, and
diagonally
– 4 filters
• Goes through matrix to determine if gradient
magnitude is a local maximum based on gradient
direction
– Determine high and low threshold
• Go through image and mark pixel as edge or nonedge based on thresholds
20
Edge Detection: Sobel
• Use
– Discrete differentiation operator
– Computes the gradient of the image intensity
• Benefits
– Few number of computations
– Can be implemented simply in both hardware and
software
• Tradeoffs
– Poor gradient approximation for high frequency
variations in image
21
Edge Detection: Sobel
Methodology
• 2 kernels convolved with original image to
calculate gradient in vertical and horizontal
direction
– Where A is the original image
• Compare gradient value to threshold similar to
Canny algorithm
22
Edge Detection: Prewitt
• Same as Sobel algorithm but with two key
differences
• The two kernels used have slightly different
values
• Magnitude and Direction of gradient in Sobel:
• Magnitude and Direction of gradient in Prewitt:
23
Edge Detection: Roberts Cross
• Use
– One of the first edge detectors
– Intensity of edges should correspond as close as
possible to what a human would perceive
• Benefits
– Only finds gradient in diagonal direction due to simple
kernels, so algorithm has high simplicity
• Tradeoffs
– Speed of modern computers make this simplicity
negligable
– Edge detection suffers from sensitivity to noise
24
Edge Detection: Roberts Cross
Methodology
• 2 kernels convolved with original image to
calculate gradient in diagonal direction
• Magnitude and direction of gradient found
similar to Sobal
• Compare gradient value to threshold similar to
Canny algorithm
25
Block M
26
Canny
27
Sobel
28
Prewitt
29
Roberts Cross
30
Edge Pixels Detected: Block M
31
Prabal
32
Canny
33
Sobel
34
Prewitt
35
Roberts Cross
36
Edge Pixels Detected: Prabal
37
Blur
38
Canny
39
Sobel
40
Prewitt
41
Roberts Cross
42
Edge Pixels Detected: Blur
43
Gray
44
Canny
45
Sobel
46
Prewitt
47
Roberts Cross
48
Edge Pixels Detected: Grayscale
49
Final Comparison
50
Questions?
Comments?
Discussion?
51
References
• Everything
–
–
Wikipedia
Mathworks
• DFT/FFT
–
–
–
The Scientist and Engineer's Guide to Digital Signal Processing By Steven W. Smith, Ph.D.
http://www.robots.ox.ac.uk/~sjrob/Teaching/SP/l7.pdf
http://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/OWENS/LECT4/node3.html
• Goertzel
–
http://www.numerix-dsp.com/goertzel.html
• Edge Detection
–
–
http://dasl.mem.drexel.edu/alumni/bGreen/www.pages.drexel.edu/_weg22/can_tut.ht
ml
http://www.cse.unr.edu/~bebis/CS791E/Notes/EdgeDetection.pdf
• Edge Detection Images
–
–
–
–
Prabal: web.eecs.umich.edu/~prabal/
Block M: www.umich.edu
Grayscale: www.colorsimulator.com
Blur: www.dreamstime.com (Royalty Free Stock Photos)
52
Download