필터 지우기
필터 지우기

How to save concatenated images in MATLAB?

조회 수: 2 (최근 30일)
SHAUROV DAS
SHAUROV DAS 2020년 7월 29일
답변: Sourabh Kondapaka 2020년 8월 10일
I am trying to concatenate two 256x256 images and save them using imwrite. The saved image is supposed to be 256x512, but when I load the saved image, the size shows to be 343x434x3. How do I solve this?
the code I am using is:
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);
  댓글 수: 1
Alexander
Alexander 2020년 7월 31일
try "imwrite(pair, new_name3);" instead

댓글을 달려면 로그인하십시오.

채택된 답변

Sourabh Kondapaka
Sourabh Kondapaka 2020년 8월 10일
Hi,
You can save the image without using the imagesc()” function as follows:
new_name3 = strcat(f_name_image, '\', kk, '_', num2str(ff), '_pair.png');
pair = [orig_im noisy_image]; %concatenating two 256x256 images
imwrite(pair, new_name3);
However, if you do need to use “imagesc()” function, then please do the following:
new_name3 = strcat(f_name_image, '\', kk, '_', num2str(ff), '_pair.png');
pair = [orig_im noisy_image]; %concatenating two 256x256 images
scaled_image = imagesc(pair);
imwrite(scaled_image.CData, new_name3);
The “imagesc()” function returns an “image” object. You need to extract the matrix values from the image object when writing into a file.
CData” property of the “Image” object stands for “Color Data” which is the matrix values of the concatenated image.
If you would like to learn more about the “Image object and its properties, please check here.

추가 답변 (0개)

제품


릴리스

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by