when i push a button i want to load image on axes in GUI. so i tried this.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
misbah 0332
am 20 Feb. 2016
Kommentiert: misbah 0332
am 21 Feb. 2016
function pushbutton2_Callback(hObject, eventdata, handles)
k=zeros(100,99);
z=imshow(k);
imshow(z, 'Parent', handles.axes1);
*also tried this
function pushbutton2_Callback(hObject, eventdata, handles)
k=zeros(100,99);
imshow(k, 'Parent', handles.axes1);
but still nothing appears on axes1
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 21 Feb. 2016
The problem is you were calling imshow to display the image, but then immediately after that you display only the handle ID, which is a single value. Don't do that.
Just do this:
imshow(k, 'Parent', handles.axes1);
Don't call imshow() twice.
2 Kommentare
Image Analyst
am 21 Feb. 2016
Doing this
k=zeros(100,99);
imshow(k, 'Parent', handles.axes1);
will display a black rectangle. Is that what you were expecting?
Weitere Antworten (1)
Stalin Samuel
am 20 Feb. 2016
Refer the example file attached
4 Kommentare
Walter Roberson
am 20 Feb. 2016
Bearbeitet: Walter Roberson
am 20 Feb. 2016
The "function [] = callme(varargin)" is that code. However, it really should be passed S.ax so it can know where to display.
function [] = GUI()
SCR = get(0,'Screensize'); % Get screensize.
S.fh = figure();
S.ax = axes('units','pixels',...
'position',[50 100 300 230]);
S.tg(1) = uicontrol('style','toggle',...
'units','pixels',...
'position',[5 355 60 40],...
'string','click here',...
'val',1,'callback',{@callme, S.ax});
function [] = callme(src, event, ax)
k = rand(100,99);
imshow(k, 'Parent', ax);
Siehe auch
Kategorien
Mehr zu Specifying Target for Graphics Output finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!