What luminosity value is considered as "light"?

kkot :

I have to decide whether image is light or dark, and I have equation like this:

double luminosity = ((r * 0.2126) + (g * 0.7152) + (b * 0.0722)) / 255

Using this equation, what pixel value is considered as 'light'?

Are there any other popular / best practices in deciding if image is light / dark

vs97 :

Your range of values is from when r, g, b equal 0 (pixel is black) and to when r, g, b all equal 255 (pixel is white)- plugging that in will give us a luminosity range of [0, 1].

One way would be to simply say - if luminosity value is below 0.5, this is "dark pixel", if luminosity is larger than 0.5 - that is "light pixel".

If inside the image we have a majority of dark pixels, the image is dark. If majority of pixels in image are light, image is light. Alternatively, get luminosity value for each pixel in the image and take the average - and then use the average luminosity to determine if image is light or dark.

Some values for individual pixel examples:

rgb(245, 100, 3) = luminosity 0.49 - darker

enter image description here

rgb(245, 120, 3) = luminosity 0.54 - lighter

enter image description here

rgb(100, 140, 3) = luminosity 0.48 - darker

enter image description here

rgb(100, 200, 3) = luminosity 0.64 - lighter

enter image description here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=117753&siteId=1