How to add more images on a gui...
1 view (last 30 days)
Show older comments
Hello everybody!
I'm working on a project, and I created a first window for choosing language. I already added a background image using axes
axes(hObject)
imshow('Img_name.png');
Now I have to add some flags. I tried the same way with new axes spaces, also tried to bring them to front, but there's no results. For each flag I used the same code, changing the Img_name... I tried to change "hObject" using other handles, but something's wrong...
I already tried with
image('Img_name.png')
and
imagesc('Img_name.png')
and I'm sure Matlab can read png files (the background is a png image) Any ideas?? Thanks!
0 Comments
Accepted Answer
Chandra Kurniawan
on 4 Dec 2011
Hello,,
Here the download link. I cannot modified your code, but I created new fig file.
3 Comments
Chandra Kurniawan
on 4 Dec 2011
It just to turns off all axis lines, tick marks, and labels.
Coz command 'imagesc' make axis line turned on :)
More Answers (3)
Chandra Kurniawan
on 3 Dec 2011
Hello,
I think what's wrong with using 'imagesc' function to display your images?
Imagesc works for all supported image formats (.png, .jpg, .tiff, .bmp, etc).
I just do the same way with you and all of my image can be displayed with command 'imagesc'.
clear; clc;
hfig = figure('unit','pixel','position',[100 100 620 400]);
axes1 = axes('parent',hfig,'unit','pixel','position',[10 10 600 380]);
axes2 = axes('parent',hfig,'unit','pixel','position',[20 20 100 100]);
axes3 = axes('parent',hfig,'unit','pixel','position',[140 20 100 100]);
axes4 = axes('parent',hfig,'unit','pixel','position',[260 20 100 100]);
axes5 = axes('parent',hfig,'unit','pixel','position',[380 20 100 100]);
axes6 = axes('parent',hfig,'unit','pixel','position',[500 20 100 100]);
I = imread('peppers.png');
J = imread('fabric.png');
K = imread('gantrycrane.png');
L = imread('hestain.png');
M = imread('pears.png');
N = imread('tape.png');
imagesc(I,'parent',axes1); axis(axes1,'off');
imagesc(J,'parent',axes2); axis(axes2,'off');
imagesc(K,'parent',axes3); axis(axes3,'off');
imagesc(L,'parent',axes4); axis(axes4,'off');
imagesc(M,'parent',axes5); axis(axes5,'off');
imagesc(N,'parent',axes6); axis(axes6,'off');
2 Comments
Walter Roberson
on 4 Dec 2011
image() and imagesc() do not accept filenames. You have to pass the image data itself to image() and imagesc(), having read in the image before that using imread()
imshow() does allow filenames and will read in the file for you. If you want imshow() to display on a particular axes, then you need to use the 'Parent' parameter, as in
imshow('Img_name.png', 'Parent', hObject);
Remember that at some point before you add the new image, you must "hold" the axes or else the new image will remove the previous ones.
hold(hObject, 'on')
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!