Combine multiple images (imfuse)

38 visualizzazioni (ultimi 30 giorni)
MechenG
MechenG il 21 Ago 2024
Commentato: MechenG il 21 Ago 2024
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);

Risposta accettata

Jatin
Jatin il 21 Ago 2024
Modificato: Jatin il 21 Ago 2024
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!

Più risposte (1)

MechenG
MechenG il 21 Ago 2024
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 Commenti
Jatin
Jatin il 21 Ago 2024
Sure @MechenG, Kindly see if my updated answer help your cause.
MechenG
MechenG il 21 Ago 2024
Yes, Thanks!

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by