File Exchange

image thumbnail

Circle Detection via Standard Hough Transform

version (2.21 KB) by Amin Sarafraz
Find circles with specific radius in a binary image via Standard Hough Transform.


Updated 31 Aug 2012

View License

Function uses Standard Hough Transform to detect circles in a binary image.
According to the Hough Transform for circles, each pixel in image space
corresponds to a circle in Hough space and vise versa.
upper left corner of image is the origin of coordinate system.

Example :
[y0detect,x0detect,Accumulator] = houghcircle(Imbinary,r,thresh)

Comments and Ratings (22)


YIBO (view profile)

Amin Sarafraz

all the reported bugs are fixed, please let me know if you find any other bug. Thanks. and check out the software section on the Computer Vision Online ( for more open source software related to image processing and computer vision


Mr Smart


David (view profile)

The performance is sensitive to the pre-defined radius.

varadha raj

It's nice to read

smitha deepu

pls send me the mat lab coding for creation of bounding box using regionprops.

Georg Wiora

Hardly appliable to real problems, because you need to know the exact radius of the circle you are looking for.

he yi

do the fair good work.

ahmed ahmed

zainal muttaqin

i want to know algorithm for image processing, now iam starting to experiment

Jamal Joder


Big Huy

mcs swami

Dennis Bush

If you can let the user set the range of radius, it would be better.

Peter Bone

apart from the speed-up of only looking over the range where the sqrt is real, you can also remove the repeated calculations for y01 and y02.

yOffset = sqrt(r^2-(xIndex(cnt)-x0)^2);
y01 = yIndex(cnt) - yOffset;
y02 = yIndex(cnt) + yOffset;

Also, take the r^2 and image size calculations out of the for loop. They only need to be claculated once.

Joseph Nguyen

Does not work at all

anish l

CJ Taylor

You should replace your inner loop to look only over the range of value for which your sqrt is real. This will noticably speed up your routine.

if (low<1) low=1; end
if (high>size(Imbinary,2)) high=size(Imbinary,2); end
for x0 = low:high
y01 = y-sqrt(r^2-(x-x0)^2);
y02 = y+sqrt(r^2-(x-x0)^2);
y01 = round(y01); y02 = round(y02);
if y01 < size(Imbinary,1) & y01 >= 1
Accumulator(y01,x0) = Accumulator(y01,x0)+1;
if y02 < size(Imbinary,1) & y02 >= 1
Accumulator(y02,x0) = Accumulator(y02,x0)+1;

Mirko Beccaria

Semplice e ben fatto,magari andrebbero aggiunte alcune note per spiegare meglio il programma.Comunque complimenti


Implemented suggestion by Peter Bone/ Better documentation

Modified version,faster and better performance

MATLAB Release Compatibility
Created with R13
Compatible with any release
Platform Compatibility
Windows macOS Linux

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Learn About Live Editor