Mean luminance Values of an Image
조회 수: 49 (최근 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!