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 Center および File ExchangeMigrate GUIDE Apps についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by