Combine multiple images (imfuse)

조회 수: 20 (최근 30일)
MechenG
MechenG 2024년 8월 21일
댓글: MechenG 2024년 8월 21일
Hi, I am trying to dispaly 3 images using the below command. My A, B, C are in the format of 656 x 875 x 3 unit 8. I think the error is because of unit 8 format. I tried imfuse() as well, although it works for two images, but not for three images.
A = imread('1.bmp');
B = imread('2.bmp');
C = imread('3.bmp');
overlay_im = cat(3, A, B, C);
imshow(overlay_im);
However, the above code throws below error
Error in imshow (line 253)
images.internal.imageDisplayParseInputs({'Parent','Border','Reduce'},preparsed_varargin{:});
Error in image_comb (line 276)
imshow(overlay_im);

채택된 답변

Jatin
Jatin 2024년 8월 21일
편집: Jatin 2024년 8월 21일
The issue encountered is due to how images are combined. The “cat” function is concatenating the images along the third dimension. Since the images are already in RGB, concatenating them is an incorrect format for display with “imshow”.
About using “imfuse” function, the document clearly states that imfusecreates a composite image from two images. You can use the imfuse” function from MATLAB as below for your task:
A = imread('1.bmp');
B = imread('2.bmp');
C = imread('3.bmp');
%blend A,B as fusedAB and then with C as fusedABC
fusedAB = imfuse(A, B, 'blend');
fusedABC = imfuse(fusedAB, C, 'blend');
imshow(fusedABC);
If you want to display your images side by side, try using "subplot" as below:
A = imread('1.bmp');
B = imread('2.bmp');
C = imread('3.bmp');
%creating new figure
figure;
subplot(1, 3, 1);
imshow(A);
subplot(1, 3, 2);
imshow(B);
subplot(1, 3, 3);
imshow(C);
You can also refer to the below MATLAB Answer and documentations for more details:
Hope this helps!

추가 답변 (1개)

MechenG
MechenG 2024년 8월 21일
Thanks!, However this blends the all the images. Actually I don't want them to blend, rater I want to display them side by side.
  댓글 수: 2
Jatin
Jatin 2024년 8월 21일
Sure @MechenG, Kindly see if my updated answer help your cause.
MechenG
MechenG 2024년 8월 21일
Yes, Thanks!

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

Community Treasure Hunt

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

Start Hunting!

Translated by