how to show images in GUI matlab

61 views (last 30 days)
mutia
mutia on 28 May 2014
Commented: Image Analyst on 9 Jul 2022
I have 4 images, I want to show in axes1, axes2, axes3 axes4, how to build the code?
I use this code, but cannot
g= imread('kasus5.png');
axes(handles.axes1)
imshow(g);
h= imread('kasus6.png');
axes(handles.axes2)
imshow(h);
the result : the picture is shown in figure , not in axes, but when I use 1 axes, that picture can be shown in axes, what happen? please help me, i cannot use multiple axes
  4 Comments
Geoff Hayes
Geoff Hayes on 29 May 2014
Do you get an error message when you are using two or more axes that is preventing the images from being shown, or does nothing happen? It will be challenging to solve your problem without being able to see the code… Are handles.axes1 and handles.axes2 valid?
mutia
mutia on 29 May 2014
thank you for your answer @Geoff Hayes nothing happen,I didn't get error message, if I click push button,the pictures being shown not in axes.
and i tried to used the one axes, the code like that g = imread('kasus5.png');
axes(handles.axes1)
imshow(g); the picture can be shown in axes,.what happen? I'm confused :(

Sign in to comment.

Answers (2)

Geoff Hayes
Geoff Hayes on 29 May 2014
mutia - maybe you should just start over with a brand new GUI. I created a very simple one with two axes and a button (I left all with their default names.) I created a callback for the button and modified it to be the following
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
I = imread('image1.jpg');
J = imread('image2.jpg');
axes(handles.axes1);
imshow(I);
axes(handles.axes2);
imshow(J);
I ran it and it worked fine. Try the above with your GUI and see what happens.
  7 Comments
Geoff Hayes
Geoff Hayes on 1 Dec 2017
Nurye - you may want to provide a small of example of code that demonstrates this problem and post as a new question rather than continuing the conversation here.
Purnendu Nath
Purnendu Nath on 14 May 2018
using the function "axes" is the key, as Geoff suggested... and solves the problem (I had the same question and tried what Geoff suggested.. works!)

Sign in to comment.


Princiya
Princiya on 9 Jul 2022
Create gui average filter
  1 Comment
Image Analyst
Image Analyst on 9 Jul 2022
Not sure how this is an answer to @mutia's question.
If you have any questions of your own, then attach your data and code to read it in with the paperclip icon after you read this:
Post it in a totally new discussion thread.

Sign in to comment.

Categories

Find more on Graphics Performance in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!