subplot() 用来平铺图片的位置,类似坐标。
代码1:
imgsrc=imread('test.jpg');
subplot(121);
imshow(imgsrc);
title('RGB');
imgsrc=rgb2gray(imgsrc);
subplot(122);
imshow(imgsrc);
title('gray');
效果:

代码2:
imgsrc=imread('test.jpg');
subplot(222);
imshow(imgsrc);
title('RGB');
imgsrc=rgb2gray(imgsrc);
subplot(223);
imshow(imgsrc);
title('gray');
效果:

分析:subplot里的3位数参数类似一个索引,前两位可以看成产生一个1 * 2和2 * 2的坐标,第3位决定了图片所在位置。
注意:subplot(222)和subplot(2, 2, 2)等价。
本文介绍如何使用subplot函数在Matplotlib中并排显示不同格式的图像,如RGB和灰度图像。通过实例展示了subplot参数的使用方法,以及如何调整图像布局。
694

被折叠的 条评论
为什么被折叠?



