52
1 EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer University of Michigan Efficient Algorithms November 27, 2012

EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Embed Size (px)

DESCRIPTION

EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer University of Michigan Efficient Algorithms November 27, 2012. Outline. Overview DFT algorithms FFT Cooley–Tukey FFT Bluestein's FFT Goertzel Edge Detection Algorithms Canny Sobel Prewitt - PowerPoint PPT Presentation

Citation preview

Page 1: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

1

EECS 373Design of Microprocessor-Based Systems

Farhan HormasjiMatthew DiffenderferUniversity of Michigan

Efficient AlgorithmsNovember 27, 2012

Page 2: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

2

Outline

• Overview

• DFT algorithms– FFT– Cooley–Tukey FFT– Bluestein's FFT– Goertzel

• Edge Detection Algorithms– Canny– Sobel– Prewitt– Roberts Cross

• Questions

Page 3: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Algorithms

What to look for:• Usefulness• Methodology• Implementation

Tradeoffs:• Cost• Code Size• Runtime• Availability

3

Page 4: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

4

Outline

• Overview

• DFT algorithms– FFT– Cooley–Tukey FFT– Bluestein's FFT– Goertzel

• Edge Detection Algorithms– Canny– Sobel– Prewitt– Roberts Cross

• Questions

Page 5: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

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

Page 6: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Discrete Fourier Transform (DFT): Mathematical Interpretation

6

Page 7: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

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

Page 8: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

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

Page 9: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

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

Page 10: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

FFT: Cooley-Tukey algorithmMethodology

10

Page 11: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

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

Page 12: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Fast Fourier Transform (FFT): BluesteinMethodology

12

Page 13: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Goertzel Algorithm

13

Page 14: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

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

Page 15: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Runtime Performance Comparison

15

Page 16: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Runtime Performance Comparison:Matlab

16

Page 17: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

17

Outline

• Overview

• DFT algorithms– FFT– Cooley–Tukey FFT– Bluestein's FFT– Goertzel

• Edge Detection Algorithms– Canny– Sobel– Prewitt– Roberts Cross

• Questions

Page 18: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Edge DetectionOverview

• 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

Page 19: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

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

Page 20: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Edge Detection: CannyMethodology

• 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 non-edge based on thresholds

20

Page 21: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

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

Page 22: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Edge Detection: SobelMethodology

• 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

Page 23: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

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

Page 24: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

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

Page 25: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Edge Detection: Roberts CrossMethodology

• 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

Page 26: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Block M

26

Page 27: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Canny

27

Page 28: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Sobel

28

Page 29: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Prewitt

29

Page 30: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Roberts Cross

30

Page 31: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Edge Pixels Detected: Block M

31

Page 32: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Prabal

32

Page 33: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Canny

33

Page 34: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Sobel

34

Page 35: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Prewitt

35

Page 36: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Roberts Cross

36

Page 37: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Edge Pixels Detected: Prabal

37

Page 38: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Blur

38

Page 39: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Canny

39

Page 40: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Sobel

40

Page 41: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Prewitt

41

Page 42: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Roberts Cross

42

Page 43: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Edge Pixels Detected: Blur

43

Page 44: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Gray

44

Page 45: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Canny

45

Page 46: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Sobel

46

Page 47: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Prewitt

47

Page 48: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Roberts Cross

48

Page 49: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Edge Pixels Detected: Grayscale

49

Page 50: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

Final Comparison

50

Page 51: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

51

Questions?

Comments?

Discussion?

Page 52: EECS 373 Design of Microprocessor-Based Systems Farhan Hormasji Matthew Diffenderfer

52

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.html– 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)