matlab之viscircles()函数

函数功能:画圆

语法:

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

 描述:

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

viscircles(centers,radii) 将具有指定中心和半径的圆绘制到当前轴上。

 举例:

1.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 red lines around the edges of the bright circles.

在明亮的圆圈边缘画一条红线。

viscircles(centersBright, radiiBright,'Color','r');

draw red dashed lines around the edges of the dark circles.

围绕暗圆的边缘绘制红色虚线。

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

 

 

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

viscircles(ax,centers,radii) 把圆画到指定的轴上。

举例:

the viscircles function does not clear the target axes before plotting circles. to remove circles that have been previously plotted in an axes, use the cla function. to illustrate, this example creates a new figure and then loops, drawing a set of circles with each iteration, clearing the axes each time.

在绘制圆之前,viscircles不去除目标轴。若要删除以前在轴中绘制的圆圈,请使用CLA函数。为了举例说明,这个示例创建一个新的图形,然后循环,用每次迭代绘制一组圆圈,每次清除轴。

figure
colors = {'b','r','g','y','k'}; %

for k = 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

    % Fix the axis limits.
    xlim([-0.1 1.1])
    ylim([-0.1 1.1])

    % Set the axis aspect ratio to 1:1.
    axis square

    % Set a title.
    title(['k = ' num2str(k)])

    % Display the circles.
    viscircles(centers,radii,'Color',colors{k});

    % Pause for 1 second.
    pause(1)
end

 

 

 

 

 

 

 

 

 

https://ww2.mathworks.cn/help/images/ref/viscircles.html

posted on 2019-06-12 09:33  一杯明月  阅读(5835)  评论(0编辑  收藏  举报