Can anyone please help me to calculate average(mean) RGB value from the image in matlab? and also show the image using that average values.....

23 ビュー (過去 30 日間)
I=imread(filename);
red=I(:,:,1);
green=I(:,:,2);
blue=I(:,:,3);
Ravg=(sum(sum(red)))./((size(red,1)).*(size(red,2)));
Gavg=(sum(sum(green)))./((size(green,1)).*(size(green,2)));
Bavg=(sum(sum(blue)))./((size(blue,1)).*(size(blue,2)));
  2 件のコメント
Rik
Rik 2019 年 8 月 18 日
This code looks like it already calculates the averages. What is your question?
Sajina Rose
Sajina Rose 2019 年 8 月 18 日
I want to calculate average RGB value and also enhance the image by using that average values.........

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

採用された回答

Image Analyst
Image Analyst 2019 年 8 月 18 日
編集済み: Image Analyst 2019 年 8 月 18 日
What does "enhance" mean to you? Increase the saturation? If so, convert to HSV space with rgb2hsv() and multiply the second channel, the "S" channel, by some factor. See attached demo where I do that for the blue colored things.
Regarding your code, you could do it much simpler by
Ravg = mean2(red);
Gavg = mean2(green);
Bavg = mean2(blue);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Filtering and Enhancement についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by