MATLAB Answers

How to concatenate GRAYSCALE and RGB images?

22 views (last 30 days)
edusadiq
edusadiq on 30 Oct 2019
Commented: 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.

Accepted Answer

Sai Bhargav Avula
Sai Bhargav Avula on 30 Oct 2019
Edited: Sai Bhargav Avula on 30 Oct 2019
Hi, If just want to stitch them you can try using the montage() function of matlab.
Hope this helps!

  3 Comments

edusadiq
edusadiq on 30 Oct 2019
Please explain it in MATLAB with the help of code
Sai Bhargav Avula
Sai Bhargav Avula on 30 Oct 2019
imRGB = imread('bird.jpg');
imGray = rgb2gray(imRGB);
figure
montage({imGray, imRGB},'Size', [1 2])
This code should give the expected result.

Sign in to comment.

More Answers (0)

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by