How to add more images on a gui...
조회 수: 1 (최근 30일)
이전 댓글 표시
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
채택된 답변
Chandra Kurniawan
2011년 12월 4일
Hello,,
Here the download link. I cannot modified your code, but I created new fig file.
댓글 수: 3
Chandra Kurniawan
2011년 12월 4일
It just to turns off all axis lines, tick marks, and labels.
Coz command 'imagesc' make axis line turned on :)
추가 답변 (3개)
Chandra Kurniawan
2011년 12월 3일
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
Walter Roberson
2011년 12월 4일
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
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!