Combine multiple images (imfuse)
조회 수: 20 (최근 30일)
이전 댓글 표시
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);
댓글 수: 0
채택된 답변
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 “imfuse” creates 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!
댓글 수: 0
추가 답변 (1개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!