Download presentation
Presentation is loading. Please wait.
1
Detecting Shape Using Hough Transform Session 8
Course : T Computer Vision Year : 2013 Detecting Shape Using Hough Transform Session 8
2
Learning Outcomes After carefully listening this lecture, students will be able to do the following: Explain how Hough Transforms are used to detect primitive shapes such as line and circle (LO2) Demonstrate HT-based line and circle detection using MATLAB/OpenCV (LO3) T Computer Vision
3
Line Detection Using Mask
The mask shown below can be used to detect lines at various orientation T Computer Vision
4
Hough Transform An algorithm to group edge points from edge detectors or from any other process. T Computer Vision
5
Straight Line Case Consider the slope-intercept equation of line:
y = ax + b a, b are constant, x is a variable, and y is a function of x Rewrite the equation as follows: b = -xa + y Now x, y are constant, a is a variable, b is a function of a T Computer Vision
6
Algorithm The following properties are true
Points lying on the same line in the x-y space, define lines in the parameter space which all intersect at the same point The coordinates of the point of intersection define the parameters of the line in the x-y space Algorithm For each edge point (x,y) for (a = amin; a ≤ amax; a++) b = -xa +y; P[a][b] ++;/*accumulator array*/ Find local maxima in P[a][b] T Computer Vision
7
T Computer Vision
8
Polar Representation of Lines
HT uses the parametric representation of a line: = x cos + y sin (*) is the distance from the origin to the line along a vector perpendicular to the line. is the angle between the x-axis and this vector. Hough function generates a parameter space matrix whose rows and columns correspond to and values respectively. Peak values in this space represent potential lines in the input image. T Computer Vision
9
Algorithm Construct accumulator array in 2D (,)
Initial values 0 Select granularity of angle For instance 10 increments For every edge point Compute using (*) Increment accumulator array by one for each computed (,) pair. T Computer Vision
10
T Computer Vision
11
Hough Lines HoughLines(dst, lines, 1, CV_PI/180, 100, 0, 0 ); for( size_t i = 0; i < lines.size(); i++ ) { float rho = lines[i][0], theta = lines[i][1]; Point pt1, pt2; double a = cos(theta), b = sin(theta); double x0 = a*rho, y0 = b*rho; pt1.x = cvRound(x *(-b)); pt1.y = cvRound(y *(a)); pt2.x = cvRound(x *(-b)); pt2.y = cvRound(y *(a)); line( cdst, pt1, pt2, Scalar(0,0,255), 3, CV_AA); } T Computer Vision
12
Hough Circle Transform
The Hough Circle Transform works in a roughly analogous way to the Hough Line Transform. In the line detection case, a line was defined by two parameters . In the circle case, we need three parameters to define a circle: /// Apply the Hough Transform to find the circles HoughCircles( src_gray, circles, CV_HOUGH_GRADIENT, 1, src_gray.rows/8, 200, 100, 0, 0 ); T Computer Vision
13
Latihan (Group, 50 menit) Jelaskan konsep dasar Hough Trasfrom
Buat program untuk mencari titik tengah untuk navigasi robot T Computer Vision
14
References Textbook Forsyth, D., Ponce, J. (2012). Computer Vision: A Modern Approach. 2nd ed. Prentice Hall. ISBN: Web Hough Transform T Computer Vision
15
T Computer Vision
16
THANK YOU T Computer Vision
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.