我使用guide
創建了MATLAB中的GUI。到目前爲止,用戶可以導入圖像並保存圖像。我的下一步是允許用戶點擊圖像來放置一個圓/方塊,哪個更容易實現。理想情況下,我想這樣做,所創建的最新版本是可撤銷的,但基本實現是最重要的。在用戶指定的圖像上繪製圓圈/正方形
我假設使用PLOT的圓的實際繪圖會很好,正如其他幾個問題中提到的那樣。我不確定的是,我將如何獲取鼠標點擊圖像中的位置,然後將PLOT放置在該位置。
編輯: 這裏是代碼的主要位,我對目前的工作零件。
function V1Open_Callback(hObject, eventdata, handles)
% hObject handle to V1Open (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
hMainGui = getappdata(0, 'hMainGui');
fileName = uigetfile('*.jpg');
setappdata(hMainGui, 'fileName', fileName);
updateAxes1
function updateAxes1
hMainGui = getappdata(0, 'hMainGui');
fileName = getappdata(hMainGui, 'fileName');
imshow(imread(fileName))
% --- Executes on button press in V1Save.
function V1Save_Callback(hObject, eventdata, handles)
% hObject handle to V1Save (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
imsave;
嗨,感謝您的回覆,已添加上面代碼的主要部分。對MATLAB來說很陌生,所以不太熟悉。 – Ieuan 2011-02-03 21:44:18