|
QGIS API Documentation
master-3f58142
|
Manipulates raster pixel values so that they enhanceContrast or clip into a specified numerical range according to the specified ContrastEnhancementAlgorithm. More...
#include <qgscontrastenhancement.h>
Collaboration diagram for QgsContrastEnhancement: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 theDatatype=QGis::Byte) | |
| QgsContrastEnhancement (const QgsContrastEnhancement &ce) | |
| ~QgsContrastEnhancement () | |
| ContrastEnhancementAlgorithm | contrastEnhancementAlgorithm () const |
| int | enhanceContrast (double) |
| Apply the contrast enhancement to a value. | |
| bool | isValueInDisplayableRange (double) |
| Return true if pixel is in stretable range, false if pixel is outside of range (i.e., clipped) | |
| double | maximumValue () const |
| Return the maximum value for the contrast enhancement range. | |
| double | minimumValue () const |
| Return the minimum value for the contrast enhancement range. | |
| void | readXML (const QDomElement &elem) |
| void | setContrastEnhancementAlgorithm (ContrastEnhancementAlgorithm, bool generateTable=true) |
| Set the contrast enhancement algorithm. | |
| void | setContrastEnhancementFunction (QgsContrastEnhancementFunction *) |
| A public method that allows the user to set their own custom contrast enhancment function. | |
| void | setMaximumValue (double, bool generateTable=true) |
| Set the maximum value for the contrast enhancement range. | |
| void | setMinimumValue (double, bool generateTable=true) |
| Return the minimum value for the contrast enhancement range. | |
| void | writeXML (QDomDocument &doc, QDomElement &parentElem) const |
Static Public Member Functions | |
| static ContrastEnhancementAlgorithm | contrastEnhancementAlgorithmFromString (const QString &contrastEnhancementString) |
| static QString | contrastEnhancementAlgorithmString (ContrastEnhancementAlgorithm algorithm) |
| static double | maximumValuePossible (QGis::DataType) |
| Helper function that returns the maximum possible value for a GDAL data type. | |
| static double | minimumValuePossible (QGis::DataType) |
| Helper function that returns the minimum possible value for a GDAL data type. | |
Private Member Functions | |
| int | calculateContrastEnhancementValue (double) |
| Method to calculate the actual enhanceContrasted value(s) | |
| bool | generateLookupTable () |
| Method to generate a new lookup table. | |
Private Attributes | |
| ContrastEnhancementAlgorithm | mContrastEnhancementAlgorithm |
| Current contrast enhancement algorithm. | |
| QgsContrastEnhancementFunction * | mContrastEnhancementFunction |
| Pointer to the contrast enhancement function. | |
| bool | mEnhancementDirty |
| Flag indicating if the lookup table needs to be regenerated. | |
| int * | mLookupTable |
| Pointer to the lookup table. | |
| double | mLookupTableOffset |
| Scalar so that values can be used as array indicies. | |
| double | mMaximumValue |
| user defineable maximum value for the band, used for enhanceContrasting | |
| double | mMinimumValue |
| User defineable minimum value for the band, used for enhanceContrasting. | |
| QGis::DataType | mRasterDataType |
| Data type of the band. | |
| double | mRasterDataTypeRange |
| Maximum range of values for a given data type. | |
Manipulates raster pixel values so that they enhanceContrast or clip into a specified numerical range according to the specified ContrastEnhancementAlgorithm.
Definition at line 38 of file qgscontrastenhancement.h.
This enumerator describes the types of contrast enhancement algorithms that can be used.
| NoEnhancement | |
| StretchToMinimumMaximum | |
| StretchAndClipToMinimumMaximum | |
| ClipToMinimumMaximum | |
| UserDefinedEnhancement |
Definition at line 44 of file qgscontrastenhancement.h.
| QgsContrastEnhancement::QgsContrastEnhancement | ( | QGis::DataType | theDatatype = QGis::Byte | ) |
Definition at line 31 of file qgscontrastenhancement.cpp.
References maximumValuePossible(), mContrastEnhancementAlgorithm, mContrastEnhancementFunction, mEnhancementDirty, minimumValuePossible(), mLookupTable, mLookupTableOffset, mMaximumValue, mMinimumValue, mRasterDataType, mRasterDataTypeRange, and NoEnhancement.
Definition at line 55 of file qgscontrastenhancement.cpp.
References mContrastEnhancementAlgorithm, mContrastEnhancementFunction, mEnhancementDirty, mLookupTable, mLookupTableOffset, mMaximumValue, mMinimumValue, mRasterDataType, mRasterDataTypeRange, and setContrastEnhancementAlgorithm().
Definition at line 78 of file qgscontrastenhancement.cpp.
References mContrastEnhancementFunction, and mLookupTable.
| int QgsContrastEnhancement::calculateContrastEnhancementValue | ( | double | ) | [private] |
Method to calculate the actual enhanceContrasted value(s)
| ContrastEnhancementAlgorithm QgsContrastEnhancement::contrastEnhancementAlgorithm | ( | ) | const [inline] |
Definition at line 79 of file qgscontrastenhancement.h.
Referenced by QgsSingleBandGrayRenderer::legendSymbologyItems(), QgsSingleBandGrayRendererWidget::setFromRenderer(), and QgsMultiBandColorRendererWidget::setMinMaxValue().
| QgsContrastEnhancement::ContrastEnhancementAlgorithm QgsContrastEnhancement::contrastEnhancementAlgorithmFromString | ( | const QString & | contrastEnhancementString | ) | [static] |
Definition at line 472 of file qgscontrastenhancement.cpp.
References ClipToMinimumMaximum, NoEnhancement, StretchAndClipToMinimumMaximum, StretchToMinimumMaximum, and UserDefinedEnhancement.
Referenced by readXML(), and QgsRasterLayer::setDefaultContrastEnhancement().
| QString QgsContrastEnhancement::contrastEnhancementAlgorithmString | ( | ContrastEnhancementAlgorithm | algorithm | ) | [static] |
Definition at line 454 of file qgscontrastenhancement.cpp.
References ClipToMinimumMaximum, NoEnhancement, StretchAndClipToMinimumMaximum, StretchToMinimumMaximum, and UserDefinedEnhancement.
Referenced by writeXML().
| int QgsContrastEnhancement::enhanceContrast | ( | double | theValue | ) |
Apply the contrast enhancement to a value.
Public function to generate the enhanced for enhanceContrasted value for a given input.
Return values are 0 - 254, -1 means the pixel was clipped and should not be displayed
| theValue | The pixel value to enhance |
Definition at line 198 of file qgscontrastenhancement.cpp.
References QgsContrastEnhancementFunction::enhance(), generateLookupTable(), mContrastEnhancementAlgorithm, mContrastEnhancementFunction, mEnhancementDirty, mLookupTable, mLookupTableOffset, and NoEnhancement.
Referenced by QgsMultiBandColorRenderer::block(), and QgsSingleBandGrayRenderer::block().
| bool QgsContrastEnhancement::generateLookupTable | ( | ) | [private] |
Method to generate a new lookup table.
Generate a new lookup table.
Definition at line 221 of file qgscontrastenhancement.cpp.
References QGis::Byte, QgsContrastEnhancementFunction::enhance(), QGis::Int16, mContrastEnhancementAlgorithm, mContrastEnhancementFunction, mEnhancementDirty, mLookupTable, mLookupTableOffset, mMaximumValue, mMinimumValue, mRasterDataType, mRasterDataTypeRange, NoEnhancement, QgsDebugMsg, and QGis::UInt16.
Referenced by enhanceContrast(), setContrastEnhancementAlgorithm(), setContrastEnhancementFunction(), setMaximumValue(), and setMinimumValue().
| bool QgsContrastEnhancement::isValueInDisplayableRange | ( | double | theValue | ) |
Return true if pixel is in stretable range, false if pixel is outside of range (i.e., clipped)
Determine if a pixel is within in the displayable range.
| theValue | The pixel value to examine |
Definition at line 253 of file qgscontrastenhancement.cpp.
References QgsContrastEnhancementFunction::isValueInDisplayableRange(), and mContrastEnhancementFunction.
Referenced by QgsMultiBandColorRenderer::block(), and QgsSingleBandGrayRenderer::block().
| double QgsContrastEnhancement::maximumValue | ( | ) | const [inline] |
Return the maximum value for the contrast enhancement range.
Definition at line 74 of file qgscontrastenhancement.h.
Referenced by QgsSingleBandGrayRenderer::legendSymbologyItems(), QgsSingleBandGrayRendererWidget::setFromRenderer(), and QgsMultiBandColorRendererWidget::setMinMaxValue().
| double QgsContrastEnhancement::maximumValuePossible | ( | QGis::DataType | theDataType | ) | [static] |
Helper function that returns the maximum possible value for a GDAL data type.
Simple function to compute the maximum possible value for a data types.
Definition at line 92 of file qgscontrastenhancement.cpp.
References QGis::ARGB32, QGis::ARGB32_Premultiplied, QGis::Byte, QGis::CFloat32, QGis::CFloat64, QGis::CInt16, QGis::CInt32, QGis::Float32, QGis::Float64, QGis::Int16, QGis::Int32, MathUtils::max(), QGis::UInt16, QGis::UInt32, and QGis::UnknownDataType.
Referenced by QgsClipToMinMaxEnhancement::enhance(), QgsContrastEnhancementFunction::enhance(), QgsRasterHistogramWidget::histoAction(), QgsContrastEnhancementFunction::isValueInDisplayableRange(), QgsContrastEnhancement(), QgsContrastEnhancementFunction::setMaximumValue(), setMaximumValue(), and QgsRasterFileWriter::writeDataRaster().
| double QgsContrastEnhancement::minimumValue | ( | ) | const [inline] |
Return the minimum value for the contrast enhancement range.
Definition at line 77 of file qgscontrastenhancement.h.
Referenced by QgsSingleBandGrayRenderer::legendSymbologyItems(), QgsSingleBandGrayRendererWidget::setFromRenderer(), and QgsMultiBandColorRendererWidget::setMinMaxValue().
| double QgsContrastEnhancement::minimumValuePossible | ( | QGis::DataType | theDataType | ) | [static] |
Helper function that returns the minimum possible value for a GDAL data type.
Simple function to compute the minimum possible value for a data type.
Definition at line 141 of file qgscontrastenhancement.cpp.
References QGis::ARGB32, QGis::ARGB32_Premultiplied, QGis::Byte, QGis::CFloat32, QGis::CFloat64, QGis::CInt16, QGis::CInt32, QGis::Float32, QGis::Float64, QGis::Int16, QGis::Int32, MathUtils::max(), MathUtils::min(), QGis::UInt16, QGis::UInt32, and QGis::UnknownDataType.
Referenced by QgsClipToMinMaxEnhancement::enhance(), QgsContrastEnhancementFunction::enhance(), QgsRasterHistogramWidget::histoAction(), QgsContrastEnhancementFunction::isValueInDisplayableRange(), QgsContrastEnhancement(), QgsContrastEnhancementFunction::setMinimumValue(), and setMinimumValue().
| void QgsContrastEnhancement::readXML | ( | const QDomElement & | elem | ) |
Definition at line 407 of file qgscontrastenhancement.cpp.
References ClipToMinimumMaximum, contrastEnhancementAlgorithmFromString(), mMaximumValue, mMinimumValue, NoEnhancement, setContrastEnhancementAlgorithm(), StretchAndClipToMinimumMaximum, StretchToMinimumMaximum, and UserDefinedEnhancement.
Referenced by QgsMultiBandColorRenderer::create(), and QgsSingleBandGrayRenderer::create().
| void QgsContrastEnhancement::setContrastEnhancementAlgorithm | ( | ContrastEnhancementAlgorithm | theAlgorithm, |
| bool | generateTable = true |
||
| ) |
Set the contrast enhancement algorithm.
The second parameter is optional and is for performace 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.
| theAlgorithm | The new contrast enhancement algorithm |
| generateTable | Flag to overide automatic look up table generation |
Definition at line 270 of file qgscontrastenhancement.cpp.
References ClipToMinimumMaximum, generateLookupTable(), mContrastEnhancementAlgorithm, mContrastEnhancementFunction, mEnhancementDirty, mMaximumValue, mMinimumValue, mRasterDataType, QgsDebugMsg, StretchAndClipToMinimumMaximum, StretchToMinimumMaximum, and UserDefinedEnhancement.
Referenced by QgsContrastEnhancement(), readXML(), QgsSingleBandGrayRendererWidget::renderer(), QgsRasterLayer::setContrastEnhancement(), and QgsMultiBandColorRendererWidget::setCustomMinMaxValues().
| void QgsContrastEnhancement::setContrastEnhancementFunction | ( | QgsContrastEnhancementFunction * | theFunction | ) |
A public method that allows the user to set their own custom contrast enhancment function.
A public function that allows the user to set their own custom contrast enhancement function.
| theFunction | The new contrast enhancement function |
Definition at line 310 of file qgscontrastenhancement.cpp.
References generateLookupTable(), mContrastEnhancementAlgorithm, mContrastEnhancementFunction, QgsDebugMsg, and UserDefinedEnhancement.
| void QgsContrastEnhancement::setMaximumValue | ( | double | theValue, |
| bool | generateTable = true |
||
| ) |
Set the maximum value for the contrast enhancement range.
Set the maximum value for the contrast enhancement.
The second parameter is option an is for performace 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 tale. By default it will be generated.
| theValue | The new maximum value for the band |
| generateTable | Flag to overide automatic look up table generation |
Definition at line 328 of file qgscontrastenhancement.cpp.
References generateLookupTable(), maximumValuePossible(), mContrastEnhancementFunction, mEnhancementDirty, mMaximumValue, mRasterDataType, QgsDebugMsg, and QgsContrastEnhancementFunction::setMaximumValue().
Referenced by QgsSingleBandGrayRendererWidget::renderer(), QgsRasterLayer::setContrastEnhancement(), and QgsMultiBandColorRendererWidget::setCustomMinMaxValues().
| void QgsContrastEnhancement::setMinimumValue | ( | double | theValue, |
| bool | generateTable = true |
||
| ) |
Return the minimum value for the contrast enhancement range.
Set the maximum value for the contrast enhancement.
The second parameter is option an is for performace 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 tale. By default it will be generated.
| theValue | The new minimum value for the band |
| generateTable | Flag to overide automatic look up table generation |
Definition at line 360 of file qgscontrastenhancement.cpp.
References generateLookupTable(), mContrastEnhancementFunction, mEnhancementDirty, minimumValuePossible(), mMinimumValue, mRasterDataType, QgsDebugMsg, and QgsContrastEnhancementFunction::setMinimumValue().
Referenced by QgsSingleBandGrayRendererWidget::renderer(), QgsRasterLayer::setContrastEnhancement(), and QgsMultiBandColorRendererWidget::setCustomMinMaxValues().
| void QgsContrastEnhancement::writeXML | ( | QDomDocument & | doc, |
| QDomElement & | parentElem | ||
| ) | const |
Definition at line 386 of file qgscontrastenhancement.cpp.
References contrastEnhancementAlgorithmString(), mContrastEnhancementAlgorithm, mMaximumValue, and mMinimumValue.
Referenced by QgsSingleBandGrayRenderer::writeXML(), and QgsMultiBandColorRenderer::writeXML().
Current contrast enhancement algorithm.
Definition at line 114 of file qgscontrastenhancement.h.
Referenced by enhanceContrast(), generateLookupTable(), QgsContrastEnhancement(), setContrastEnhancementAlgorithm(), setContrastEnhancementFunction(), and writeXML().
Pointer to the contrast enhancement function.
Definition at line 117 of file qgscontrastenhancement.h.
Referenced by enhanceContrast(), generateLookupTable(), isValueInDisplayableRange(), QgsContrastEnhancement(), setContrastEnhancementAlgorithm(), setContrastEnhancementFunction(), setMaximumValue(), setMinimumValue(), and ~QgsContrastEnhancement().
bool QgsContrastEnhancement::mEnhancementDirty [private] |
Flag indicating if the lookup table needs to be regenerated.
Definition at line 120 of file qgscontrastenhancement.h.
Referenced by enhanceContrast(), generateLookupTable(), QgsContrastEnhancement(), setContrastEnhancementAlgorithm(), setMaximumValue(), and setMinimumValue().
int* QgsContrastEnhancement::mLookupTable [private] |
Pointer to the lookup table.
Definition at line 126 of file qgscontrastenhancement.h.
Referenced by enhanceContrast(), generateLookupTable(), QgsContrastEnhancement(), and ~QgsContrastEnhancement().
double QgsContrastEnhancement::mLookupTableOffset [private] |
Scalar so that values can be used as array indicies.
Definition at line 123 of file qgscontrastenhancement.h.
Referenced by enhanceContrast(), generateLookupTable(), and QgsContrastEnhancement().
double QgsContrastEnhancement::mMaximumValue [private] |
user defineable maximum value for the band, used for enhanceContrasting
Definition at line 132 of file qgscontrastenhancement.h.
Referenced by generateLookupTable(), QgsContrastEnhancement(), readXML(), setContrastEnhancementAlgorithm(), setMaximumValue(), and writeXML().
double QgsContrastEnhancement::mMinimumValue [private] |
User defineable minimum value for the band, used for enhanceContrasting.
Definition at line 129 of file qgscontrastenhancement.h.
Referenced by generateLookupTable(), QgsContrastEnhancement(), readXML(), setContrastEnhancementAlgorithm(), setMinimumValue(), and writeXML().
Data type of the band.
Definition at line 135 of file qgscontrastenhancement.h.
Referenced by generateLookupTable(), QgsContrastEnhancement(), setContrastEnhancementAlgorithm(), setMaximumValue(), and setMinimumValue().
double QgsContrastEnhancement::mRasterDataTypeRange [private] |
Maximum range of values for a given data type.
Definition at line 138 of file qgscontrastenhancement.h.
Referenced by generateLookupTable(), and QgsContrastEnhancement().