0
我想从显示的图像中获取矩形坐标。我想要移动图像。这是我的matlab GUI。
如何不停止正确的Matlab GUI?
所以,当我按下它应该显示下一个图像的系列和类似的后退按钮。我使用此代码
function next_Callback(hObject, eventdata, handles)
% hObject handle to next (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if handles.mypointer~=length(handles.cur_images)
handles.mypointer=handles.mypointer+1;
pic=imread(fullfile('images',handles.cur_images(handles.mypointer).name));
handles.imageName=handles.cur_images(handles.mypointer).name;
imshow(pic);
h=imrect;
getMyPos(getPosition(h));
addNewPositionCallback(h,@(p) getMyPos(p));
fcn = makeConstrainToRectFcn('imrect',get(gca,'XLim'),get(gca,'YLim'));
setPositionConstraintFcn(h,fcn);
handles.output = hObject;
handles.posi=getPosition(h);
guidata(hObject, handles);
但这种代码的缺点是,当按下一个按钮则停在h=imrect
所以等待用户绘制矩形。它不做任何事,如果我不绘制一个矩形。即使我再次按下或下一个按钮,它什么都不做,因为它仍在等待用户绘制矩形。我很抱歉,如果这是一个明显的问题,但我是matlab GUI新手。
问:
如何不要让程序停止在Imrect
为“不正确”做一个单独的按钮... – excaza