15QMatrix4x4
matrixFromColumns(
const QVector3D &first,
const QVector3D &second,
const QVector3D &third)
18 ret(0, 0) = first.x();
19 ret(1, 0) = first.y();
20 ret(2, 0) = first.z();
21 ret(0, 1) = second.x();
22 ret(1, 1) = second.y();
23 ret(2, 1) = second.z();
24 ret(0, 2) = third.x();
25 ret(1, 2) = third.y();
26 ret(2, 2) = third.z();
44 return QVector2D(
x,
y);
60 .Z =
Y * (1 -
x -
y) /
y,
71 const double sum =
X +
Y +
Z;
89 const double sum =
X +
Y +
Z;
132 return QVector3D(
X,
Y,
Z);
151 static const QMatrix4x4 bradford = []() {
164 static const QMatrix4x4 inverseBradford = []() {
166 ret(0, 0) = 0.9869929;
167 ret(0, 1) = -0.1470543;
168 ret(0, 2) = 0.1599627;
169 ret(1, 0) = 0.4323053;
170 ret(1, 1) = 0.5183603;
171 ret(1, 2) = 0.0492912;
172 ret(2, 0) = -0.0085287;
173 ret(2, 1) = 0.0400428;
174 ret(2, 2) = 0.9684867;
177 if (sourceWhitepoint == destinationWhitepoint) {
180 const QVector3D factors = (bradford.map(destinationWhitepoint.
asVector())) / (bradford.map(sourceWhitepoint.
asVector()));
181 QMatrix4x4 adaptation{};
182 adaptation(0, 0) = factors.x();
183 adaptation(1, 1) = factors.y();
184 adaptation(2, 2) = factors.z();
185 return inverseBradford * adaptation * bradford;
194 return matrixFromColumns(r * component_scale.x(), g * component_scale.y(), b * component_scale.z());
200 m_red * (1 - factor) + one.
red() * factor,
209 return std::abs(0.5 * (
p1.x() * (
p2.y() -
p3.y()) +
p2.x() * (
p3.y() -
p1.y()) +
p3.x() * (
p1.y() -
p2.y())));
217 if (gamutArea < 0.02) {
226 if (std::abs(area1 + area2 + area3 - gamutArea) > 0.001) {
252 , m_toXYZ(calculateToXYZMatrix(red, green, blue, white))
253 , m_fromXYZ(m_toXYZ.inverted())
258 :
Colorimetry(red.toXYZ(), green.toXYZ(), blue.toXYZ(), white.toXYZ())
263 : m_white(
xyY{white.x, white.y, 1.0}.toXYZ())
320 newWhitepoint.
toXYZ(),
331 newWhitePoint.
toXYZ(),
410 xy{1.0 / 3.0, 1.0 / 3.0}.
toXYZ(),
432 QDebugStateSaver saver(debug);
433 debug.nospace() <<
"xy(x: " <<
value.x <<
", y: " <<
value.y <<
")";
438 QDebugStateSaver saver(debug);
439 debug.nospace() <<
"xyY(x: " <<
value.x <<
", y: " <<
value.y <<
", Y: " <<
value.Y <<
")";
444 QDebugStateSaver saver(debug);
445 debug.nospace() <<
"XYZ(X: " <<
value.X <<
", Y: " <<
value.Y <<
", Z: " <<
value.Z <<
")";
450 QDebugStateSaver saver(debug);
451 debug.nospace() <<
"Colorimetry(Red: " <<
value.red().toxy() <<
", Green: " <<
value.green().toxy() <<
", Blue: " <<
value.blue().toxy() <<
", White: " <<
value.white().toxy() <<
")";
float value(const T *src, size_t ch)
QMatrix4x4 relativeColorimetricTo(const Colorimetry &other) const
const QMatrix4x4 & fromXYZ() const
static const Colorimetry GenericFilm
Colorimetry interpolateGamutTo(const Colorimetry &one, double factor) const
Colorimetry(XYZ red, XYZ green, XYZ blue, XYZ white)
static QMatrix4x4 chromaticAdaptationMatrix(XYZ sourceWhitepoint, XYZ destinationWhitepoint)
static const Colorimetry PAL
static QMatrix4x4 calculateToXYZMatrix(XYZ red, XYZ green, XYZ blue, XYZ white)
static const Colorimetry NTSC
static const Colorimetry PAL_M
static const Colorimetry AdobeRGB
QMatrix4x4 absoluteColorimetricTo(const Colorimetry &other) const
static const Colorimetry BT709
static const Colorimetry CIEXYZ
QMatrix4x4 fromLMS() const
Colorimetry withWhitepoint(xyY newWhitePoint) const
const QMatrix4x4 & toXYZ() const
static bool isReal(xy red, xy green, xy blue, xy white)
const XYZ & white() const
Colorimetry adaptedTo(xyY newWhitepoint) const
const XYZ & green() const
bool operator==(const Colorimetry &other) const
static const Colorimetry DisplayP3
static const Colorimetry BT2020
static bool isValid(xy red, xy green, xy blue, xy white)
static const Colorimetry DCIP3
static bool qFuzzyCompare(half p1, half p2)
static bool qFuzzyIsNull(half h)
QMatrix4x4 matrixFromColumns(const QVector3D &first, const QVector3D &second, const QVector3D &third)
static const QMatrix4x4 s_xyzToDolbyLMS
QDebug operator<<(QDebug debug, const xy &value)
static const QMatrix4x4 s_inverseDolbyLMS
static double triangleArea(QVector2D p1, QVector2D p2, QVector2D p3)
static XYZ fromVector(const QVector3D &vector)
bool operator==(const XYZ &other) const
XYZ operator*(double factor) const
XYZ operator/(double factor) const
QVector3D asVector() const
XYZ operator+(const XYZ &other) const
bool operator==(const xyY &other) const
QVector2D asVector() const
bool operator==(const xy &other) const