File Exchange

image thumbnail

Circle Finder

version (116 KB) by Brett Shoelson
Interactive app and function to find circles in an image.


Updated 01 Sep 2016

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

In R2012a, we introduce CIRCULAR HOUGH TRANSFORMS for detecting circles in images. There are several parameters which can be manipulated to enhance the performance of the IMFINDCIRCLES functionality. This app provides an interactive environment for changing parameters and options, and for visualizing immediately the effects of the calculation.
circleFinder launches the GUI environment with the default image ('coins.png') pre-loaded.
circleFinder(inputImage) sllows user to specify input image, or the name of an input image.
inputImage can be any valid image format readable by IMREAD. Color (RGB) images are supported, but circle detection is performed on the RGB2GRAY representation.

(See help for IMFINDCIRCLES for details.)

NOTE: This function and app are verified for R2014b readiness, and are intended as REPLACEMENTS FOR FindCirclesGUI.

A VIDEO TUTORIAL explaining the use of this app can be accessed here:

Comments/suggestions welcome.

Comments and Ratings (17)

This helped me out, choosing your background carefully improves the results dramatically. I was trying to find the heads of pins and using a mostly black background resulted in a 90% success rate.

shahzeb ali

eye iris is not detected properly please tell any other solution

unfortunately, this could not determine the circles im using...

Towards the bottom right of the tool, you'll see a button labeled "Export/Save Results". If you tune the parameters for a sample images and then export, you will see in your MATLAB Command Window the equivalent code to reproduce the results. You should be able to copy and paste that code into a function and apply it to multiple files (in a for loop or parfor loop) pretty easily.

I find it very useful in droplet microfluidics. However, as I am very new to MATLAB, I cannot use it to the full. Is it the right place to ask for tips?
I can detect circles (i.e droplets) in a single image with a number of objects. However, I would like to do this to extract information from the sequence of images picturing moving droplets, one by one. Is it possible to do this in an easy manner?

Yanyan Liu

Thanks a lot! This is very important to my process

Thanks for the rating--your approach to processing large images is clever. And if you're not aware of it, the |blockproc| function facilitates exactly such interactions. Once you have a function handle (as returned by my app), you can read and process arbitrarily large images a chunk at a time!

Thank you for providing this GUI, I have used it a lot!
It could not process my images with size 20.000*20.000, but by adding a loop that goes through the image in (overlapping) sections it is possible. Double counts are cleared in a second step. In this way you also have a process bar and you save memory.

Thanks for the suggestions. If you click the "Export" button, one of the things exported is a "results" image. Alternatively, you can simply write:


As for the red-until-done, how long are your processes taking? Typically, it's pretty fast.


Much better than trying different parameters by hand. It would be nice to be able to save an image of what I see once I've found the circles and their radii. Also, changing the color of the Process Now button to red until it was done would help to recognize when the processing is complete.

Kyle Morris

With a 4096 x 4096 image, searching with two-stage (sensitivity 0.3), over 10 - 50 px, 'tic' and 'toc' report a calculation time of 95 seconds.

I appreciate that this image size and search parameters are probably pushing 'imfindcircles' beyond its intended design and reliability so the time is not a problem, I'm actually quite impressed, just curious if the accumulator progress can be reported on.

Kyle, thanks for the rating. A waitbar is not really practical in this case--there's no for loop. Just an accumulator that runs until it's done. (How long are your calculations taking, though?)

Kyle Morris

Great implementation. Is there any way to indicate the Hough transforms progress with a 'waitbar' for instance?


Updated license

Modifying description to include link to instructional YouTube video.

I think I still had some incompatibilities with newer (R14b+) MATLABs. This should fix them.

Verified for R2014b readiness. I think it should still work in previous versions.

Fixed a problem with underscores in image names, and with loading subsequent images.

Incorporates a missing file that disallowed loading new images. Also fixes a problem with underscores in image titles.

Now defaults to "process immediately" = false. Also, takes optional input argument specifying initial radius range. A few minor bug fixes, better expandAxes behavior, better image import behavior.

Updated to include an App file for R2012b.

Steered to correct files.

Adding copyright.

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