viscircles

Create circle

Syntax

  • viscircles(centers,radii) example
  • viscircles(ax,centers,radii)
  • h = viscircles(ax,centers,radii)
  • h = viscircles(___,Name,Value) example

Description

example

viscircles(centers,radii) draws circles with specified centers and radii onto the current axes.

viscircles(ax,centers,radii) draws circles onto the axes specified by ax.

h = viscircles(ax,centers,radii) draws circles and returns a handle to the circles created. This handle is an hggroup object that is a child of the axes object, ax.

example

h = viscircles(___,Name,Value) specifies additional options with one or more Name,Value pair arguments, using any of the previous syntaxes. Parameter names can be abbreviated.

Examples

expand all

Draw Lines Around Bright and Dark Circles in Image

This example shows how to draw lines around both bight and dark circles in an image.

Read 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');

Draw blue lines around the edges of the bright circles.

viscircles(centersBright, radiiBright,'EdgeColor','b');

Draw red dashed lines around the edges of the dark cirles.

viscircles(centersDark, radiiDark,'LineStyle','--');

Input Arguments

expand all

centers — Coordinates of circle centerstwo-column matrix

Coordinates of circle centers, specified as a P-by-2 matrix, such as that obtained from imfindcircles. The x-coordinates of the circle centers are in the first column and the y-coordinates are in the second column. The coordinates can be integers (of any numeric type) or floating-point values (of type double or single).

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

radii — Circle radiicolumn vector

Circle radii, specified as a column vector such as that returned by imfindcircles. The radius value at radii(j) corresponds to the circle with center coordinates centers(j,:). The values of radii can be nonnegative integers (of any numeric type) or floating-point values (of type double or single).

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

ax — Axes in which to draw circleshandle

Axes in which to draw circles, specified as a handle object returned by gca or axes.

Data Types: double

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'EdgeColor','b' specifies blue circle edges, using the short name for blue.

'DrawBackgroundCircle' — Logical flag that controls the drawing of the contrasting background circle‘true' (default) | ‘false'

Logical flag that controls the drawing of the contrasting background circle, specified as a logical value true or false. If you set the value to true, viscircles draws the contrasting background circle below the colored circle. If you set the value to false, viscircles does not draw the background circle.

Data Types: logical

'EdgeColor' — Color of circle edge‘red' (default) | [R G B] | short name | long name

Color of circle edges, specified as a MATLAB® ColorSpec value.

Example: 'EdgeColor','b' specifies blue circle edges.

'LineStyle' — Line style of circle edge'-' (default) | '--' | ':'

Line style of circle edge, specified as the comma-separated pair consisting of 'LineStyle' and any line specifier in the table below.

Specifier

Line Style

'-'

Solid line (default)

'--'

Dashed line

':'

Dotted line

'-.'

Dash-dot line

'none'

No line

Example: 'LineStyle','--' specifies a dashed line at each circle edge.

'LineWidth' — Width of circle edge2 (default) | double

Width of circle edge, specified a positive floating-point double value. Line width is expressed in points, where each point equals 1/72 of an inch.

Example: 'LineWidth',4 specifies a 4-point line width.

Output Arguments

expand all

h — Circles drawnHandle to an hggroup object

Circles drawn, returned as a handle to an hggroup object. This handle is a child of the axes object, ax.

Was this topic helpful?