Finding lanes and eyes in images with a few lines of Python code

Posted May 26, 2020

Featured Image

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

Parameter space

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.

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

#opencv #python

Implementing Shape Detection using Hough Transform with OpenCV & Python
12.05 GEEK