how to preserve RGB values of an image while making it gray image

17 vues (au cours des 30 derniers jours)
ASHWIN JOSHY
ASHWIN JOSHY le 2 Mai 2022
Modifié(e) : DGM le 2 Mai 2022
I need to convert an RGB image to gray image, but after processing i want the image back to RGB,
So how can i preserve the RGB values of an image
I am using
RGBImage=imread('RGBImage.tiff')
to read the image
  1 commentaire
Dyuman Joshi
Dyuman Joshi le 2 Mai 2022
Store the image in a variable and use rgb2gray to store in another variable?

Connectez-vous pour commenter.

Réponse acceptée

DGM
DGM le 2 Mai 2022
Modifié(e) : DGM le 2 Mai 2022
You don't. When you convert a color image to grayscale, you are discarding the color information. It's gone.
If you want to keep the color image, simply keep the color image and make a grayscale copy.
rgbpict = imread('peppers.png');
graypict = rgb2gray(rgbpict); % BT601 luma
If instead you intend to do some operations on the color image by using the grayscale image as a proxy, I'd have to know what kind of operation you're trying to do. If that's your intent, you'll have to describe the task.

Plus de réponses (0)

Catégories

En savoir plus sur Color and Styling dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by