필터 지우기
필터 지우기

imshow, axes in GUI, cla not working

조회 수: 1 (최근 30일)
KJVKU999
KJVKU999 2014년 5월 7일
댓글: KJVKU999 2014년 5월 7일
Hello,
Number of axes created for displaying image depends on the slider value. switch slidervalue with two case is shown below:
switch slidervalue
case 1
RA = axes('units','pixels','Position',[350 12 868 320]); axes(RA); cla;
imshow(firstM); title(['D = : ', num2str(DISTANCE(1))]);
case 2
RA1 = axes('units','pixels','Position',[368 9 418 320]); axes(RA1); cla;
imshow(firstM); title(['D = : ', num2str(DISTANCE(1))]);
RA2 = axes('units','pixels','Position',[802 9 418 320]); axes(RA2); cla;
imshow(secondM); title(['D = : ', num2str(DISTANCE(2))]);
after case 1(shown image by RA axes), if second call is for case 2 - it will overwrite the case 1 image.(Case 2 images shown on case 1 image) most part of case 1 image is still visible
I think cla is not working. Tried this also: axes property- NextPlot value = replace, new, replacechildren, etc. that didn't work. reset , delete axes also didn't work.
can anyone provide solution:? I want to clear axes before displaying other ones...
  댓글 수: 1
KJVKU999
KJVKU999 2014년 5월 7일
Also, when case 1 is called (or true) second time, image shown at same place results in mixing up the title names...(and imshow() overwrites the older image). So, if there are different size of image, We can see all images (full or fraction) instead of seeing current case's image/s.

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

채택된 답변

Roberto
Roberto 2014년 5월 7일
편집: Roberto 2014년 5월 7일
This is because RA axes is still visible and you are creating one axe every time,
to create just one axe try this code outside your function right at the beginning of the file, after the 'Do not edit' and the guidata command line (I'm assuming some characteristics of your code, did you created with GUIDE? or else, upload your code!):
% Choose default command line output for WHATEVER.m
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
handles.RA = axes('units','pixels','Position',[350 12 868 320]);
handles.RA1 = axes('units','pixels','Position',[368 9 418 320]);
handles.RA2 = axes('units','pixels','Position',[802 9 418 320]);
guidata(hObject,handles);
And then have the handles values passed to your function...
function slider_Fnc_Callback(hObject,EventData,handles)
switch slidervalue
case 1
set(handles.RA,'Visible','on');
set(handles.RA1,'Visible','off');
set(handles.RA2,'Visible','off');
axes(handles.RA); cla; imshow(firstM);
title(['D = : ', num2str(DISTANCE(1))]);
case 2
set(handles.RA,'Visible','off');
set(handles.RA1,'Visible','on');
set(handles.RA2,'Visible','on');
axes(handles.RA1); cla; imshow(firstM);
title(['D = : ', num2str(DISTANCE(1))]);
axes(handles.RA2); cla; imshow(secondM);
title(['D = : ', num2str(DISTANCE(2))]);
Or something like this!
  댓글 수: 3
Roberto
Roberto 2014년 5월 7일
not only for axes, but with everything!!
KJVKU999
KJVKU999 2014년 5월 7일
Yeah, Sure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by