QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
qgscontrastenhancement.h
Go to the documentation of this file.
1 /* **************************************************************************
2  qgscontrastenhancement.h - description
3  -------------------
4 begin : Mon Oct 22 2007
5 copyright : (C) 2007 by Peter J. Ersts
6 email : ersts@amnh.org
7 
8 This class contains code that was originally part of the larger QgsRasterLayer
9 class originally created circa 2004 by T.Sutton, Gary E.Sherman, Steve Halasz
10 ****************************************************************************/
11 
12 /* **************************************************************************
13  * *
14  * This program is free software; you can redistribute it and/or modify *
15  * it under the terms of the GNU General Public License as published by *
16  * the Free Software Foundation; either version 2 of the License, or *
17  * (at your option) any later version. *
18  * *
19  ***************************************************************************/
20 
21 #ifndef QGSCONTRASTENHANCEMENT_H
22 #define QGSCONTRASTENHANCEMENT_H
23 
24 #include <limits>
25 
26 #include "qgis.h"
27 
29 class QDomDocument;
30 class QDomElement;
31 class QString;
32 
38 class CORE_EXPORT QgsContrastEnhancement
39 {
40 
41  public:
42 
45  {
46  NoEnhancement, //this should be the default color scaling algorithm
47  StretchToMinimumMaximum, //linear histogram enhanceContrast
50  UserDefinedEnhancement
51  };
52 
56 
57  /*
58  *
59  * Static methods
60  *
61  */
63  static double maximumValuePossible( QGis::DataType );
64 
66  static double minimumValuePossible( QGis::DataType );
67 
68  /*
69  *
70  * Non-Static Inline methods
71  *
72  */
74  double maximumValue() const { return mMaximumValue; }
75 
77  double minimumValue() const { return mMinimumValue; }
78 
79  ContrastEnhancementAlgorithm contrastEnhancementAlgorithm() const { return mContrastEnhancementAlgorithm; }
80 
81  static QString contrastEnhancementAlgorithmString( ContrastEnhancementAlgorithm algorithm );
82 
83  static ContrastEnhancementAlgorithm contrastEnhancementAlgorithmFromString( const QString& contrastEnhancementString );
84 
85  /*
86  *
87  * Non-Static methods
88  *
89  */
91  int enhanceContrast( double );
92 
94  bool isValueInDisplayableRange( double );
95 
97  void setContrastEnhancementAlgorithm( ContrastEnhancementAlgorithm, bool generateTable = true );
98 
100  void setContrastEnhancementFunction( QgsContrastEnhancementFunction* );
101 
103  void setMaximumValue( double, bool generateTable = true );
104 
106  void setMinimumValue( double, bool generateTable = true );
107 
108  void writeXML( QDomDocument& doc, QDomElement& parentElem ) const;
109 
110  void readXML( const QDomElement& elem );
111 
112  private:
115 
118 
121 
124 
127 
130 
133 
136 
139 
140 
141 
143  bool generateLookupTable();
144 
146  int calculateContrastEnhancementValue( double );
147 };
148 
149 #endif
ContrastEnhancementAlgorithm contrastEnhancementAlgorithm() const
double mLookupTableOffset
Scalar so that values can be used as array indicies.
ContrastEnhancementAlgorithm mContrastEnhancementAlgorithm
Current contrast enhancement algorithm.
bool mEnhancementDirty
Flag indicating if the lookup table needs to be regenerated.
int * mLookupTable
Pointer to the lookup table.
ContrastEnhancementAlgorithm
This enumerator describes the types of contrast enhancement algorithms that can be used...
double mMaximumValue
user defineable maximum value for the band, used for enhanceContrasting
QGis::DataType mRasterDataType
Data type of the band.
A contrast enhancement funcion is the base class for all raster contrast enhancements.
double minimumValue() const
Return the minimum value for the contrast enhancement range.
DataType
Raster data types.
Definition: qgis.h:204
double mRasterDataTypeRange
Maximum range of values for a given data type.
QgsContrastEnhancementFunction * mContrastEnhancementFunction
Pointer to the contrast enhancement function.
double maximumValue() const
Return the maximum value for the contrast enhancement range.
Manipulates raster pixel values so that they enhanceContrast or clip into a specified numerical range...
double mMinimumValue
User defineable minimum value for the band, used for enhanceContrasting.