MATLAB: How to concatenate GRAYSCALE and RGB images

catconcatenateMATLAB

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

Best Answer

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