You are here : matlabImage Processingimfindcircles

imfindcircles() - Image Processing

centers = imfindcircles(A,radius) finds
the circles in image A whose radii are approximately
equal to radius. The output, centers,
is a two-column matrix containing the x,y coordinates
of the circles centers in the image.[centers,radii]
= imfindcircles(A,radiusRange) finds
circles with radii in the range specified by radiusRange.
The additional output argument, radii, contains
the estimated radii corresponding to each circle center in centers.example[centers,radii,metric]
= imfindcircles(A,radiusRange) also
returns a column vector, metric, containing the
magnitudes of the accumulator array peaks for each circle (in descending
order). The rows of centers and radii correspond
to the rows of metric.example[centers,radii,metric]
= imfindcircles(___,Name,Value) specifies
additional options with one or more Name,Value pair
arguments,  using any of the previous syntaxes.Code Generation support:
Yes.MATLAB® Function Block support: No.


Syntax

centers = imfindcircles(A,radius)[centers,radii]
= imfindcircles(A,radiusRange)[centers,radii,metric]
= imfindcircles(A,radiusRange) example[centers,radii,metric]
= imfindcircles(___,Name,Value) example


Example

Detection of Five Strongest Circles in an ImageRead the image into the workspace and display it.A = imread('coins.png');
imshow(A)
Find all the circles with radius r such
that 15 ≤ r ≤
30.[centers, radii, metric] = imfindcircles(A,[15 30]);
Retain the five strongest circles according to the metric
values.centersStrong5 = centers(1:5,:);
radiiStrong5 = radii(1:5);
metricStrong5 = metric(1:5);Draw the five strongest circle perimeters.viscircles(centersStrong5, radiiStrong5,'EdgeColor','b');
Detection of Bright and Dark Circles in an ImageRead the image into the workspace and display it.A = imread('circlesBrightDark.png');
imshow(A)

Define the radius range.Rmin = 30;
Rmax = 65;
Find all the bright circles in the image within the radius
range.[centersBright, radiiBright] = imfindcircles(A,[Rmin Rmax],'ObjectPolarity','bright');
Find all the dark circles in the image within the radius
range.[centersDark, radiiDark] = imfindcircles(A,[Rmin Rmax],'ObjectPolarity','dark');
Plot bright circles in blue.viscircles(centersBright, radiiBright,'EdgeColor','b');
 Plot dark circles in dashed red boundaries.viscircles(centersDark, radiiDark,'LineStyle','--');


Output / Return Value


Limitations


Alternatives / See Also


Reference