21#ifndef QGSCONTRASTENHANCEMENT_H
22#define QGSCONTRASTENHANCEMENT_H
56 UserDefinedEnhancement
76 return std::numeric_limits<unsigned char>::max();
78 return std::numeric_limits<int8_t>::max();
80 return std::numeric_limits<unsigned short>::max();
82 return std::numeric_limits<short>::max();
84 return std::numeric_limits<unsigned int>::max();
86 return std::numeric_limits<int>::max();
88 return std::numeric_limits<float>::max();
90 return std::numeric_limits<double>::max();
92 return std::numeric_limits<short>::max();
94 return std::numeric_limits<int>::max();
96 return std::numeric_limits<float>::max();
98 return std::numeric_limits<double>::max();
106 return std::numeric_limits<double>::max();
117 return std::numeric_limits<unsigned char>::min();
119 return std::numeric_limits<int8_t>::min();
121 return std::numeric_limits<unsigned short>::min();
123 return std::numeric_limits<short>::min();
125 return std::numeric_limits<unsigned int>::min();
127 return std::numeric_limits<int>::min();
129 return std::numeric_limits<float>::max() * -1.0;
131 return std::numeric_limits<double>::max() * -1.0;
133 return std::numeric_limits<short>::min();
135 return std::numeric_limits<int>::min();
137 return std::numeric_limits<float>::max() * -1.0;
139 return std::numeric_limits<double>::max() * -1.0;
147 return std::numeric_limits<double>::max() * -1.0;
153 static QString contrastEnhancementAlgorithmString( ContrastEnhancementAlgorithm
algorithm );
158 static ContrastEnhancementAlgorithm contrastEnhancementAlgorithmFromString(
const QString &contrastEnhancementString );
171 int enhanceContrast(
double value );
177 bool isValueInDisplayableRange(
double value );
186 void setContrastEnhancementAlgorithm( ContrastEnhancementAlgorithm
algorithm,
bool generateTable =
true );
204 void setMaximumValue(
double value,
bool generateTable =
true );
216 void setMinimumValue(
double value,
bool generateTable =
true );
218 void writeXml( QDomDocument &doc, QDomElement &parentElem )
const;
220 void readXml(
const QDomElement &elem );
230 void toSld( QDomDocument &doc, QDomElement &element )
const;
238 ContrastEnhancementAlgorithm mContrastEnhancementAlgorithm = NoEnhancement;
241 std::unique_ptr< QgsContrastEnhancementFunction > mContrastEnhancementFunction;
244 bool mEnhancementDirty =
false;
247 int *mLookupTable =
nullptr;
250 double mMinimumValue;
253 double mMaximumValue;
259 double mRasterDataTypeRange;
262 double mLookupTableOffset;
265 bool generateLookupTable();
268 int calculateContrastEnhancementValue(
double );
DataType
Raster data types.
@ Float32
Thirty two bit floating point (float)
@ CFloat64
Complex Float64.
@ Int16
Sixteen bit signed integer (qint16)
@ ARGB32_Premultiplied
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32_Premultiplied.
@ Int8
Eight bit signed integer (qint8) (added in QGIS 3.30)
@ UInt16
Sixteen bit unsigned integer (quint16)
@ Byte
Eight bit unsigned integer (quint8)
@ UnknownDataType
Unknown or unspecified type.
@ ARGB32
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32.
@ Int32
Thirty two bit signed integer (qint32)
@ Float64
Sixty four bit floating point (double)
@ CFloat32
Complex Float32.
@ UInt32
Thirty two bit unsigned integer (quint32)
A contrast enhancement function is the base class for all raster contrast enhancements.
Handles contrast enhancement and clipping.
ContrastEnhancementAlgorithm
This enumerator describes the types of contrast enhancement algorithms that can be used.
@ StretchToMinimumMaximum
Linear histogram.
@ StretchAndClipToMinimumMaximum
@ NoEnhancement
Default color scaling algorithm, no scaling is applied.
static double maximumValuePossible(Qgis::DataType dataType)
Helper function that returns the maximum possible value for a data type.
double minimumValue() const
Returns the minimum value for the contrast enhancement range.
static double minimumValuePossible(Qgis::DataType dataType)
Helper function that returns the minimum possible value for a data type.
const QgsContrastEnhancement & operator=(const QgsContrastEnhancement &)=delete
ContrastEnhancementAlgorithm contrastEnhancementAlgorithm() const
double maximumValue() const
Returns the maximum value for the contrast enhancement range.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call