Effacer les filtres
Effacer les filtres

How to change 1 channel image to 3 channel

31 vues (au cours des 30 derniers jours)
evianita dewi
evianita dewi le 13 Déc 2019
Réponse apportée : DGM le 2 Mai 2022
I have several grayscale images with channel 1, then I want to convert it to RGB channel 3 image, how do I change it?

Réponse acceptée

Image Analyst
Image Analyst le 13 Déc 2019
Try cat() to stack the gray scale image into 3 slices (color channels):
rgbImage = cat(3, grayImage, grayImage, grayImage);
It will be an RGB image though the only colors will be gray since there is no difference between the three different color channels. It will be a 3-D image with the z-direction (third index) being the color channel index.
  2 commentaires
evianita dewi
evianita dewi le 26 Déc 2019
this is very helpful, thank you!!
Muhammad Kamran
Muhammad Kamran le 25 Mar 2021
Thanks a lot.
It's very helpful.

Connectez-vous pour commenter.

Plus de réponses (1)

DGM
DGM le 2 Mai 2022
Alternative to using cat(), the same can also be done a couple other ways.
You can use repmat()
rgbpict = repmat(graypict,[1 1 3]);
... or you can even use basic indexing:
rgbpict = graypict(:,:,[1 1 1]);

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by