math - Calculating how "colorful" a color is -
i create ratio between 0-1 of how "colorful" color is, colorful mean:
- black colors have ratio 0 (no light)
- white colors have ratio 0 (no saturation)
- a saturated / lighted color has ratio 1
i tried converting color hsv colorspace , calculating ratio as:
ratio = (color.value / 100) * (color.saturation / 100) this works somewhat, feels curve wrong, example
hsv(hue=0, saturation=80, value=80)
only gives ratio of 0.64 looks close saturated / lighted color.
maybe need somehow create "ease-out" on values? thought taking human perception of colors account aswell (using lab or yuv colorspaces) dont think needed here, might wrong.
the definition of saturation hsv not want, because not compensate lightness of color.
from the wikipedia article on colorfulness:
[perceived saturation] proportion of pure chromatic color in total color sensation.
where sab saturation, l* lightness , c*ab chroma of color.
this definition uses l* , c*ab components of cielab colorspace. guess application use lab colorspace instead. code this:
function perceived_saturation(l, a, b) return 100 * sqrt(a*a + b*b) / sqrt(l*l + a*a + b*b) for example color rgb = (204, 41, 41), returns perceived saturation of 86%, when converting color via path rgb → srgb → lab.


Comments
Post a Comment