.jpg as a background on gui
조회 수: 6 (최근 30일)
이전 댓글 표시
I have a code that creates a projectile motion. I'm looking to make the background a .jpg file instead of colors that I currently use. Help is much appreciated. This is our current background.
backgroundX = [0 1 2 3 4 5 6 7 8 9 10 0];
backgroundY = [0 4 2 7 5 8 3 4 2 5 0 0];
backgroundX1 = [0 .75 1.5 2 2.8 3.5 4 4.666667 5.2 6 6.5 7.25 8,...
8.66667 9.2 10 0];
backgroundY1 = [0 3 3 2 6 6 5 7 7 3 3.5 3.5 2 4 4 0 0];
backgroundX2 = [0 0 1 2 3 4 5 6 7 8 9 10 10 0];
backgroundY2 = [10 0 4 2 7 5 8 3 4 2 5 0 10 10];
fill(330*backgroundX,200*backgroundY,'PhilSkyline.jpg')
fill(330*backgroundX1,200*backgroundY1,[0 .65 0])
fill(330*backgroundX2,200*backgroundY2,[.3 .7 1])
axis([0 3300 0 2000])
댓글 수: 0
답변 (2개)
Giorgos Papakonstantinou
2015년 3월 2일
편집: Giorgos Papakonstantinou
2015년 3월 2일
You can create a figure and remove the MenuBar. In this figure you can display your image, whose parent is an axis. You can set the axis position to occupy the full dimension of your figure.
i.e.
fig = figure('MenuBar', 'none');
IM = imread('peppers.png');
h = image(IM);
set(get(h, 'parent'),'XTick', [], 'YTick', [], 'position' , [0 0 1 1])
댓글 수: 2
Giorgos Papakonstantinou
2015년 3월 3일
The limits of your axis are the same size of your image. Therefore when you invoke the|axis| command you change the limits of the axis: [xmin xmax ymin ymax]. You set them [0 2000 0 2000].
Is this size of your image? (2000 x 2000).
Moreover, when you issue axis equal you set the aspect ratio so that the data units are the same in every direction. As a result your image does not fill the whole figure when you resize the figure.
Image Analyst
2015년 3월 3일
How about this from the Mathworks Support Team?
댓글 수: 2
Image Analyst
2015년 3월 3일
I don't know. I've never tried it but I doubt it. I think fill just fills with a uniform color.
참고 항목
카테고리
Help Center 및 File Exchange에서 Assembly에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!