How to convert RGB image to grayscale image

4 ビュー (過去 30 日間)
aarti sawant
aarti sawant 2014 年 2 月 2 日
コメント済み: DGM 2021 年 11 月 30 日
Please help me to convert RGB image to grayscale without using rgb2gray().

採用された回答

Image Analyst
Image Analyst 2014 年 2 月 2 日
Sounds like homework. You can get the color channels:
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
and then do a weighted average of them.
grayImage = a1 * redChannel + a2 * greenChannel + a3 * blueChannel;
Look up standard weights, or pick your own.
  3 件のコメント
Image Analyst
Image Analyst 2021 年 11 月 30 日
DGM
DGM 2021 年 11 月 30 日
What's wrong with just giving the luma constants?
[0.299 0.587 0.114] for Rec 601 (what rgb2gray() uses)
or
[0.2126 0.7152 0.0722] for Rec 709

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by