QgsContrastEnhancement class
Manipulates raster pixel values so that they enhanceContrast or clip into a specified numerical range according to the specified ContrastEnhancementAlgorithm.
Contents
Public types
- enum ContrastEnhancementAlgorithm { NoEnhancement, StretchToMinimumMaximum, StretchAndClipToMinimumMaximum, ClipToMinimumMaximum, UserDefinedEnhancement }
- This enumerator describes the types of contrast enhancement algorithms that can be used.
Public static functions
- static auto contrastEnhancementAlgorithmFromString(const QString& contrastEnhancementString) -> ContrastEnhancementAlgorithm
- Deserialize ContrastEnhancementAlgorithm.
- static auto contrastEnhancementAlgorithmString(ContrastEnhancementAlgorithm algorithm) -> QString
- Returns a string to serialize ContrastEnhancementAlgorithm.
-
static auto maximumValuePossible(Qgis::
DataType) -> double - Helper function that returns the maximum possible value for a GDAL data type.
-
static auto minimumValuePossible(Qgis::
DataType) -> double - Helper function that returns the minimum possible value for a GDAL data type.
Public functions
- auto enhanceContrast(double value) -> int
- Applies the contrast enhancement to a value.
- auto isValueInDisplayableRange(double value) -> bool
- Returns true if a pixel value is in displayable range, false if pixel is outside of range (i.e.
- auto maximumValue() const -> double
- Returns the maximum value for the contrast enhancement range.
- auto minimumValue() const -> double
- Returns the minimum value for the contrast enhancement range.
- void setContrastEnhancementAlgorithm(ContrastEnhancementAlgorithm algorithm, bool generateTable = true)
- Sets the contrast enhancement algorithm.
- void setContrastEnhancementFunction(QgsContrastEnhancementFunction* function)
- Allows the user to set their own custom contrast enhancement function.
- void setMaximumValue(double value, bool generateTable = true)
- Sets the maximum value for the contrast enhancement range.
- void setMinimumValue(double value, bool generateTable = true)
- Sets the minimum value for the contrast enhancement range.
Function documentation
int QgsContrastEnhancement:: enhanceContrast(double value)
Applies the contrast enhancement to a value.
Return values are 0 - 254, -1 means the pixel was clipped and should not be displayed.
bool QgsContrastEnhancement:: isValueInDisplayableRange(double value)
Returns true if a pixel value is in displayable range, false if pixel is outside of range (i.e.
clipped).
void QgsContrastEnhancement:: setContrastEnhancementAlgorithm(ContrastEnhancementAlgorithm algorithm,
bool generateTable = true)
Sets the contrast enhancement algorithm.
The generateTable parameter is optional and is for performance improvements. If you know you are immediately going to set the Minimum or Maximum value, you can elect to not generate the lookup tale. By default it will be generated.
void QgsContrastEnhancement:: setContrastEnhancementFunction(QgsContrastEnhancementFunction* function)
Allows the user to set their own custom contrast enhancement function.
Ownership of function is transferred.
void QgsContrastEnhancement:: setMaximumValue(double value,
bool generateTable = true)
Sets the maximum value for the contrast enhancement range.
The generateTable parameter is optional and is for performance improvements. If you know you are immediately going to set the minimum value or the contrast enhancement algorithm, you can elect to not generate the lookup table. By default it will be generated.
void QgsContrastEnhancement:: setMinimumValue(double value,
bool generateTable = true)
Sets the minimum value for the contrast enhancement range.
The generateTable parameter is optional and is for performance improvements. If you know you are immediately going to set the maximum value or the contrast enhancement algorithm, you can elect to not generate the lookup table. By default it will be generated.