matlab - Circular ROI is not being drawn from input -


for reason, following code displays masked image roi @ 10,10 height , width 100,100. these initial values. seems image not update after getposition function. explain issue?

`i = imread('/users/imageuser/documents/pt300.tif'); h = imshow(i);   % define circular roi square bounding box x = 10; y = 10;  d1 = 100; d2 = 100;  e = imellipse(gca, [x y d1 d2]);   % roi can interactively moved/adjusted % not close figure window before createmask called  %%% these lines needed if move or resize roi    pos = getposition(e);    x = pos(1);    y = pos(2);    d1 = pos(3);    d2 = pos(4); %%%  bw = createmask(e,h);  pause;  imshow(bw);` 

you need put lines (note inverted order):

pause; bw = createmask(e,h); 

before calling getposition, otherwise new position not updated.

whole code:

clear clc close  = imread('coins.png'); h = imshow(i);   % define circular roi square bounding box x = 10; y = 10;  d1 = 100; d2 = 100;  e = imellipse(gca, [x y d1 d2]);  pause; bw = createmask(e,h);  % roi can interactively moved/adjusted % not close figure window before createmask called  %%% these lines needed if move or resize roi    pos = getposition(e)    x = pos(1);    y = pos(2);    d1 = pos(3);    d2 = pos(4); %%%  figure imshow(bw); 

sample output after dragging roi:

enter image description here

yay!

note: mentioned juicestain, instead of using pause halt execution of program while user done creating gui, can use wait wait until user double-clicks on roi object instead of having press key pause command.

therefore, replace call pause call wait(e).


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -