フィルターのクリア

Adding/Deleting draggable rectangles on the image

2 ビュー (過去 30 日間)
Naseer Khan
Naseer Khan 2016 年 9 月 20 日
コメント済み: Adam 2016 年 9 月 20 日
In the following code I am drawing number of rectangles on the Image and saving them to a file.My problem is that when I delete a rectangle(s) from the Image I get "Invalid or delete object" error.
I have created 3 buttons. "Load" load the Image "DrawRectangles" draw draggable rectangles on the Image "Save" saves all rectangles on the image to a file.
Load Button
% --- Executes on button press in loadButton.
function loadButton_Callback(hObject, eventdata, handles)
% hObject handle to loadButton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
I=imread('http://ichef.bbci.co.uk/corporate2/images/width/live/p0/0l/3r/p00l3rnt.jpg/624');
imshow(I);
rectangles=cell(1,1);
count=0;
handles.rectangles=rectangles;
handles.count=count;
guidata(hObject,handles);
Draw Rectangle Button
function drawButton_Callback(hObject, eventdata, handles)
% hObject handle to drawButton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
rectangles=handles.rectangles;
count=handles.count;
count=count+1;
h=imrect;
rectangles{count,1}=h;
handles.count=count;
handles.rectangles=rectangles;
guidata(hObject,handles);
Save Button
function saveButton_Callback(hObject, eventdata, handles)
% hObject handle to saveButton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
rectangles=handles.rectangles;
for i=1:length(rectangles)
dlmwrite('P:\bla.txt',rectangles{i}.getPosition,'-append','delimiter',' ','newline','pc');
end
How to fix this error and please also tell me how would I change the color and pixel size of the draggable rectangles that are being drawn on the Image.
  1 件のコメント
Adam
Adam 2016 年 9 月 20 日
You don't seem to have any code there that is deleting a rectangle so I'm not quite sure what error you mean. Also please give the full erorr message rather than just a shortened interpretation of it, including showing which line causes the error.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeC4ISR についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by