How to concatenate GRAYSCALE and RGB images?
18 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
edusadiq
el 30 de Oct. de 2019
Comentada: DGM
el 26 de Oct. de 2022
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
0 comentarios
Respuesta aceptada
Sai Bhargav Avula
el 30 de Oct. de 2019
Editada: Sai Bhargav Avula
el 30 de Oct. de 2019
Hope this helps!
4 comentarios
Más respuestas (1)
DGM
el 26 de Oct. de 2022
Alternatively, you can expand the grayscale image. Assuming the images have compatible geometry, they can then be edge-concatenated as normal.
% an RGB image and a mono image
RGB = imread('peppers.png');
I = rgb2gray(RGB);
% expand the single-channel image
Irgb = repmat(I,[1 1 3]);
% concatenate the images
outpict = [Irgb RGB];
imshow(outpict)
0 comentarios
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!