QgsContrastEnhancement Class Reference
[Core]

#include <qgscontrastenhancement.h>

Collaboration diagram for QgsContrastEnhancement:

Collaboration graph
[legend]
List of all members.

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 33 of file 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...
enum  QgsRasterDataType {
  QGS_Unknown = 0, QGS_Byte = 1, QGS_UInt16 = 2, QGS_Int16 = 3,
  QGS_UInt32 = 4, QGS_Int32 = 5, QGS_Float32 = 6, QGS_Float64 = 7,
  QGS_CInt16 = 8, QGS_CInt32 = 9, QGS_CFloat32 = 10, QGS_CFloat64 = 11,
  QGS_TypeCount = 12
}
 These are exactly the same as GDAL pixel data types This was added so that the python bindings could be built, which initially was a problem because GDALDataType was passed around as an argument to numerous method, including the constructor. More...

Public Member Functions

 QgsContrastEnhancement (QgsContrastEnhancement::QgsRasterDataType theDatatype=QGS_Byte)
 ~QgsContrastEnhancement ()
double maximumValue () const
 Return the maximum value for the contrast enhancement range.
double minimumValue () const
 Return the minimum value for the contrast enhancement range.
ContrastEnhancementAlgorithm contrastEnhancementAlgorithm ()
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).
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.

Static Public Member Functions

static double maximumValuePossible (QgsRasterDataType)
 Helper function that returns the maximum possible value for a GDAL data type.
static double minimumValuePossible (QgsRasterDataType)
 Helper function that returns the minimum possible value for a GDAL data type.

Private Member Functions

bool generateLookupTable ()
 Method to generate a new lookup table.
int calculateContrastEnhancementValue (double)
 Method to calculate the actual enhanceContrasted value(s).

Private Attributes

ContrastEnhancementAlgorithm mContrastEnhancementAlgorithm
 Current contrast enhancement algorithm.
QgsContrastEnhancementFunctionmContrastEnhancementFunction
 Pointer to the contrast enhancement function.
bool mEnhancementDirty
 Flag indicating if the lookup table needs to be regenerated.
double mLookupTableOffset
 Scalar so that values can be used as array indicies.
int * mLookupTable
 Pointer to the lookup table.
double mMinimumValue
 User defineable minimum value for the band, used for enhanceContrasting.
double mMaximumValue
 user defineable maximum value for the band, used for enhanceContrasting
QgsRasterDataType mRasterDataType
 Data type of the band.
double mRasterDataTypeRange
 Maximum range of values for a given data type.


Member Enumeration Documentation

enum QgsContrastEnhancement::ContrastEnhancementAlgorithm

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

Enumerator:
NoEnhancement 
StretchToMinimumMaximum 
StretchAndClipToMinimumMaximum 
ClipToMinimumMaximum 
UserDefinedEnhancement 

Definition at line 39 of file qgscontrastenhancement.h.

enum QgsContrastEnhancement::QgsRasterDataType

These are exactly the same as GDAL pixel data types This was added so that the python bindings could be built, which initially was a problem because GDALDataType was passed around as an argument to numerous method, including the constructor.

It seems like there should be a better way to do this...

Enumerator:
QGS_Unknown 
QGS_Byte  Eight bit unsigned integer
QGS_UInt16  Sixteen bit unsigned integer
QGS_Int16  Sixteen bit signed integer
QGS_UInt32  Thirty two bit unsigned integer
QGS_Int32  Thirty two bit signed integer
QGS_Float32  Thirty two bit floating point
QGS_Float64  Sixty four bit floating point
QGS_CInt16  Complex Int16
QGS_CInt32  Complex Int32
QGS_CFloat32  Complex Float32
QGS_CFloat64  Complex Float64
QGS_TypeCount 

Definition at line 55 of file qgscontrastenhancement.h.


Constructor & Destructor Documentation

QgsContrastEnhancement::QgsContrastEnhancement ( QgsContrastEnhancement::QgsRasterDataType  theDatatype = QGS_Byte  ) 

Definition at line 29 of file qgscontrastenhancement.cpp.

References maximumValuePossible(), mContrastEnhancementAlgorithm, mContrastEnhancementFunction, mEnhancementDirty, minimumValuePossible(), mLookupTable, mLookupTableOffset, mMaximumValue, mMinimumValue, mRasterDataType, mRasterDataTypeRange, and NoEnhancement.

QgsContrastEnhancement::~QgsContrastEnhancement (  ) 

Definition at line 53 of file qgscontrastenhancement.cpp.


Member Function Documentation

double QgsContrastEnhancement::maximumValuePossible ( QgsRasterDataType   )  [static]

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

Definition at line 65 of file qgscontrastenhancement.cpp.

References QGS_Byte, QGS_CFloat32, QGS_CFloat64, QGS_CInt16, QGS_CInt32, QGS_Float32, QGS_Float64, QGS_Int16, QGS_Int32, QGS_TypeCount, QGS_UInt16, QGS_UInt32, and QGS_Unknown.

Referenced by QgsContrastEnhancementFunction::enhance(), QgsClipToMinMaxEnhancement::enhance(), QgsContrastEnhancementFunction::isValueInDisplayableRange(), QgsContrastEnhancement(), QgsContrastEnhancementFunction::setMaximumValue(), and setMaximumValue().

double QgsContrastEnhancement::minimumValuePossible ( QgsRasterDataType   )  [static]

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

Definition at line 113 of file qgscontrastenhancement.cpp.

References QGS_Byte, QGS_CFloat32, QGS_CFloat64, QGS_CInt16, QGS_CInt32, QGS_Float32, QGS_Float64, QGS_Int16, QGS_Int32, QGS_TypeCount, QGS_UInt16, QGS_UInt32, and QGS_Unknown.

Referenced by QgsContrastEnhancementFunction::enhance(), QgsClipToMinMaxEnhancement::enhance(), QgsContrastEnhancementFunction::isValueInDisplayableRange(), QgsContrastEnhancement(), QgsContrastEnhancementFunction::setMinimumValue(), and setMinimumValue().

double QgsContrastEnhancement::maximumValue (  )  const [inline]

Return the maximum value for the contrast enhancement range.

Definition at line 92 of file qgscontrastenhancement.h.

double QgsContrastEnhancement::minimumValue (  )  const [inline]

Return the minimum value for the contrast enhancement range.

Definition at line 95 of file qgscontrastenhancement.h.

ContrastEnhancementAlgorithm QgsContrastEnhancement::contrastEnhancementAlgorithm (  )  [inline]

Definition at line 97 of file qgscontrastenhancement.h.

int QgsContrastEnhancement::enhanceContrast ( double   ) 

Apply 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 169 of file qgscontrastenhancement.cpp.

References QgsContrastEnhancementFunction::enhance(), generateLookupTable(), mContrastEnhancementAlgorithm, mContrastEnhancementFunction, mEnhancementDirty, mLookupTable, mLookupTableOffset, and NoEnhancement.

Referenced by QgsRasterLayer::drawMultiBandColor(), and QgsRasterLayer::drawSingleBandGray().

bool QgsContrastEnhancement::isValueInDisplayableRange ( double  theValue  ) 

Return true if pixel is in stretable range, false if pixel is outside of range (i.e., clipped).

Parameters:
theValue The pixel value to examine

Definition at line 220 of file qgscontrastenhancement.cpp.

References QgsContrastEnhancementFunction::isValueInDisplayableRange(), and mContrastEnhancementFunction.

Referenced by QgsRasterLayer::drawMultiBandColor(), and QgsRasterLayer::drawSingleBandGray().

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.

Parameters:
theAlgorithm The new contrast enhancement algorithm
generateTable Flag to overide automatic look up table generation

Definition at line 237 of file qgscontrastenhancement.cpp.

References ClipToMinimumMaximum, generateLookupTable(), mContrastEnhancementAlgorithm, mContrastEnhancementFunction, mEnhancementDirty, mMaximumValue, mMinimumValue, mRasterDataType, QgsDebugMsg, StretchAndClipToMinimumMaximum, StretchToMinimumMaximum, and UserDefinedEnhancement.

void QgsContrastEnhancement::setContrastEnhancementFunction ( QgsContrastEnhancementFunction theFunction  ) 

A public method that allows the user to set their own custom contrast enhancment function.

Parameters:
theFunction The new contrast enhancement function

Definition at line 277 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.

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.

Parameters:
theValue The new maximum value for the band
generateTable Flag to overide automatic look up table generation

Definition at line 295 of file qgscontrastenhancement.cpp.

References generateLookupTable(), maximumValuePossible(), mContrastEnhancementFunction, mEnhancementDirty, mMaximumValue, mRasterDataType, QgsDebugMsg, and QgsContrastEnhancementFunction::setMaximumValue().

void QgsContrastEnhancement::setMinimumValue ( double  theValue,
bool  generateTable = true 
)

Return the minimum value for the contrast enhancement range.

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.

Parameters:
theValue The new minimum value for the band
generateTable Flag to overide automatic look up table generation

Definition at line 327 of file qgscontrastenhancement.cpp.

References generateLookupTable(), mContrastEnhancementFunction, mEnhancementDirty, minimumValuePossible(), mMinimumValue, mRasterDataType, QgsDebugMsg, and QgsContrastEnhancementFunction::setMinimumValue().

bool QgsContrastEnhancement::generateLookupTable (  )  [private]

Method to generate a new lookup table.

Definition at line 192 of file qgscontrastenhancement.cpp.

References QgsContrastEnhancementFunction::enhance(), mContrastEnhancementAlgorithm, mContrastEnhancementFunction, mEnhancementDirty, mLookupTable, mLookupTableOffset, mMaximumValue, mMinimumValue, mRasterDataType, mRasterDataTypeRange, NoEnhancement, QGS_Byte, QGS_Int16, QGS_UInt16, and QgsDebugMsg.

Referenced by enhanceContrast(), setContrastEnhancementAlgorithm(), setContrastEnhancementFunction(), setMaximumValue(), and setMinimumValue().

int QgsContrastEnhancement::calculateContrastEnhancementValue ( double   )  [private]

Method to calculate the actual enhanceContrasted value(s).


Member Data Documentation

ContrastEnhancementAlgorithm QgsContrastEnhancement::mContrastEnhancementAlgorithm [private]

Current contrast enhancement algorithm.

Definition at line 124 of file qgscontrastenhancement.h.

Referenced by enhanceContrast(), generateLookupTable(), QgsContrastEnhancement(), setContrastEnhancementAlgorithm(), and setContrastEnhancementFunction().

QgsContrastEnhancementFunction* QgsContrastEnhancement::mContrastEnhancementFunction [private]

Pointer to the contrast enhancement function.

Definition at line 127 of file qgscontrastenhancement.h.

Referenced by enhanceContrast(), generateLookupTable(), isValueInDisplayableRange(), QgsContrastEnhancement(), setContrastEnhancementAlgorithm(), setContrastEnhancementFunction(), setMaximumValue(), and setMinimumValue().

bool QgsContrastEnhancement::mEnhancementDirty [private]

Flag indicating if the lookup table needs to be regenerated.

Definition at line 130 of file qgscontrastenhancement.h.

Referenced by enhanceContrast(), generateLookupTable(), QgsContrastEnhancement(), setContrastEnhancementAlgorithm(), setMaximumValue(), and setMinimumValue().

double QgsContrastEnhancement::mLookupTableOffset [private]

Scalar so that values can be used as array indicies.

Definition at line 133 of file qgscontrastenhancement.h.

Referenced by enhanceContrast(), generateLookupTable(), and QgsContrastEnhancement().

int* QgsContrastEnhancement::mLookupTable [private]

Pointer to the lookup table.

Definition at line 136 of file qgscontrastenhancement.h.

Referenced by enhanceContrast(), generateLookupTable(), and QgsContrastEnhancement().

double QgsContrastEnhancement::mMinimumValue [private]

User defineable minimum value for the band, used for enhanceContrasting.

Definition at line 139 of file qgscontrastenhancement.h.

Referenced by generateLookupTable(), QgsContrastEnhancement(), setContrastEnhancementAlgorithm(), and setMinimumValue().

double QgsContrastEnhancement::mMaximumValue [private]

user defineable maximum value for the band, used for enhanceContrasting

Definition at line 142 of file qgscontrastenhancement.h.

Referenced by generateLookupTable(), QgsContrastEnhancement(), setContrastEnhancementAlgorithm(), and setMaximumValue().

QgsRasterDataType QgsContrastEnhancement::mRasterDataType [private]

Data type of the band.

Definition at line 145 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 148 of file qgscontrastenhancement.h.

Referenced by generateLookupTable(), and QgsContrastEnhancement().


The documentation for this class was generated from the following files:
Generated on Tue Jan 6 16:51:20 2009 for Quantum GIS API Documentation by  doxygen 1.5.1