matlab - 在 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
(here 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');
推荐阅读
- java - 如何在独立的 OC4J 中将 jdbc 驱动程序从 10g 升级到 12c
- javascript - 从具有重复值的数组创建对象
- python - 我可以只为单个实例装饰属性获取器吗?
- vim - 如何使用 vim visualblock 递增块中的数字
- javascript - 如何制作一个 chrome 扩展程序来读取我正在访问的网站中的文本?
- python - numpy 显示图像列表的错误尺寸
- regex - 形式语言理论(正则表达式和正则语言)-“或”的概念
- javascript - 使用正则表达式计算文本中的数字
- mongodb - 如何为以下用例实现部分数据的复制
- r - 属性()是R中的函数吗?