主要内容

viscircles

创建圆圈

描述

example

Viscircles(centers,radii)draws circles with specifiedcentersandradii到电流轴上。

Viscircles(ax,centers,radii)draws circles onto the axes specified byax

Viscircles(___,姓名,Value)使用名称值对参数来指定圆的其他属性。

h= viscircles(___)returns a handle,h,到绘制的圆圈。

例子

collapse all

将图像读取到工作区中并显示。

a = imread('Circlesbrightdark.png'); imshow(A)

图包含一个轴对象。这轴object contains an object of type image.

Define the radius range.

rmin = 30;rmax = 65;

在半径范围内找到图像中的所有明亮圆圈。

[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','黑暗的');

Draw blue lines around the edges of the bright circles.

Viscircles(centersBright, radiiBright,'颜色','b');

图包含一个轴对象。这轴object contains 3 objects of type line, image.

在黑眼圈的边缘上画红色的虚线。

Vescircles(Radiidark Centersdark,'linestyle','--');

图包含一个轴对象。轴对象包含5个类型线的对象,图像。

viscircles函数在绘制圆圈之前不会清除目标轴。要删除以前已在轴上绘制的圆圈,请使用clafunction. To illustrate, this example creates a new figure and then loops, drawing a set of circles with each iteration, clearing the axes each time.

图颜色= {'b','r','G','y','K'};fork = 1:5% Create 5 random circles to display,X = rand(5,1); Y = rand(5,1); centers = [X Y]; radii = 0.1*rand(5,1);% Clear the axes.cla%固定轴极限。xlim([-0.1 1.1]) ylim([-0.1 1.1])% Set the axis aspect ratio to 1:1.正方形%设置标题。标题(['k = 'num2str(k)])%显示圆圈。Viscircles(centers,radii,'颜色',colors{k});% Pause for 1 second.pause(1)end

图包含一个轴对象。这轴object with title k = 5 contains 2 objects of type line.

Input Arguments

collapse all

圆心中心的坐标,指定为P-经过-2矩阵,例如从imfindcircles。这x- 圆心中心的坐标在第一列中,y- 坐标在第二列中。坐标可以是整数(任何数字类型)或浮点值(类型的浮点数)双倍的or单身的).

数据类型:单身的|双倍的|int8|INT16|INT32|INT64|UINT8|UINT16|UINT32|Uint64

圆半径,指定为列向量,例如返回imfindcircles。这radius value atradii(j)corresponds to the circle with center coordinatescenters(j,:)。值radiican be nonnegative integers (of any numeric type) or floating-point values (of type双倍的or单身的).

数据类型:单身的|双倍的|int8|INT16|INT32|INT64|UINT8|UINT16|UINT32|Uint64

Axes in which to draw circles, specified as a handle object returned byGCAor

数据类型:双倍的

姓名-Value Arguments

Specify optional pairs of arguments asname1 = value1,...,namen = valuen, 在哪里姓名is the argument name andValue是相应的值。名称值参数必须在其他参数之后出现,但是对的顺序并不重要。

在R2021a之前,请使用逗号分隔每个名称和值,并附上姓名用引号。

例子:voscircles(中心,半径,'颜色','b')指定蓝色圆边缘,使用蓝色的短颜色名称。

增强绘制的圆圈具有相反的功能以提高可见性,指定为逻辑值trueorfalse。If you set the value totrue, thenviscirclesdraws a contrasting circle below the colored circle.

数据类型:logical

Color of the boundary, specified as an RGB triplet, a hexadecimal color code, a color name, or a short color name.

For a custom color, specify an RGB triplet or a hexadecimal color code.

  • An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range[0,1];例如,[0.4 0.6 0.7]

  • 十六进制的颜色代码是字符向量或字符串标量,以哈希符号开头(#),然后是三个或六个十六进制的数字,范围从0F。这些值不敏感。因此,颜色代码'#FF8800','#ff8800','#F80', and'#f80'are equivalent.

Alternatively, you can specify some common colors by name. This table lists the named color options, the equivalent RGB triplets, and hexadecimal color codes.

Color Name 简称 RGB Triplet Hexadecimal Color Code Appearance
“红色” 'r' [10 0] '#FF0000'

颜色红色样品

'green' 'G' [0 1 0] '#00FF00'

颜色绿色样品

'蓝色的' 'b' [0 0 1] '#0000FF'

Sample of the color blue

'cyan' 'C' [0 1 1] '#00ffff'

颜色青色样品

'品红' 'M' [10 1] '#ff00ff'

Sample of the color magenta

'黄色' 'y' [11 0] '#FFFF00'

黄色样品

'黑色的' 'K' [0 0 0] '#000000'

Sample of the color black

“白色” 'w' [11 1] '#FFFFFF'

Sample of the color white

'none' Not applicable Not applicable Not applicable 没有颜色

这是RGB三胞胎和默认颜色的十六进制颜色代码matlab®在许多类型的图中使用。

RGB Triplet Hexadecimal Color Code Appearance
[0 0.4470 0.7410] '#0072BD'

RGB三重态样品[0 0.4470 0.7410],显示为深蓝色

[0.8500 0.3250 0.0980] '#D95319'

RGB三重态样品[0.8500 0.3250 0.0980],如深橙色

[0.9290 0.6940 0.1250] '#EDB120'

RGB三重态样品[0.9290 0.6940 0.1250],显示为深黄色

[0.4940 0.1840 0.5560] '#7E2F8E'

Sample of RGB triplet [0.4940 0.1840 0.5560], which appears as dark purple

[0.4660 0.6740 0.1880] '#77AC30'

Sample of RGB triplet [0.4660 0.6740 0.1880], which appears as medium green

[0.3010 0.7450 0.9330] '#4dbeee'

RGB三胞胎样品[0.3010 0.7450 0.9330],如浅蓝色

[0.6350 0.0780 0.1840] '#A2142F'

RGB三重态样品[0.6350 0.0780 0.1840],看起来为深红色

例子:voscircles(中心,半径,'颜色','r');

例子:Viscircles(centers,radii,'Color','green');

例子:voscircles(中心,半径,“颜色”,[0 0 1]);

例子:Viscircles(centers,radii,'Color','#FF8800');

Line style of circle edge, specified as the comma-separated pair consisting of'linestyle'以及下表中的任何行规范符。

Line Style 描述 结果线
“- - -” 实线

实线样品

'--' Dashed line

Sample of dashed line

':' Dotted line

Sample of dotted line

'-.' Dash-dotted line

仪表板点线样本,带有交替的破折号和点

'none' 没有行 没有行

圆边的宽度,指定一个正数。线宽度以点表示,每个点等于1/72英寸。

数据类型:双倍的

输出参数

collapse all

Circles drawn, returned as anhggroupobject.his the child of the axesaxif specified, otherwiseh是当前轴的孩子。

版本历史

Introduced in R2012a