Krita Source Code Documentation
Loading...
Searching...
No Matches
KoGamutMappingUtils.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2026 Wolthera van Hövell tot Westerflier <griffinvalley@gmail.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5 */
6#ifndef KOGAMUTMAPPINGUTILS_H
7#define KOGAMUTMAPPINGUTILS_H
8
9#include <QPointF>
10#include <QVector>
11
12#include <KoColorimetryUtils.h>
13#include <KoColorProfile.h>
14
15#include "kritapigment_export.h"
16
23float KRITAPIGMENT_EXPORT deltaE76(const QVector<float> &a, const QVector<float> &b);
24
31QVector4D KRITAPIGMENT_EXPORT XYZToOkLab(const QVector4D &xyz);
32QVector4D KRITAPIGMENT_EXPORT OkLabToXYZ(const QVector4D &okLab);
33
41QVector4D KRITAPIGMENT_EXPORT XYZToICtCp(const QVector4D &xyz);
42QVector4D KRITAPIGMENT_EXPORT ICtCpToXYZ(const QVector4D &iCtCp);
43
55
62QMap<float, QPointF> KRITAPIGMENT_EXPORT getGamutCuspDescription(const KoColorProfile *profile, KoGamutMappingUtils::MappingModel model, const int samplesPerChannel = 5);
63QPointF KRITAPIGMENT_EXPORT cuspForHue(const QMap<float, QPointF> &gamutCuspDescription, const float hue);
64
65
70
78float KRITAPIGMENT_EXPORT reinhardToneMapping(const float linearY, const float maxY);
79
86struct KRITAPIGMENT_EXPORT PiecewiseFilmicCurve {
87
88 QPointF p0;
89 QPointF p1;
90
91 float inverseMaxWhite {1.0};
92
93 struct Segment {
94 float lnA{0.0f};
95 float b{0.0f};
96
97 float offsetX{0.0f};
98 float offsetY{0.0f};
99 float scaleX{1.0f};
100 float scaleY{1.0f};
101
102 float evalSegment(const float x);
103 };
104
106
107 PiecewiseFilmicCurve(float maxWhite, QPointF point0, QPointF point1, QPointF overshootPoint);
108 static PiecewiseFilmicCurve fromUserParams(float toeStrength = 0.5, float toeLength = 0.5, float shoulderStrength = 2.0, float shoulderLength = 0.5, float shoulderAngle = 1.0);
109
110 float evalCurve(const float x);
111};
112
113
114
115};
116
117#endif // KOGAMUTMAPPINGUTILS_H
QVector4D KRITAPIGMENT_EXPORT ICtCpToXYZ(const QVector4D &iCtCp)
float KRITAPIGMENT_EXPORT deltaE76(const QVector< float > &a, const QVector< float > &b)
deltaE76 calculates the difference between two colors, represented as normalized channels.
QVector4D KRITAPIGMENT_EXPORT OkLabToXYZ(const QVector4D &okLab)
QMap< float, QPointF > KRITAPIGMENT_EXPORT getGamutCuspDescription(const KoColorProfile *profile, KoGamutMappingUtils::MappingModel model, const int samplesPerChannel=5)
getGamutCuspDescription Generates a hexagonal gamut cusp description from a RGB or CMYK profile.
QVector4D KRITAPIGMENT_EXPORT XYZToICtCp(const QVector4D &xyz)
XYZToICtCp Ad-hoc implementation of ICtCp for use in filters. Unlike the official YCbCr-compatible st...
MappingModel
The MappingModel enum This represents the preferred model to do gamut and/or tone mapping in.
QVector4D KRITAPIGMENT_EXPORT XYZToOkLab(const QVector4D &xyz)
XYZToOkLab Ad-hoc implementation of OkLAB. This takes a QVector4D and transforms it to the OkLAB mode...
float KRITAPIGMENT_EXPORT reinhardToneMapping(const float linearY, const float maxY)
reinhardToneMapping Implements 'extended' reinhard tonemapping.
QPointF KRITAPIGMENT_EXPORT cuspForHue(const QMap< float, QPointF > &gamutCuspDescription, const float hue)
The piecewiseFilmicCurve class Implement's Hable's piecewise filmic curve. https://filmicworlds....