Paul_Johno wrote:Hi all,
I'm using the circular hough transform (CHT) in MATLab to identify some circles within images. While I can get the CHT to work, I don't fully understand it, and I was hoping someone could explain it to me in laymans terms. I've had a hunt through Google and I still haven't gained a reasonable understanding.
This would be a massive help, thanks.
Are you familiar with the traditional Hough Transform? I'll explain that, and then you should be able to extend it to the circular transform.
The traditional HT is used for detecting lines. The way it does this is simple. Assume you have run an image through an edge detection algorithm, and you have a black/white image that contains all the edges. These edges make up a set of points/pixels.
The HT iterates through each point. At each point, it generates a set of lines passing through the pixel at different angles (0 to 180 degrees, with some pre-defined granularity). So at the point (x0,y0), the HT draws a line through (x0,y0) at (for 5 degree granularity) 0 degrees, 5 degrees, 10 degrees, etc. The angle is our value of \theta
. Store that for a moment.
Now, we have this line that we just drew at angle \theta
through (x0,y0). Draw a line perpendicular to this one that goes through the origin (it might not be in the image itself!). The distance between the origin and where this new line intersects is our value of r.
Make a table. We now have a value of \theta
that we selected, and a value of r
that we computed. Imagine that your table has \theta
as rows, and r as columns. When you encounter a (\theta
, r) pair, add a vote to that part of the table (ie, increment it by 1).
What happens is that any time you land on a pixel that makes a line with another pixel, that same (\theta
, r) gets voted up. So the cells in the table with the highest votes represent the longest lines.
Think about the line y=ax+b
. This line covers an infinite number of points in Cartesian (x,y) space. But in parameter space, it is uniquely defined by a single point: (a,b). Another way of saying this is that if I made a function:
- Code: Select all
y = a*x+b;
I could cover an infinite number of points just by specifying one single point in parameter space.
I'll try to draw you an image to make some sense of things.