制作2D Matlab的数字,其中包含在给定的位置开始多张图像(X,Y) [英] Making a 2D Matlab figure that contains multiple images which start at a given point (x,y)

查看:236
本文介绍了制作2D Matlab的数字,其中包含在给定的位置开始多张图像(X,Y)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Matlab的二维图它由多个图像和情节数据图(我最终可以转换成图像太)的。对于这些图像,图形,我需要能够以指定它们存在于我的笛卡尔坐标系中。

I am trying to make a 2D figure in Matlab which consists of multiple images and a graph with plot data (which I could eventually convert into an image too). For these images and graph, I need to be able to specify where they are located in my cartesion coordinate system.

有关我的具体情况,它足以能告诉Matlab的在图像的左下角是

For my specific case, it is sufficient to be able to "tell" Matlab where the left-bottom corner of the image is.

因此​​,对于上面的例子。我需要一些绝招,让bird1.jpg的位置开始(A,B),bird2.jpg在位置( C,D)和我的情节在位置(E,F)在一个Matlab的身影。​​

So for the example above. I would need some "trick" to let "bird1.jpg" start at position (a,b), "bird2.jpg" at position (c,d) and my plot at position (e,f) in one Matlab figure.

由于chappjc我能找到我的问题的解决方案。这里是code我用这样其他人可以在将来使用它。

Thanks to chappjc I was able to find a solution for my problem. Here is the code I used such that other people can use it in the future too.

figure_color = [.741 .717 .42];
axe_color = [1 1 1];
Screen.fig = figure('units','pixels',...
           'name','Parallel projection',...
           'menubar','none',...
           'numbertitle','off',...
           'position',[100 100 650 720],...
           'color',figure_color,...
           'busyaction','cancel',...
           'renderer','opengl');
Screen.axes = axes('units','pix',...
         'position',[420 460 200 200],... % (420,460) is the position of the first image
         'ycolor',axe_color,...
         'xcolor',axe_color,...
         'color',axe_color,...
         'xtick',[],'ytick',[],...
         'xlim',[-.1 7.1],...
         'ylim',[-.1 7.1],...
         'visible','On');
Screen.img = imshow(phantom);
Screen.axes2 = axes('units','pix',...
         'position',[0 0 200 200],... % (0,0) is the position of the second image
         'ycolor',axe_color,...
         'xcolor',axe_color,...
         'color',axe_color,...
         'xtick',[],'ytick',[],...
         'xlim',[-.1 7.1],...
         'ylim',[-.1 7.1],...
         'visible','On');
Screen.img2 = imshow(phantom);

基本上我做的是先建立一个(大)图,然后在这个大画面的某个位置创建一个第一斧,并使其成为默认的斧头。在这个斧头我显示我的第一张图像(与幻影功能制造)。从那以后,我做在另一个位置上的新的斧头,再次使其成为默认的斧头。当我这样做,我把图像有太多(同样的图片,但你也可以用另外一个,如果你想)。您也可以使用手柄这是更清洁的方法,因为chappjc描述。

Basically what I do is first creating a (big) figure, and then create a first axe at a certain position in this big picture, and make it the default axe. In this axe I display my first image (made with the phantom function). After that I make a new axe at a another position and make it again the default axe. After I have done that, I place an image there too (the same picture, but you can also use another one if you want). You can also use handles which is the more clean method, as chappjc describes.

推荐答案

一个办法是操纵的位置在图多轴属性。为了使多轴的数字:

Positioning axes in a figure

One approach would be to manipulate the Position property of multiple axes in a figure. To make multiple axes in a figure:

hf = figure;
ha0 = axes('parent',hf,'Position',[x0 y0 w0 h0]);
ha1 = axes('parent',hf,'Position',[x1 y1 w1 h1]);

然后通过指定手柄(即HA 0或HA1)显示您的图片和图表插入轴。例如:图像(img0,'父',HA 0) imshow(IMG1,父,HA1)

另一种方法是使一个单一的大图像,只需用图片 / imshow /等显示出来。

Another approach is to make a single large image and simply display it with image/imshow/etc.

首先对于该地块,可以使用的getFrame 然后按 frame2im 来获得图像中的矩阵格式。

First for the plots, you can use getframe followed by frame2im to get an image in a matrix format.

接下来,决定什么进入你的组合图像,并计算成包围该图像所需的最大盒(使用它们的起源和大小找到最大的x和y坐标),其中包括在原点presumably。使用此信息,以使空白图像(如 IMG =零(H,W,3)并RGB图像)。

Next, decide what goes into your combined image and compute the largest box required to circumscribe the images (using their origins and sizes find the largest x and y coordinate), which includes the origin presumably. Use this info to make a blank image (e.g. img = zeros(h,w,3) for and RGB image).

这篇关于制作2D Matlab的数字,其中包含在给定的位置开始多张图像(X,Y)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆