Class: QgsContrastEnhancement¶
Handles contrast enhancement and clipping.
Manipulates raster or point cloud pixel values so that they enhance contrast or clip into a specified numerical range according to the specified ContrastEnhancementAlgorithm.
Methods
Applies the contrast enhancement to a value. |
|
Returns |
|
Returns the maximum value for the contrast enhancement range. |
|
Returns the minimum value for the contrast enhancement range. |
|
Sets the contrast enhancement algorithm. |
|
Allows the user to set their own custom contrast enhancement function. |
|
Sets the maximum value for the contrast enhancement range. |
|
Sets the minimum value for the contrast enhancement range. |
|
Write ContrastEnhancement tags following SLD v1.0 specs SLD1.0 is limited to the parameters listed in: https://docs.geoserver.org/stable/en/user/styling/sld/reference/rastersymbolizer.html#contrastenhancement Btw only sld:Normalize + vendor options are supported because there is no clear mapping of ContrastEnhancement parameters to support sld:Histogram or sld:GammaValue |
|
Static Methods
Deserialize ContrastEnhancementAlgorithm. |
|
Returns a string to serialize ContrastEnhancementAlgorithm. |
|
Helper function that returns the maximum possible value for a data type. |
|
Helper function that returns the minimum possible value for a data type. |
Attributes
- class qgis.core.QgsContrastEnhancement[source]¶
Bases:
object
- __init__(datatype: Qgis.DataType = Qgis.DataType.Byte)
Constructor for QgsContrastEnhancement, for the specified data type.
- Parameters:
datatype (Qgis.DataType = Qgis.DataType.Byte)
- __init__(ce: QgsContrastEnhancement)
- Parameters:
- ClipToMinimumMaximum = 3¶
- class ContrastEnhancementAlgorithm¶
Bases:
int
- NoEnhancement = 0¶
- StretchAndClipToMinimumMaximum = 2¶
- StretchToMinimumMaximum = 1¶
- UserDefinedEnhancement = 4¶
- contrastEnhancementAlgorithm(self) QgsContrastEnhancement.ContrastEnhancementAlgorithm [source]¶
- Return type:
- static contrastEnhancementAlgorithmFromString(contrastEnhancementString: str | None) QgsContrastEnhancement.ContrastEnhancementAlgorithm [source]¶
Deserialize ContrastEnhancementAlgorithm.
- Parameters:
contrastEnhancementString (Optional[str])
- Return type:
- static contrastEnhancementAlgorithmString(algorithm: QgsContrastEnhancement.ContrastEnhancementAlgorithm) str [source]¶
Returns a string to serialize ContrastEnhancementAlgorithm.
- Parameters:
algorithm (QgsContrastEnhancement.ContrastEnhancementAlgorithm)
- Return type:
str
- enhanceContrast(self, value: float) int [source]¶
Applies the contrast enhancement to a
value
. Return values are 0 - 255, -1 means the pixel was clipped and should not be displayed.- Parameters:
value (float)
- Return type:
int
- isValueInDisplayableRange(self, value: float) bool [source]¶
Returns
True
if a pixelvalue
is in displayable range,False
if pixel is outside of range (i.e. clipped).- Parameters:
value (float)
- Return type:
bool
- maximumValue(self) float [source]¶
Returns the maximum value for the contrast enhancement range.
- Return type:
float
- static maximumValuePossible(dataType: Qgis.DataType) float [source]¶
Helper function that returns the maximum possible value for a data type.
- Parameters:
dataType (Qgis.DataType)
- Return type:
float
- minimumValue(self) float [source]¶
Returns the minimum value for the contrast enhancement range.
- Return type:
float
- static minimumValuePossible(dataType: Qgis.DataType) float [source]¶
Helper function that returns the minimum possible value for a data type.
- Parameters:
dataType (Qgis.DataType)
- Return type:
float
- setContrastEnhancementAlgorithm(self, algorithm: QgsContrastEnhancement.ContrastEnhancementAlgorithm, generateTable: bool = True)[source]¶
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.- Parameters:
algorithm (QgsContrastEnhancement.ContrastEnhancementAlgorithm)
generateTable (bool = True)
- setContrastEnhancementFunction(self, function: QgsContrastEnhancementFunction | None)[source]¶
Allows the user to set their own custom contrast enhancement
function
. Ownership offunction
is transferred.- Parameters:
function (Optional[QgsContrastEnhancementFunction])
- setMaximumValue(self, value: float, generateTable: bool = True)[source]¶
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.See also
- Parameters:
value (float)
generateTable (bool = True)
- setMinimumValue(self, value: float, generateTable: bool = True)[source]¶
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.See also
- Parameters:
value (float)
generateTable (bool = True)
- toSld(self, doc: QDomDocument, element: QDomElement)[source]¶
Write ContrastEnhancement tags following SLD v1.0 specs SLD1.0 is limited to the parameters listed in: https://docs.geoserver.org/stable/en/user/styling/sld/reference/rastersymbolizer.html#contrastenhancement Btw only sld:Normalize + vendor options are supported because there is no clear mapping of ContrastEnhancement parameters to support sld:Histogram or sld:GammaValue
Added in version 3.6.
- Parameters:
doc (QDomDocument)
element (QDomElement)