Mean luminance Values of an Image
36 次查看(过去 30 天)
显示 更早的评论
Hi ALL,
I want to calculate the means luminance value of an image block
i found the formula is..
luminance= 0.3 R + 0.59 G + 0.11 B
but how i can calculate the R, G and B values.
i know that
R=rgb_img(:,:,1)
G=rgb_img(:,:,2)
B=rgb_img(:,:,3)
but it give in the shape of matrix, i think i need only a single value of R,G and B, to use above luminance formula.
please help me out.
Thanks in Advance
0 个评论
采纳的回答
Walter Roberson
2013-2-1
mean2(rgb2gray(rgb_img))
provided you have the toolbox installed.
Otherwise, calculate a luminance array using the R, G, B arrays, and then mean2() the luminance array.
4 个评论
Walter Roberson
2017-7-1
rgb2gray converts RGB values to grayscale values by forming a weighted sum of the R, G, and B components:
0.2989 * R + 0.5870 * G + 0.1140 * B
[...] First convert the gamma-compressed RGB values to linear RGB, and then
Y = 0.2126 R + 0.7152 G + 0.0722 B
And then https://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color (see original for links to sources)
Do you mean brightness? Perceived brightness? Luminance?
Luminance (standard for certain colour spaces): (0.2126*R + 0.7152*G + 0.0722*B)
Luminance (perceived option 1): (0.299*R + 0.587*G + 0.114*B)
Luminance (perceived option 2, slower to calculate): sqrt( 0.299*R^2 + 0.587*G^2 + 0.114*B^2 )
So we see that the "Rleative luminance" given in the Wikipedia article is "for certain colour spaces", and the "Perceived option 1" is what is used by rgb2gray. If I recall correctly, the second perceived one is considered slightly more correct in terms of theory.
So... you have to decide which colorspace you are working in, and which variety of "luminance" you want.
更多回答(1 个)
Rodrigo Souza
2019-1-28
Hi all,
I have put together three scripts for calculating (mean and SD), matching or normalizing luminance of colored images (using HSV and CIE Lab color spaces).
They may be specially useful for pupillometry measures of infant research.
The scripts and their descriptions are available at my OSF page: https://osf.io/auzjy/
Hope it helps.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!