在 MATLAB 中保存连接的图像

Save concatenated images in MATLAB

我正在尝试连接两个 256x256 图像并使用 imwrite 保存它们。保存的图像应该是 256x512,但是当我加载保存的图像时,大小显示为 343x434x3。我该如何解决?

我使用的代码是:

new_name3 = strcat(f_name_image, '\', kk, '_', num2str(ff), '_pair.png');
pair = [orig_im  noisy_image]; %concatenating two 256x256 images
imagesc(pair)
f = getframe(gca);  
im = frame2im(f);
imwrite(im, new_name3);

在不配置其他选项的情况下,从帧中保存图像可能会有损。要保留像素信息,请直接从 pair(此处为 Image_Pair)数组保存拼接图像。此外,343x434x3 中的第三维表示图像的 RGB 颜色通道。

%Grabbing the two images%
Image_1 = imread('Image_1.jpeg');
Image_2 = imread('Image_2.jpeg');

%The file name for the concantenated images%
New_File_Name = "Image_3.jpeg";

%Concatenating the images%
Image_Pair = [Image_1 Image_2];

%Displaying the image pair%
imshow(Image_Pair);

%Saving the image to the "New_File_Name"%
imwrite(Image_Pair, New_File_Name);

%Loading the saved image to see if dimensions are consistent%
Saved_Image = imread('Image_3.jpeg');