1

I am trying to make a circular roi with a specified R,but allowing to set the center and the position. I first thought of doing it with 'ginput' and later drawing the circle, but since I need to allow for interactive reposition, I switched to 'roi' creation (image.roi.circle).

However, for some reason, something happens with the Radius and it's never set as defined, or it allows interactive setting of the radius... I tried both with 'drawcircle' and 'draw' (predefining the roi), but none works for me as I want to. This is the code for '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)

And here the code for roi definition + draw():

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

In both cases, the first time I run it, it yields the warning, sets the Radius to the minimum, and the field 'Radius' of the roi is set to zero. However, if I run it again once the object has been created, what it does is to interactively allow the radius definition. (while in the permisions I only allow for moving it!).

Does anyone know what am I doing wrong or how can I get what I need? (thanks in advance)

Tamara
  • 21
  • 2

1 Answers1

0

The drawcircle function, requires the center coordinate of the circle.

You may use ginput for interactively getting the initial center position, then executing drawcircle with the selected center.

Here is a code sample:

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

Rotem
  • 30,366
  • 4
  • 32
  • 65