Hough transform
![hough transform hough transform](https://sbme-tutorials.github.io/2019/cv/images/hough_space2.png)
image: 8-bit, single-channel binary source image.The function expects the following parameters:
![hough transform hough transform](https://miro.medium.com/max/2806/1*Y9ljU_--SdFe7on9W_axrA.png)
In OpenCV, line detection using Hough Transform is implemented in the functions HoughLines and HoughLinesP (Probabilistic Hough Transform). However we will take a look at an implementation of this algorithm, which is part of the OpenCV library. The algorithm for making the transformation happen and subsequently finding the intersecting curves is little bit complicated, and thus out of the scope of this post. In our line example, a Hough transform will be responsible for processing the dots on the image and calculating the values in Hough space. A “simple” shape will be only represented by a few parameters, for example a line can be represented by its slope and intercept, or a circle which can be represented by x, y and radius. The “simple” characteristic is derived by the shape representation in terms of parameters. Hough transform is a feature extraction method for detecting simple shapes such as circles, lines, etc in an image. One very important observation though, is what happens when we take multiple points around a line, and we transform into our Hough space.Ī single dot on image space translates to a curve on Hough space, with the particularity that points among a line on image space will be represented by multiple curves with a single touchpoint.Īnd this will be our target, finding the points where a group of curves intersects.
![hough transform hough transform](http://inf4300.olemarius.net/wp-content/uploads/2015/09/OMHR_solution_044.png)
So we need a better way parametrization, polar coordinates (rho and theta). 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īut 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.īut we have a problem though, with y = mx + b, we cannot represent a vertical line, as the slope is infinite.
#HOUGH TRANSFORM HOW TO#
Today we will learn how to detect lines and circles in an image, with the help of a technique called Hough transform.īefore 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.