I was trying to use imfreehand function in Matlab to create multiply ROI. After the users choose enough ROI they need, they can stop it by hit the ESC key. Here is my code but it has an error on it.
Error: Expected one output from a curly brace or dot indexing expression, but there were 0 results.
Can someone help me and point out the problem? The code is modified from here
Draw multiple regions on an image- imfreehand
Thanks
I = imread('pout.tif');
totMask = zeros(size(I)); % accumulate all single object masks to this one
f = figure('CurrentCharacter','a');
imshow(I)
h = imfreehand( gca ); setColor(h,'green');
position = wait( h );
BW = createMask( h );
while double(get(f,'CurrentCharacter'))~=27
totMask = totMask | BW; % add mask to global mask
% ask user for another mask
h = imfreehand( gca ); setColor(h,'green');
position = wait( h );
BW = createMask( h );
pause(.1)
end
% show the resulting mask
figure; imshow( totMask ); title('multi-object mask');