1
A
回答
4
提到這一點:
How do I add a background image to my GUI or figure window?
我只是改變了命令 - >現與圖像軸在上面。試試下面的代碼:
% This creates the 'background' axes
ha = axes('units','normalized', ...
'position',[0.3,0.35,0.4,0.4]);
% Load in a background image and display it using the correct colors
% The image used below, is in the Image Processing Toolbox. If you do not have
% access to this toolbox, you can use another image file instead.
I=imread('eight.tif');
hi = imagesc(I)
colormap gray
% Turn the handlevisibility off so that we don't inadvertently plot into the axes again
% Also, make the axes invisible
set(ha,'handlevisibility','off', ...
'visible','off')
% Now we can use the figure, as required.
% For example, we can put a plot in an axes
axes('position',[0 0 1 1])
plot(rand(10))
% this creates transparency, you probably dont need it:
set(hi,'alphadata',.5)
% move the image to the top:
uistack(ha,'top');
結果(不透明度)應該是這樣的:
0
非常感謝,這是非常有益的。 因此我做了一個功能
function legend_Image(Image_file,Fig_position,reduc_fact)
% legend_Image(Image_file,Fig_position,reduc_fact)
% Image_file= Image File name (full)
% Fig_position: position on figure [1 2 3 4]= [U/L U/R D/R D/L]
% reduc_fact : Ratio Image_size/Figure/size
%% Figure example
% hist(rand(1,2000),100);
Dim1=get(gca,'position');
L =Dim1(1); D=Dim1(2); W=Dim1(3); H=Dim1(4);
%%
% Calculate the Image position on figure
% reduction factor of the size
im_W=W/reduc_fact;
im_H=H/reduc_fact;
switch Fig_position
case 1 % Position 1 : Upper/Left
im_L=L;
im_D=D+H-im_H;
case 2 % Position 2 : Upper/Right
im_L=L+W-im_W;
im_D=D+H-im_H;
case 3 % Position 3 : Down/Right
im_L=L+W-im_W;
im_D=D;
case 4 % Position 4 : Down/Left
im_L=L;
im_D=D;
end
ha = axes('units','normalized', ...
'position',[im_L im_D im_W im_H]);
%%
% Load in a background image and display it using the correct
I=imread(Image_file);
hi = imagesc(I);
% colormap gray
%%
% Turn the handlevisibility off so that we don't inadvertently plot into the axes again
% Also, make the axes invisible
set(ha,'handlevisibility','off','visible','off');
%% I am not sur this is necessary !!
% this creates transparency, you probably dont need it:
% set(hi,'alphadata',.5)
% % move the image to the top:
% uistack(ha,'top');
%%
end
相關問題
- 1. 將Matlab圖形保存在背景中
- 2. 插入圖片作爲圖的背景?
- 3. 將jpg設置爲UIView的背景?
- 4. 回形針圖像保存爲JPG白色背景
- 5. 條形圖背景
- 6. 如何將PNG透明背景轉換爲JPG白色背景?
- 7. 透明背景圖(matlab)
- 8. Matlab - 顯示背景圖像
- 9. Matlab的插入圖像(.JPG)文件轉換爲Word文件
- 10. php Imagemagick jpg黑色背景
- 11. CRichEditCtrl和插入圖像(JPG)
- 12. 將背景圖片應用到形狀
- 13. 如何正確插入背景圖片
- 14. Twitter Bootstrap模態插入背景圖像
- 15. 無法插入背景圖片
- 16. Wx.html2未插入背景圖像
- 17. 如何將圖像插入背景並將其保存爲JAVA?
- 18. matlab繪圖圖像作爲背景圖
- 19. 通過矩形繪製Matlab圖的顏色背景
- 20. 保存與不同背景顏色的MATLAB圖形
- 21. 用黑色背景導出的MATLAB圖形
- 22. 如何將jpg/png插入到opengl中的場景中?
- 23. 如何將背景圖片插入我的網站?
- 24. 背景圖像整形
- 25. 在sceneGroup中插入背景?
- 26. 插入背景橫幅
- 27. Matlab - 忽略圖像的背景
- 28. 默認情況下在背景中繪製Matlab圖形
- 29. 將pgm圖像轉換爲jpg Matlab
- 30. Matlab將個別子圖保存爲jpg