28 #include <QDomDocument>
29 #include <QDomElement>
94 switch ( theDataType )
143 switch ( theDataType )
272 QgsDebugMsg(
"called algorithm: " + QString::number((
int )theAlgorithm ) +
" generate lookup table: " + QString::number((
int )generateTable ) );
276 switch ( theAlgorithm )
314 if ( 0 != theFunction )
330 QgsDebugMsg(
"called value: " + QString::number( theValue ) +
" generate lookup table: " + QString::number((
int )generateTable ) );
362 QgsDebugMsg(
"called value: " + QString::number( theValue ) +
" generate lookup table: " + QString::number((
int )generateTable ) );
389 QDomElement minElem = doc.createElement(
"minValue" );
390 QDomText minText = doc.createTextNode( QString::number(
mMinimumValue ) );
391 minElem.appendChild( minText );
392 parentElem.appendChild( minElem );
395 QDomElement maxElem = doc.createElement(
"maxValue" );
396 QDomText maxText = doc.createTextNode( QString::number(
mMaximumValue ) );
397 maxElem.appendChild( maxText );
398 parentElem.appendChild( maxElem );
401 QDomElement algorithmElem = doc.createElement(
"algorithm" );
403 algorithmElem.appendChild( algorithmText );
404 parentElem.appendChild( algorithmElem );
409 QDomElement minValueElem = elem.firstChildElement(
"minValue" );
410 if ( !minValueElem.isNull() )
414 QDomElement maxValueElem = elem.firstChildElement(
"maxValue" );
415 if ( !maxValueElem.isNull() )
419 QDomElement algorithmElem = elem.firstChildElement(
"algorithm" );
420 if ( !algorithmElem.isNull() )
422 QString algorithmString = algorithmElem.text();
425 if ( algorithmString ==
"0" )
429 else if ( algorithmString ==
"1" )
433 else if ( algorithmString ==
"2" )
437 else if ( algorithmString ==
"3" )
441 else if ( algorithmString ==
"4" )
459 return "NoEnhancement";
461 return "StretchToMinimumMaximum";
463 return "StretchAndClipToMinimumMaximum";
465 return "ClipToMinimumMaximum";
467 return "UserDefinedEnhancement";
469 return "NoEnhancement";
474 if ( contrastEnhancementString ==
"StretchToMinimumMaximum" )
478 else if ( contrastEnhancementString ==
"StretchAndClipToMinimumMaximum" )
482 else if ( contrastEnhancementString ==
"ClipToMinimumMaximum" )
486 else if ( contrastEnhancementString ==
"UserDefinedEnhancement" )
~QgsContrastEnhancement()
void setContrastEnhancementAlgorithm(ContrastEnhancementAlgorithm, bool generateTable=true)
Set the contrast enhancement algorithm.
void writeXML(QDomDocument &doc, QDomElement &parentElem) const
void readXML(const QDomElement &elem)
bool isValueInDisplayableRange(double)
Return true if pixel is in stretable range, false if pixel is outside of range (i.e., clipped)
double mLookupTableOffset
Scalar so that values can be used as array indicies.
ContrastEnhancementAlgorithm mContrastEnhancementAlgorithm
Current contrast enhancement algorithm.
static double maximumValuePossible(QGis::DataType)
Helper function that returns the maximum possible value for a GDAL data type.
bool mEnhancementDirty
Flag indicating if the lookup table needs to be regenerated.
bool generateLookupTable()
Method to generate a new lookup table.
int * mLookupTable
Pointer to the lookup table.
double ANALYSIS_EXPORT max(double x, double y)
returns the maximum of two doubles or the first argument if both are equal
void setContrastEnhancementFunction(QgsContrastEnhancementFunction *)
A public method that allows the user to set their own custom contrast enhancment function.
void setMinimumValue(double)
Mutator for the minimum value.
static double minimumValuePossible(QGis::DataType)
Helper function that returns the minimum possible value for a GDAL data type.
double mMaximumValue
user defineable maximum value for the band, used for enhanceContrasting
A linear enhanceContrast enhancement that first clips to min max and then enhanceContrastes linearly ...
void setMinimumValue(double, bool generateTable=true)
Return the minimum value for the contrast enhancement range.
QGis::DataType mRasterDataType
Data type of the band.
static QString contrastEnhancementAlgorithmString(ContrastEnhancementAlgorithm algorithm)
A contrast enhancement funcion is the base class for all raster contrast enhancements.
A color enhancement function that performs a linear enhanceContrast between min and max...
double mRasterDataTypeRange
Maximum range of values for a given data type.
QgsContrastEnhancement(QGis::DataType theDatatype=QGis::Byte)
static ContrastEnhancementAlgorithm contrastEnhancementAlgorithmFromString(const QString &contrastEnhancementString)
ContrastEnhancementAlgorithm
This enumerator describes the types of contrast enhancement algorithms that can be used...
A raster contrast enhancement that will clip a value to the specified min/max range.
int enhanceContrast(double)
Apply the contrast enhancement to a value.
QgsContrastEnhancementFunction * mContrastEnhancementFunction
Pointer to the contrast enhancement function.
DataType
Raster data types.
virtual int enhance(double)
A customizable method that takes in a double and returns a int between 0 and 255. ...
virtual bool isValueInDisplayableRange(double)
A customicable method to indicate if the pixels is displayable.
Manipulates raster pixel values so that they enhanceContrast or clip into a specified numerical range...
double ANALYSIS_EXPORT min(double x, double y)
returns the minimum of two doubles or the first argument if both are equal
double mMinimumValue
User defineable minimum value for the band, used for enhanceContrasting.
void setMaximumValue(double, bool generateTable=true)
Set the maximum value for the contrast enhancement range.
void setMaximumValue(double)
Mustator for the maximum value.