Hello. I superimpose a rectangle on a loaded image displayed on an axes component. I need the rectangle central, and size determined by a variable 'delta' as below.
img=imread('c:\Image03.tif');axes(handles.axes1)imageHandle=imshow(img,[]);[rows,cols]=size(img)rm=round(rows/2)cm=round(cols/2)delta=200x=cm-deltay=rm-deltahold on;h1=rectangle('Position',[x,y,delta,delta], 'FaceColor','none', 'EdgeColor','r')hold off;
I then save this rectangle to the handles structure, so I can use it later.
handles.ROIrect=h1 guidata(hObject, handles);
I then use another button's callback to delete the rectangle fromt he image through:
axes(handles.axes1) delete( findobj(gca, 'type', 'rectangle') );
I then want to have another pushbutton with its callback to redraw the rectangle on the image. I thought the following would work but it doesn't.
axes(handles.axes1) h1=handles.ROIrect
Have i made an obvious mistake>?
Thanks
Best Answer