Computer Vision
Understanding & Implementing Shape Detection using Hough Transform with OpenCV & Python
Finding lanes and eyes in images with a few lines of Python code
--
Today we will learn how to detect lines and circles in an image, with the help of a technique called Hough transform.
What is Hough space?
Before we start applying Hough transform to images, we need to understand what a Hough space is, and we will learn that in the way of an example.
Parameter space
When we work with images, we can imagine the image being a 2d matrix over some x and y coordinates, under which a line could be described as y = mx + b
But in parameter space, which we will call Hough space, I can represent that same line as m
vs b
instead, so the characterization of a line on image space will be a single point at the position m-b
in Hough space.
But we have a problem though, with y = mx + b
, we cannot represent a vertical line, as the slope is infinite. So we need a better way parametrization, polar coordinates (rho and theta).
Hough space
- rho: describes the distance of the line from the origin
- theta: describes the angle away from horizontal
One very important observation though, is what happens when we take multiple points around a line, and we transform into our Hough space.