Something very strange is happening. Im using imrect to get a user defined ROI from an image (taken from an axes on a GUIDE GUI).
axes(handles.axes4);
Orig=getimage(handles.axes4);
val=get(handles.checkbox13,'Value');
if val==1
position=getappdata(0,'pos');
rectangle('Position',position,'EdgeColor','y')
drawnow;
else
warndlg('Select a box around single object. Try to centre around the Object','Template Matching','modal')
h=imrect
position=wait(h);
setappdata(0,'pos',position);
position
delete(h)
end
Orig=double(imcrop(Orig,position));
For testing, I have the checkbox13 unchecked so the code executes the "else" part.
The warning dialog appears, the blue imrect feature appears and it does indeed create the cropped image.
However, if the checkbox13 is checked, their is an error that "position" is wrong.
To check this, I removed the semi colon for h=imrect & position in the else part of the loop and unchecked the checkbox so the code executed this part. This is what the output is in the command window
h =
0×0 imrect array with properties:
Deletable
position =
[]
This suggests that "position" hasn't been obtained yet the imcrop works correctly. not sure whats going on.
Thanks for any help. Jason