2

大家好,我在matlab中遇到了一些问题:

假设我有 5 张图像,我想在 matlab 图形窗口中绘制所有图像。我该怎么做?意思是我想在第一行放两张图片,在第二行放三张图片。我实际上想要这个输出。

在此处输入图像描述

或者是这样的:

在此处输入图像描述

请记住,我想将两个图形窗口顶行中的图像居中对齐。简而言之,我想知道如何在 matlab 图形窗口中专门设置子图的位置?

还有什么方法可以给我的图形窗口一个主标题?我不想使用功能SUPLABEL

我使用的代码是这样的:

h1=figure;
subplot(2,3,1);imshow(I_orignial);title('The original Image','FontWeight','bold','FontSize', 12);
subplot(2,2,2);imshow(aa1); title('1st segment','FontWeight','bold','FontSize', 12);
subplot(2,2,3);imshow(aa2); title('2nd segment','FontWeight','bold','FontSize', 12);
subplot(2,2,4);imshow(aa3); title('3rd segment','FontWeight','bold','FontSize', 12);

%//Please note that aa1,aa2 & aa3 are logical arrays and I_orignial is an uint8 image.
%//The size of the logical arrays is 64X64.
%//The size of the image is 160X221.

无论如何,我可以在显示数字之前将我的子图图像调整为特定大小吗?我的意思是如何在 matlab 图上将不同大小的图像强制为相同的子图大小?请注意:我不是在谈论 imresize。

如需进一步澄清,请回复我!

提前致谢 !!

4

2 回答 2

2

如果要使用subplot,而不是直接指定轴位置,您必须在脑海中将图形拆分为最小的均匀区域,然后将它们组合成图。例如,要拥有三个大小相同的地块,一个在顶部,两个在底部,您可以:

firstAxes =  subplot(2,4,2:3);
secondAxes = subplot(2,4,5:6);
thirdAxes =  subplot(2,4,7:8);

如果要执行更复杂的操作,例如将文本放在特定位置,最好直接创建显示对象。例如:

   fh = figure;
   hiddenAxes = axes('parent',fh,'units','normalized','position',[0 0 1 1],'color','w','xcolor','w','ycolor','w','xlim',[0 1],'ylim',[0 1]);
   text('parent',hiddenAxes','position',[0.25 0.9 0.5 0.1],'horizontalAlignment','center','string','this is a centered title','fontWeight','bold')
   firstAxes =  axes('parent',fh,'units','normalized','position',[0.25 0.5 0.5 0.45]);
   secondAxes = axes('parent',fh,'units','normalized','position',[0 0 0.5 0.45]);
   thirdAxes =  axes('parent',fh,'units','normalized','position',[0.5 0 0.5 0.45]);

要控制图像大小,您需要更改轴限制。

于 2013-09-08T17:40:22.573 回答
1

你也可以试试

figure
subplot(2,3,1.5)
subplot(2,3,2.5)
subplot(2,3,4)
subplot(2,3,5)
subplot(2,3,6)

5plots_1-2居中 或者

subplot(2,2,1.5)
subplot(2,2,3)
subplot(2,2,4)

3plots_1居中

于 2017-09-26T19:30:15.740 回答