如何在Matlab中附加图片? [英] How to Append pictures in Matlab?

查看:119
本文介绍了如何在Matlab中附加图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在没有imagemagick的系统中做这个伪代码但我在系统中有Matlab 2016a和Java

I want to do this pseudocode in a system without imagemagick but I have Matlab 2016a and Java in the system

convert 1.png 2.png +append result.png

假设你想在如下的循环中连接这样尺寸可能不匹配。
但是,所有对象1,2,...,N具有完全相同的尺寸。
但是,以下循环会同时连接两张图片,使尺寸与后续图像不同:bigImage vs new image。

Assume you want to concatenate in a loop like the following such that dimensions may not match. However, all objects 1,2,...,N have exactly the same dimensions. The following loop, however, concatenates two pictures at the same time, making the dimensions different with subsequent images: bigImage vs new image.

iterationCounter=1;

result=0;
while(iterationCounter < 3)
    imgRGB=imread(filenamePng); % Images 1,2, ..., N have same dimensions.

    if (result==0)
        result=imgRGB;
    end

    % http://stackoverflow.com/a/35915990/54964
    if (ismatrix(result(:,:,1)))
        heightRatio=size(result,1)/size(imgRGB,1);
        wantedSize=int16([size(result,1), size(imgRGB,2)*heightRatio]);
        imgResized=imresize(imgRGB, wantedSize);
        result=[result, imgResized];
    end

    iterationCounter=iterationCounter+1;

end

其中输出为空图片。

如何在Matlab / Java中水平追加图像?

How can you do the horizontal appending of the images in Matlab/Java?

推荐答案

这应该有效:

imwrite([imread('1.png') imread('2.png')], '12.png');

注意:它们应具有相同的宽度/高度,具体取决于您添加它们的方式。

这篇关于如何在Matlab中附加图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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