Transform RGB image to grayscale but keep format as RBG

7 vues (au cours des 30 derniers jours)
Gazebo
Gazebo le 18 Fév 2020
Réponse apportée : darova le 18 Fév 2020
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.

Réponses (1)

darova
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

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by