Krita Source Code Documentation
Loading...
Searching...
No Matches
KisPiecewiseFilmicToneMapAdjustment< LuminanceModel > Class Template Reference
+ Inheritance diagram for KisPiecewiseFilmicToneMapAdjustment< LuminanceModel >:

Public Member Functions

 KisPiecewiseFilmicToneMapAdjustment (const KoColorSpace *sourceSpace)
 
int parameterId (const QString &name) const override
 
QList< QString > parameters () const override
 
void setParameter (int id, const QVariant &parameter) override
 
void transform (const quint8 *srcU8, quint8 *dstU8, qint32 nPixels) const override
 
- Public Member Functions inherited from KoColorTransformation
virtual bool isValid () const
 
void setParameters (const QHash< QString, QVariant > &parameters)
 
virtual ~KoColorTransformation ()
 

Private Attributes

float m_shoulderAngle {1.0}
 
float m_shoulderLength {0.5}
 
float m_shoulderStrength {2.0}
 
const KoColorSpace * m_sourceSpace
 
float m_toeLength {0.5}
 
float m_toeStrength {0.5}
 

Detailed Description

template<class LuminanceModel>
class KisPiecewiseFilmicToneMapAdjustment< LuminanceModel >

Definition at line 115 of file kis_tonemap_adjustment.cpp.

Constructor & Destructor Documentation

◆ KisPiecewiseFilmicToneMapAdjustment()

template<class LuminanceModel >
KisPiecewiseFilmicToneMapAdjustment< LuminanceModel >::KisPiecewiseFilmicToneMapAdjustment ( const KoColorSpace * sourceSpace)
inline

Definition at line 118 of file kis_tonemap_adjustment.cpp.

118: m_sourceSpace(sourceSpace) {}

Member Function Documentation

◆ parameterId()

template<class LuminanceModel >
int KisPiecewiseFilmicToneMapAdjustment< LuminanceModel >::parameterId ( const QString & name) const
inlineoverridevirtual

Get the parameter id for a parameter name

Reimplemented from KoColorTransformation.

Definition at line 159 of file kis_tonemap_adjustment.cpp.

160 {
161 if (name == "toeStrength") {
162 return 0;
163 } else if (name == "toeLength") {
164 return 1;
165 } else if (name == "shoulderStrength") {
166 return 2;
167 } else if (name == "shoulderLength") {
168 return 3;
169 } else if (name == "shoulderAngle") {
170 return 4;
171 }
172 return -1;
173 }

◆ parameters()

template<class LuminanceModel >
QList< QString > KisPiecewiseFilmicToneMapAdjustment< LuminanceModel >::parameters ( ) const
inlineoverridevirtual
Returns
the list of parameters

Reimplemented from KoColorTransformation.

Definition at line 148 of file kis_tonemap_adjustment.cpp.

149 {
150 QList<QString> list;
151 list << "toeStrength";
152 list << "toeLength";
153 list << "shoulderStrength";
154 list << "shoulderLength";
155 list << "shoulderAngle";
156 return list;
157 }

◆ setParameter()

template<class LuminanceModel >
void KisPiecewiseFilmicToneMapAdjustment< LuminanceModel >::setParameter ( int id,
const QVariant & parameter )
inlineoverridevirtual

Update one parameter of a cached transformation object.

Reimplemented from KoColorTransformation.

Definition at line 175 of file kis_tonemap_adjustment.cpp.

176 {
177 switch(id)
178 {
179 case 0:
180 m_toeStrength = parameter.toFloat();
181 break;
182 case 1:
183 m_toeLength = parameter.toFloat();
184 break;
185 case 2:
186 m_shoulderStrength = parameter.toFloat();
187 break;
188 case 3:
189 m_shoulderLength = parameter.toFloat();
190 break;
191 case 4:
192 m_shoulderAngle = parameter.toFloat();
193 break;
194 default:
195 ;
196 }
197 }

References KisPiecewiseFilmicToneMapAdjustment< LuminanceModel >::m_shoulderAngle, KisPiecewiseFilmicToneMapAdjustment< LuminanceModel >::m_shoulderLength, KisPiecewiseFilmicToneMapAdjustment< LuminanceModel >::m_shoulderStrength, KisPiecewiseFilmicToneMapAdjustment< LuminanceModel >::m_toeLength, and KisPiecewiseFilmicToneMapAdjustment< LuminanceModel >::m_toeStrength.

◆ transform()

template<class LuminanceModel >
void KisPiecewiseFilmicToneMapAdjustment< LuminanceModel >::transform ( const quint8 * src,
quint8 * dst,
qint32 nPixels ) const
inlineoverridevirtual

This function apply the transformation on a given number of pixels.

Parameters
srca pointer to the source pixels
dsta pointer to the destination pixels
nPixelsthe number of pixels

This function may or may not be thread safe. You need to create one KoColorTransformation per thread.

Implements KoColorTransformation.

Definition at line 120 of file kis_tonemap_adjustment.cpp.

121 {
122 if (!m_sourceSpace) {
123 qWarning() << "no source space!";
124 return;
125 }
126
129
130 QVector<float> originalChannels(m_sourceSpace->channelCount());
131 std::unique_ptr<quint8[]> tmpOriginal(new quint8[m_sourceSpace->pixelSize()]);
132 while (nPixels > 0) {
133 m_sourceSpace->normalisedChannelsValue(srcU8, originalChannels);
134
135 float Y = LuminanceModel::luminance(originalChannels.data());
136 Y = curve.evalCurve(Y);
137 LuminanceModel::setLuminance(originalChannels.data(), Y);
138
139 m_sourceSpace->fromNormalisedChannelsValue(tmpOriginal.get(), originalChannels);
140 memcpy(dstU8, tmpOriginal.get(), m_sourceSpace->pixelSize());
141
142 --nPixels;
143 srcU8 += m_sourceSpace->pixelSize();
144 dstU8 += m_sourceSpace->pixelSize();
145 }
146 }
virtual quint32 pixelSize() const =0
virtual quint32 channelCount() const =0
virtual void normalisedChannelsValue(const quint8 *pixel, QVector< float > &channels) const =0
virtual void fromNormalisedChannelsValue(quint8 *pixel, const QVector< float > &values) const =0
const QString Y
The piecewiseFilmicCurve class Implement's Hable's piecewise filmic curve. https://filmicworlds....
static PiecewiseFilmicCurve fromUserParams(float toeStrength=0.5, float toeLength=0.5, float shoulderStrength=2.0, float shoulderLength=0.5, float shoulderAngle=1.0)

References KoColorSpace::channelCount(), KoGamutMappingUtils::PiecewiseFilmicCurve::evalCurve(), KoColorSpace::fromNormalisedChannelsValue(), KoGamutMappingUtils::PiecewiseFilmicCurve::fromUserParams(), KisPiecewiseFilmicToneMapAdjustment< LuminanceModel >::m_shoulderAngle, KisPiecewiseFilmicToneMapAdjustment< LuminanceModel >::m_shoulderLength, KisPiecewiseFilmicToneMapAdjustment< LuminanceModel >::m_shoulderStrength, KisPiecewiseFilmicToneMapAdjustment< LuminanceModel >::m_sourceSpace, KisPiecewiseFilmicToneMapAdjustment< LuminanceModel >::m_toeLength, KisPiecewiseFilmicToneMapAdjustment< LuminanceModel >::m_toeStrength, KoColorSpace::normalisedChannelsValue(), and KoColorSpace::pixelSize().

Member Data Documentation

◆ m_shoulderAngle

template<class LuminanceModel >
float KisPiecewiseFilmicToneMapAdjustment< LuminanceModel >::m_shoulderAngle {1.0}
private

Definition at line 205 of file kis_tonemap_adjustment.cpp.

205{1.0};

◆ m_shoulderLength

template<class LuminanceModel >
float KisPiecewiseFilmicToneMapAdjustment< LuminanceModel >::m_shoulderLength {0.5}
private

Definition at line 204 of file kis_tonemap_adjustment.cpp.

204{0.5};

◆ m_shoulderStrength

template<class LuminanceModel >
float KisPiecewiseFilmicToneMapAdjustment< LuminanceModel >::m_shoulderStrength {2.0}
private

Definition at line 203 of file kis_tonemap_adjustment.cpp.

203{2.0};

◆ m_sourceSpace

template<class LuminanceModel >
const KoColorSpace* KisPiecewiseFilmicToneMapAdjustment< LuminanceModel >::m_sourceSpace
private

Definition at line 200 of file kis_tonemap_adjustment.cpp.

◆ m_toeLength

template<class LuminanceModel >
float KisPiecewiseFilmicToneMapAdjustment< LuminanceModel >::m_toeLength {0.5}
private

Definition at line 202 of file kis_tonemap_adjustment.cpp.

202{0.5};

◆ m_toeStrength

template<class LuminanceModel >
float KisPiecewiseFilmicToneMapAdjustment< LuminanceModel >::m_toeStrength {0.5}
private

Definition at line 201 of file kis_tonemap_adjustment.cpp.

201{0.5};

The documentation for this class was generated from the following file: