MATLAB Answers

0

How to concatenate GRAYSCALE and RGB images?

Asked by edusadiq on 30 Oct 2019
Latest activity Commented on by edusadiq on 30 Oct 2019
I'm trying to concatenate a graysacale and rgb image but it shows error.
This is the code
>> A = imread('bird.jpg');
>> B = rgb2gray(A);
>> imshow(A),imshow(B);
>> C = cat(2,A,B);
Error using cat
Dimensions of arrays being concatenated are not consistent.
Can someone help me out?
I want this effect which is shown in given image
Concatenate GRAYSCALE and RGB image in MATLAB.jpg

  0 Comments

Sign in to comment.

Products


Release

R2019a

1 Answer

Answer by Sai Bhargav Avula on 30 Oct 2019
Edited by Sai Bhargav Avula on 30 Oct 2019
 Accepted Answer

Hi, If just want to stitch them you can try using the montage() function of matlab.
Hope this helps!

  3 Comments

Please explain it in MATLAB with the help of code
imRGB = imread('bird.jpg');
imGray = rgb2gray(imRGB);
figure
montage({imGray, imRGB},'Size', [1 2])
This code should give the expected result.
Yes, it worked 100%.

Sign in to comment.