image analysis for finding circles in a BW image, returns radii, locations and line thicknesses


Updated 24 Mar 2015

View License

Comprehensive suite for identifying circles in an image with a GUI front end. Primarily intended for identifying mircofluidic drops.
To try it out on two monodisperse drop images just run circle_finder from the command line within the downloaded directory. (The images are included)

GUI for finding circles in an image, and determining their radii (e.g. drops)
Image analysis involves three steps
1. Loading images from disc
2. Conditioning images to:
-enhance the circles and remove background
-if necessary resize such that the largest drop radius is smaller
than 255
-select sub-region for circle analysis by zooming and moving within
the enhanced output image (the one on the right!)
3. Selecting appropriate parameters for:
- the range of radii
- the range thicknesses of the circles' arcs
- the depth of the search in terms of either
-the merit, a number from 1 (best fit) to 0 (worst fit), or
-the number of found circles

Analyzing an image produces TWO additional figures
1. "outline" after hitting "outline" in the control GUI "circle_finder"
There are two panels:
-left: the conditioned image using a gaussian mask of given size in
conv2 to flatten the image and enhance contrast
-right: the BW image using a a given threshold
There are three types of GUI input:
-slider for the mask size is set (should be comparable to the line width)
-slider for the threshold value for turning the convolved output image into
a BW image suitable for circle finding
-edit field for imresize factor for reducing image size. The maximum circle radius
should be smaller than 255. Program works best and fastest for
range of radii between 10 and 40. Large numbers of circles can take
up to a minute to process.
To reduce the search use zooming and panning for the right panel
2. "data" after hitting "search" in the control GUI "circle_finder"
This figure has three panels:
-the original image with the centers marked according to the
quality of the fit. Worse fits are larger red markers, better
are smaller blue markers
-the dependence of merit on the order of found circles, using the
same color-coding scheme
-the histogram of the circle radii. This can be in pixels, or by
setting the calibration in units (see below)
There are three types of GUI input for post processing:
-popup menu for selecting graphic overlaid on the input image, which
can be marker, inner radius, middle radius, outer radius, thickness,
order, circles or nothing
-edit field for setting the calibration factor used in the histograms
-slider for decreasing the set of displayed circles, where the
worst fits are dropped
-pushbutton for exporting the data to the caller (typically the
workspace). The data is in the form of a structure with fields for
x, y, radius, thickness, merit sorted in the order of fitting
quality. Note the exported data is the same subset that is
displayed AND has the calibration factor if possible
see find_circles for more information

More user notes:
*The search time increases with the image size and the radius size
-initially zoom to a smaller region of the outline image, panning
is also possible
-reduce the image size using the GUI in the outline figure
-use generous circle thicknesses, which results in larger merit
values for the fits
*To validate measurements
-verify visually that most of the circles have been found, i.e. the
search is deep enough and has not been prematurely cancelled.
-reduce the depth of the search using the number slider, and verify
that the histograms are unchanged, i.e. eliminate systematic errors
due to finding algorithm
-the inner radius is less dependent on the thickness
*Closing the data figure also exports the data structure
*You can open several circle_finders at once, and operate each
*Changing the directory to one containing '*.jpg', '*.tif' or '*.bmp'
will process every file using default parameters in separate windows

tested & developed for MATLAB R2015a
3/23/15 Stephan Koehler,

Cite As

Stephan Koehler (2023). circle_finder (, MATLAB Central File Exchange. Retrieved .

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

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes