简体   繁体   中英

how to concatenate two images of different dimension in matlab

I have two images of the same scene but of a different type: image1:Type RGB ([400 400 3]) and image2:type infrared ([400 400 1]).I am seeking an image by concatenating the image1 and image2 to get an image3 ([400 400 4]).

im1=imread('rgbimage.jpg');
im2=imread('infraredimage.jpg');
im3=cat(4,im1,im2);

I try with function cat in matlab but I get this error:

Error using cat
Dimensions of matrices being concatenated are not consistent.

if someone can help me , thank you

Concatenating two images with dimensions [400 400 3] and [400 400 1] to [400 400 4] is a concatenation among the third dimension. Use im3=cat(3,im1,im2);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM