How can I add UNDO functionality here

조회 수: 1 (최근 30일)
Muhammet
Muhammet 2013년 8월 7일
Hello, I am creating a GUI which enables user to draw a line on image using imfreehand and the position points pixels value will be assigned to 0 so I am being able to remove overlappings of white objects on black background by hand.I want to add UNDO functionality to my program.Here my callback code is callback of TOGGLE BUTTON. I want user to cancel the last drawing (not all the things done by toggle,only last stage of while loop).How can I achieve this ? thank you for your opinions
global I
axes(handles.axes1);
while get(hObject,'value')
h=imfreehand;
setClosed(h,'false');
pos=h.getPosition();
pos=round(pos);
s=numel(pos)/2;
for p=1:s
I(pos(p+s),pos(p))=0;
end;
imshow(I);
end;

채택된 답변

Jan
Jan 2013년 8월 7일
You can store the the value of I before the changes. Then pressing an "undo" button can restore the global variable I and restore the display also.
  댓글 수: 1
Jan
Jan 2013년 8월 7일
I don't know. It is a good strategy to open a new thread for a new question.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by