QGIS API Documentation  3.6.0-Noosa (5873452)
Public Types | Public Member Functions | Static Public Member Functions | List of all members
QgsContrastEnhancement Class Reference

Manipulates raster pixel values so that they enhanceContrast or clip into a specified numerical range according to the specified ContrastEnhancementAlgorithm. More...

#include <qgscontrastenhancement.h>

Public Types

enum  ContrastEnhancementAlgorithm {
  NoEnhancement, StretchToMinimumMaximum, StretchAndClipToMinimumMaximum, ClipToMinimumMaximum,
  UserDefinedEnhancement
}
 This enumerator describes the types of contrast enhancement algorithms that can be used. More...
 

Public Member Functions

 QgsContrastEnhancement (Qgis::DataType datatype=Qgis::Byte)
 
 QgsContrastEnhancement (const QgsContrastEnhancement &ce)
 
 ~QgsContrastEnhancement ()
 
ContrastEnhancementAlgorithm contrastEnhancementAlgorithm () const
 
int enhanceContrast (double value)
 Applies the contrast enhancement to a value. More...
 
bool isValueInDisplayableRange (double value)
 Returns true if a pixel value is in displayable range, false if pixel is outside of range (i.e. More...
 
double maximumValue () const
 Returns the maximum value for the contrast enhancement range. More...
 
double minimumValue () const
 Returns the minimum value for the contrast enhancement range. More...
 
const QgsContrastEnhancementoperator= (const QgsContrastEnhancement &)=delete
 
void readXml (const QDomElement &elem)
 
void setContrastEnhancementAlgorithm (ContrastEnhancementAlgorithm algorithm, bool generateTable=true)
 Sets the contrast enhancement algorithm. More...
 
void setContrastEnhancementFunction (QgsContrastEnhancementFunction *function)
 Allows the user to set their own custom contrast enhancement function. More...
 
void setMaximumValue (double value, bool generateTable=true)
 Sets the maximum value for the contrast enhancement range. More...
 
void setMinimumValue (double value, bool generateTable=true)
 Sets the minimum value for the contrast enhancement range. More...
 
void toSld (QDomDocument &doc, QDomElement &element) const
 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. More...
 
void writeXml (QDomDocument &doc, QDomElement &parentElem) const
 

Static Public Member Functions

static ContrastEnhancementAlgorithm contrastEnhancementAlgorithmFromString (const QString &contrastEnhancementString)
 Deserialize ContrastEnhancementAlgorithm. More...
 
static QString contrastEnhancementAlgorithmString (ContrastEnhancementAlgorithm algorithm)
 Returns a string to serialize ContrastEnhancementAlgorithm. More...
 
static double maximumValuePossible (Qgis::DataType)
 Helper function that returns the maximum possible value for a GDAL data type. More...
 
static double minimumValuePossible (Qgis::DataType)
 Helper function that returns the minimum possible value for a GDAL data type. More...
 

Detailed Description

Manipulates raster pixel values so that they enhanceContrast or clip into a specified numerical range according to the specified ContrastEnhancementAlgorithm.

Definition at line 42 of file qgscontrastenhancement.h.

Member Enumeration Documentation

◆ ContrastEnhancementAlgorithm

This enumerator describes the types of contrast enhancement algorithms that can be used.

Enumerator
NoEnhancement 
StretchToMinimumMaximum 
StretchAndClipToMinimumMaximum 
ClipToMinimumMaximum 
UserDefinedEnhancement 

Definition at line 48 of file qgscontrastenhancement.h.

Constructor & Destructor Documentation

◆ QgsContrastEnhancement() [1/2]

QgsContrastEnhancement::QgsContrastEnhancement ( Qgis::DataType  datatype = Qgis::Byte)

Definition at line 32 of file qgscontrastenhancement.cpp.

◆ QgsContrastEnhancement() [2/2]

QgsContrastEnhancement::QgsContrastEnhancement ( const QgsContrastEnhancement ce)

Definition at line 51 of file qgscontrastenhancement.cpp.

◆ ~QgsContrastEnhancement()

QgsContrastEnhancement::~QgsContrastEnhancement ( )

Definition at line 70 of file qgscontrastenhancement.cpp.

Member Function Documentation

◆ contrastEnhancementAlgorithm()

ContrastEnhancementAlgorithm QgsContrastEnhancement::contrastEnhancementAlgorithm ( ) const
inline

Definition at line 100 of file qgscontrastenhancement.h.

◆ contrastEnhancementAlgorithmFromString()

QgsContrastEnhancement::ContrastEnhancementAlgorithm QgsContrastEnhancement::contrastEnhancementAlgorithmFromString ( const QString &  contrastEnhancementString)
static

Deserialize ContrastEnhancementAlgorithm.

Definition at line 447 of file qgscontrastenhancement.cpp.

◆ contrastEnhancementAlgorithmString()

QString QgsContrastEnhancement::contrastEnhancementAlgorithmString ( ContrastEnhancementAlgorithm  algorithm)
static

Returns a string to serialize ContrastEnhancementAlgorithm.

Definition at line 429 of file qgscontrastenhancement.cpp.

◆ enhanceContrast()

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.

Definition at line 158 of file qgscontrastenhancement.cpp.

◆ isValueInDisplayableRange()

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).

Definition at line 208 of file qgscontrastenhancement.cpp.

◆ maximumValue()

double QgsContrastEnhancement::maximumValue ( ) const
inline

Returns the maximum value for the contrast enhancement range.

Definition at line 95 of file qgscontrastenhancement.h.

◆ maximumValuePossible()

double QgsContrastEnhancement::maximumValuePossible ( Qgis::DataType  dataType)
static

Helper function that returns the maximum possible value for a GDAL data type.

Definition at line 80 of file qgscontrastenhancement.cpp.

◆ minimumValue()

double QgsContrastEnhancement::minimumValue ( ) const
inline

Returns the minimum value for the contrast enhancement range.

Definition at line 98 of file qgscontrastenhancement.h.

◆ minimumValuePossible()

double QgsContrastEnhancement::minimumValuePossible ( Qgis::DataType  dataType)
static

Helper function that returns the minimum possible value for a GDAL data type.

Definition at line 116 of file qgscontrastenhancement.cpp.

◆ operator=()

const QgsContrastEnhancement& QgsContrastEnhancement::operator= ( const QgsContrastEnhancement )
delete

◆ readXml()

void QgsContrastEnhancement::readXml ( const QDomElement &  elem)

Definition at line 333 of file qgscontrastenhancement.cpp.

◆ setContrastEnhancementAlgorithm()

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.

Definition at line 218 of file qgscontrastenhancement.cpp.

◆ setContrastEnhancementFunction()

void QgsContrastEnhancement::setContrastEnhancementFunction ( QgsContrastEnhancementFunction function)

Allows the user to set their own custom contrast enhancement function.

Ownership of function is transferred.

Definition at line 248 of file qgscontrastenhancement.cpp.

◆ setMaximumValue()

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.

See also
setMinimumValue()

Definition at line 260 of file qgscontrastenhancement.cpp.

◆ setMinimumValue()

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.

See also
setMaximumValue()

Definition at line 286 of file qgscontrastenhancement.cpp.

◆ toSld()

void QgsContrastEnhancement::toSld ( QDomDocument &  doc,
QDomElement &  element 
) const

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.

Since
QGIS 3.6

Definition at line 380 of file qgscontrastenhancement.cpp.

◆ writeXml()

void QgsContrastEnhancement::writeXml ( QDomDocument &  doc,
QDomElement &  parentElem 
) const

Definition at line 312 of file qgscontrastenhancement.cpp.


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