2次元画像の中心に以​下のコードのような円​を描写したいのですが​、どうすればよいでし​ょうか?

%// radius
r = 2;
%// center
c = [3 3];
pos = [c-r 2*r 2*r];
rectangle('Position',pos,'Curvature',[1 1])
axis equal

 Respuesta aceptada

Kojiro Saito
Kojiro Saito el 24 de Mayo de 2022

2 votos

imshow で2 次元の画像表示をした後に、その座標軸(gca)に対してrectangle を実行すればできます。rectangle で画像の中心座標(width と height のそれぞれの半分)を指定します。
見やすくするために下記ではrを20にしています。
img = imread('peppers.png');
imshow(img)
r = 20;
%// center
c = [width(img)/2 height(img)/2];
pos = [c-r 2*r 2*r];
rectangle(gca, 'Position',pos,'Curvature',[1 1],'EdgeColor', 'r')

Más respuestas (0)

Categorías

Más información sobre イメージ en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 24 de Mayo de 2022

Respondida:

el 24 de Mayo de 2022

Community Treasure Hunt

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

Start Hunting!