我正在使用 slider 显示图像元胞数组中的新图像。基本上,如果 slider 的值为“i”,则 slider 的回调函数会显示元胞数组中的第 i 个图像。
在该回调函数中,我试图让用户使用鼠标选择一个矩形。 MATLAB getrect()方法用于执行此操作 - 它在回调中不起作用:
Reference to a cleared variable GETRECT_H1.
Error in getrect (line 121)
elseif (~ishghandle(GETRECT_H1) || ...
Error in faceSliderGUI/slider_callback (line 23)
rect = getrect(gca);
Error using waitfor
Error while evaluating uicontrol Callback
Reference to a cleared variable GETRECT_H1.
回调函数如下图:
%# Callback function
function slider_callback(hObj, eventdata)
value = round(get(hObj,'Value'));
imageHandle = imshow(image_series{value});
ah = get( imageHandle, 'Parent' );
rect = getrect(ah); %let user draw a rectangle with mouse
set(hTxt, 'String',num2str(value)) %# update text
end
最佳答案
尝试使用 imrect
而不是 getrect
。
关于matlab - 回调函数中的 Getrect() 有运行时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23316331/