'drawcircle' 和 'roi.cricle' 不尊重预设半径

问题描述

我正在尝试使用指定的 R 制作圆形 roi,但允许设置中心和位置。我首先想到用 'ginput' 来做,然后再画圆,但由于我需要允许交互式重新定位,所以我切换到了 'roi' 创建(image.roi.circle)。

然而,由于某种原因,半径发生了一些事情,它从未按定义设置,或者它允许半径的交互式设置......我尝试了“drawcircle”和“draw”(预定义roi),但是没有一个像我想要的那样适合我。 这是'drawcircle'的代码

figure    
imagesc(background);
    drawncircle = drawcircle('InteractionsAllowed','translate','Radius',6,'linewidth',1.5);
    Warning: The ROI was not fully defined. 'Radius' will be ignored and interactive placement will begin. 
    > In drawcircle (line 187)

这里是 roi 定义 + draw() 的代码

figure
imagesc(background);
drawnroi = images.roi.Circle('InteractionsAllowed',1.5);
draw(drawnroi);

在这两种情况下,我第一次运行它时都会产生警告,将半径设置为最小值,并且将 roi 的字段“半径”设置为零。 但是,如果我在创建对象后再次运行它,它所做的就是以交互方式允许半径定义。 (虽然在权限中我只允许移动它!)。

有谁知道我做错了什么或者我怎样才能得到我需要的东西? (提前致谢)

解决方法

drawcircle 函数,需要圆心坐标。

您可以使用 ginput 以交互方式获取初始中心位置,然后使用选定的中心执行 drawcircle

这是一个代码示例:

background = zeros(32,64,'uint8'); % Create sample background

figure
imagesc(background);
axis image % Use axis image,for setting aspect ratio to 1:1

% Get the initial center position from the user
[x,y] = ginput(1);

% Draw a cicle,and allow the user to change the position
drawncircle = drawcircle('Center',[x,y],'InteractionsAllowed','translate','Radius',6,'LineWidth',1.5);

enter image description here