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

2 次查看(过去 30 天)
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

采纳的回答

DGM
DGM 2022-5-2
编辑:DGM 2022-5-2
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Modify Image Colors 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by