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

조회 수: 2 (최근 30일)
ASHWIN JOSHY
ASHWIN JOSHY 2022년 5월 2일
편집: DGM 2022년 5월 2일
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
Dyuman Joshi
Dyuman Joshi 2022년 5월 2일
Store the image in a variable and use rgb2gray to store in another variable?

댓글을 달려면 로그인하십시오.

채택된 답변

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