Top Banner
Image Processing Workshop Session 2 – Hough Transformation Ashay Tejwani
23

Session 2 – Hough Transformation Ashay Tejwani. Video Processing In the last session we saw that an image can be represented by an array of RGB values.

Jan 17, 2016

Download

Documents

Holly Wilkins
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Session 2 – Hough Transformation Ashay Tejwani. Video Processing In the last session we saw that an image can be represented by an array of RGB values.

Image Processing Workshop

Session 2 – Hough TransformationAshay Tejwani

Page 2: Session 2 – Hough Transformation Ashay Tejwani. Video Processing In the last session we saw that an image can be represented by an array of RGB values.

Video ProcessingIn the last session we saw that an image can

be represented by an array of RGB values.

In video processing we:Break down the video into separate framesExtract each image as an arraySimply apply the relevant image processing

techniques.

Page 3: Session 2 – Hough Transformation Ashay Tejwani. Video Processing In the last session we saw that an image can be represented by an array of RGB values.

Hough Transform

Page 4: Session 2 – Hough Transformation Ashay Tejwani. Video Processing In the last session we saw that an image can be represented by an array of RGB values.

Why do we need it?Consider assessing this image:

Page 5: Session 2 – Hough Transformation Ashay Tejwani. Video Processing In the last session we saw that an image can be represented by an array of RGB values.

So what does it do?Useful for detecting Parametric curves (such

as lines, circles, conics).Relatively unaffected by:

GapsNoise

Page 6: Session 2 – Hough Transformation Ashay Tejwani. Video Processing In the last session we saw that an image can be represented by an array of RGB values.

How does it Work?The theory behind Hough Transform

Page 7: Session 2 – Hough Transformation Ashay Tejwani. Video Processing In the last session we saw that an image can be represented by an array of RGB values.

An ExampleUsing Edge Detection Algorithm

1 2

4

5

3

Page 8: Session 2 – Hough Transformation Ashay Tejwani. Video Processing In the last session we saw that an image can be represented by an array of RGB values.

An ExampleLet us consider a coordinate system

1 2

4

5

3

X

Y

Page 9: Session 2 – Hough Transformation Ashay Tejwani. Video Processing In the last session we saw that an image can be represented by an array of RGB values.

Represent all lines in terms of R and Theta

Convention

4

5

X

Y1 2

3

Page 10: Session 2 – Hough Transformation Ashay Tejwani. Video Processing In the last session we saw that an image can be represented by an array of RGB values.

ProcedureSelect one point at

a time, and consider all the combinations of R and Theta for which the line would pass through the given point.

4

5

X

Y1 2

3

Page 11: Session 2 – Hough Transformation Ashay Tejwani. Video Processing In the last session we saw that an image can be represented by an array of RGB values.

LimitsBefore we start off, we

need to set a limit to the max and min values of R and Theta.

Min R=0,Max R= image diagonal

Min Theta=-90Max Theta=+904

5

X

Y1 2

3

(142,142)

(0,100)

Page 12: Session 2 – Hough Transformation Ashay Tejwani. Video Processing In the last session we saw that an image can be represented by an array of RGB values.

An ExampleR=Xcos(Θ) + Y

sin(Θ)

For point 1, all lines will have R=0

4

5

X

Y1 2

3

(142,142)

(0,100)

Page 13: Session 2 – Hough Transformation Ashay Tejwani. Video Processing In the last session we saw that an image can be represented by an array of RGB values.

An ExampleFor Point 2,

R=100, Theta=0R=70.7, Theta=45

For Point 3,R=100, Theta=90R=70.7, Theta=45

Plotting these in the 2-D array:

4

5

X

Y1 2

3

(142,142)

(0,100)

Page 14: Session 2 – Hough Transformation Ashay Tejwani. Video Processing In the last session we saw that an image can be represented by an array of RGB values.

Plotting acceptable R- Θ pairs

R

The t a

Rmax

ThetamaxThetamin

Rmin

Page 15: Session 2 – Hough Transformation Ashay Tejwani. Video Processing In the last session we saw that an image can be represented by an array of RGB values.

ResultThe points of intersection of these plots give

us a value of R and Θ. These R and Θ represent the lines passing

through the two points.

Page 16: Session 2 – Hough Transformation Ashay Tejwani. Video Processing In the last session we saw that an image can be represented by an array of RGB values.

How to Code this?Open CV style

Page 17: Session 2 – Hough Transformation Ashay Tejwani. Video Processing In the last session we saw that an image can be represented by an array of RGB values.

The logic- Voting!We create a 2-D matrix of all possible R and

Θ values.For each edge point you detect, consider all

the valid values of R and Θ.Increment the element of the array by 1 each

time it is valid for a point – Each point ‘votes’ for a valid line.

Page 18: Session 2 – Hough Transformation Ashay Tejwani. Video Processing In the last session we saw that an image can be represented by an array of RGB values.

Which is equivalent to converting this into a matrix

R

The t a

Rmax

ThetamaxThetamin

Rmin

Page 19: Session 2 – Hough Transformation Ashay Tejwani. Video Processing In the last session we saw that an image can be represented by an array of RGB values.

This matrix represents Hough SpaceTheta

R

0 0 0 0 0 0 0 0 0 0

0 0 0 0 0 0 0 1 1 1

0 0 0 0 0 0 1 0 0 0

0 0 0 0 0 1 0 0 0 0

2 1 1 1 2 1 1 1 1 2

0 1 0 1 0 0 0 0 1 0

0 0 2 0 0 0 0 1 0 0

1 1 0 1 0 0 1 0 0 0

0 0 0 0 1 1 0 0 0 0

Page 20: Session 2 – Hough Transformation Ashay Tejwani. Video Processing In the last session we saw that an image can be represented by an array of RGB values.

ResultFrom this array, we find all local Maxima.These correspond to the pair of R- Θ of lines

which pass through the given group of points.

Page 21: Session 2 – Hough Transformation Ashay Tejwani. Video Processing In the last session we saw that an image can be represented by an array of RGB values.

AlgorithmFor all X{

For all Y{ if(edge point at (x,y)){ for all theta{

R= x*cos(theta) + y*sin(theta);increment one to the cell in the matrix

corresponding to R, theta.End all loops

Page 22: Session 2 – Hough Transformation Ashay Tejwani. Video Processing In the last session we saw that an image can be represented by an array of RGB values.

Practical usage

Page 23: Session 2 – Hough Transformation Ashay Tejwani. Video Processing In the last session we saw that an image can be represented by an array of RGB values.

Thank you