Transform RGB image to grayscale but keep format as RBG
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi all,
I have a imageDatastore of jpeg images, and I'm trying to transform all the images to grayscale, however I want to keep dimensions of the images the same (m x n, 3).
I was hoping to use rbg2gray, however I cannot compare the original and grayscale images as the dimensions are not consistent.
Thanks.
0 commentaires
Réponses (1)
darova
le 18 Fév 2020
You can use repmat or cat to create 3D matrix
I1 = rgb2gray(I);
I2 = cat(3,I1,I1,I1); % gray image as 3D matrix
%I2 = repmat(I1,[1 1 3]); % gray image as 3D matrix
0 commentaires
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!