alainloisel / ehost

Automatically exported from code.google.com/p/ehost
0 stars 0 forks source link

detect gray level #272

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Current we use RGB mode to detect the gray level, however, it isn't working so 
well. 

Original issue reported on code.google.com by jwleng@gmail.com on 2 Aug 2012 at 8:23

GoogleCodeExporter commented 8 years ago
Following method is the previous solution we used to judge if a color is dark 
or light.
if ($R + $G + $B >= 450) {
    // it's light color
}

It's very simple,but not good, especially while the B is very big compared to 
others. Considering eyes have different sensitive level to red, blue and gree. 
We decide to use YUV mode instead of RBG mode,Y here is the light level, 
defined as following:

$grayLevel = $R * 0.299 + $G * 0.587 + $B * 0.114;

if ($grayLevel >= 192) {
    // it's a light color
}

-------------------------------------
It's applied on the dialog of "class manager" and the list of annotation text 
on result editor.

(The screenshot is attached.)
-------------------------------------

Original comment by jwleng@gmail.com on 2 Aug 2012 at 8:28

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by jwleng@gmail.com on 10 Oct 2012 at 6:34