在matlab中融合2个以上的图像 [英] fusing more than 2 images in matlab

查看:1420
本文介绍了在matlab中融合2个以上的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MATLAB中,如何融合两个以上的图像?例如,我想做 imfuse 但是对于超过2个图像。使用两个图像,这是我的代码:

In MATLAB, how do I fuse more than two images? For example, I want to do what imfuse does but for more than 2 images. Using two images, this is the code I have:

A = imread('file1.jpg');
B = imread('file2.jpg');

C = imfuse(A,B,'blend','Scaling','joint'); 

C 将是<$的融合版本c $ c> A 和 B 。我有大约50张图像要融合。我如何实现这一目标?

C will be fused version of A and B. I have about 50 images to fuse. How do I achieve this?

推荐答案

您可以为循环编写 ,然后只需要一个存储所有融合结果的图像,并反复将此图像与您读入的新图像融合。因此,假设您的图像是从 file1.jpg file50.jpg 。你可以这样做:

You could write a for loop, then simply have a single image that stores all of the fused results and repeatedly fusing this image with a new image you read in. As such, let's say your images were named from file1.jpg to file50.jpg. You could do something like this:

A = imread('file1.jpg'); 
for idx = 2 : 50
    B = imread(['file' num2str(idx) '.jpg']); %// Read in the next image
    A = imfuse(A, B, 'blend', 'Scaling', 'joint'); %// Fuse and store into A
end

上述代码将做的是它会反复读取下一张图像,并将其与存储在 A 中的图像融合。在每次迭代中,它将采用当前在 A 中的内容,将其与新图像融合,然后将其存储在 A 。这样,当我们继续阅读图像时,我们将继续将新图像融合在之前融合的图像之上。在此 for 循环结束后,您将有50张图片全部融合在一起。

What the above code will do is that it will repeatedly read in the next image, and fuse it with the image stored in A. At each iteration, it will take what is currently in A, fuse it with a new image, then store it back in A. That way, as we keep reading in images, we will keep fusing new images on top of those images that were fused from before. After this for loop finishes, you will have 50 images that are all fused together.

这篇关于在matlab中融合2个以上的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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