-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gray.hpp
41 lines (34 loc) · 1.03 KB
/
Gray.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#pragma once
#ifndef AE_UTILS_GRAY_HPP
#define AE_UTILS_GRAY_HPP
#include <AE_Effect.h>
namespace Gray {
namespace Generic {
constexpr float KR = 0.298912f;
constexpr float KG = 0.586611f;
constexpr float KB = 0.114478f;
constexpr PF_Pixel32 ToGray(const PF_Pixel32 &in) noexcept {
float res = in.red * KR + in.green * KG + in.blue * KB;
return PF_Pixel32{in.alpha, res, res, res};
}
} // namespace Generic
namespace REC709 {
constexpr float KR = 0.2126f;
constexpr float KG = 0.7152f;
constexpr float KB = 0.0722f;
constexpr PF_Pixel32 ToGray(const PF_Pixel32 &in) noexcept {
float res = in.red * KR + in.green * KG + in.blue * KB;
return PF_Pixel32{in.alpha, res, res, res};
}
} // namespace REC709
namespace REC2020 {
constexpr float KR = 0.2627f;
constexpr float KG = 0.678f;
constexpr float KB = 0.0593f;
constexpr PF_Pixel32 ToGray(const PF_Pixel32 &in) noexcept {
float res = in.red * KR + in.green * KG + in.blue * KB;
return PF_Pixel32{in.alpha, res, res, res};
}
} // namespace REC2020
} // namespace Gray
#endif