used BT601 instead of BT709 in RGB2Lum

This commit is contained in:
HuYingzhuo(hugo/hyzboy) 2023-11-01 19:13:54 +08:00
parent b5c66fe2cd
commit 1141f37cc4

View File

@ -5,19 +5,24 @@
namespace hgl
{
template<typename T> constexpr T RGB2Lum(const T &r, const T &g, const T &b)
template<typename T> constexpr T RGB2Lum(const T &r,const T &g,const T &b)
{
return 0.2126f*r+0.7152f*g+0.0722f*b;
return T(0.299f*r+0.587f*g+0.114f*b);
}
template<> constexpr uint8 RGB2Lum(const uint8 &r, const uint8 &g, const uint8 &b)
template<> constexpr uint8 RGB2Lum(const uint8 &r,const uint8 &g,const uint8 &b)
{
return (r*54+g*183+b*19)>>8;
return uint8((r*77+g*151+b*28)>>8);
}
template<typename T> constexpr T RGB2LumBT709(const T &r, const T &g, const T &b)
{
return T(0.2126f*r+0.7152f*g+0.0722f*b);
}
template<typename T> constexpr T RGB2LumBT2020(const T &r,const T &g,const T &b)
{
return 0.2627f*r+0.6780f*g+0.0593f*b;
return T(0.2627f*r+0.6780f*g+0.0593f*b);
}
}//namespace hgl
#endif//HGL_COLOR_LUM_INCLUDE