QGIS API Documentation  3.2.0-Bonn (bc43194)
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 : [email protected]
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 "qgis_core.h"
25 #include <limits>
26 
27 #include "qgis.h"
28 #include "qgsraster.h"
29 #include <memory>
30 
32 class QDomDocument;
33 class QDomElement;
34 class QString;
35 
42 class CORE_EXPORT QgsContrastEnhancement
43 {
44 
45  public:
46 
49  {
50  NoEnhancement, //this should be the default color scaling algorithm
51  StretchToMinimumMaximum, //linear histogram enhanceContrast
54  UserDefinedEnhancement
55  };
56 
60 
61  const QgsContrastEnhancement &operator=( const QgsContrastEnhancement & ) = delete;
62 
63  /*
64  *
65  * Static methods
66  *
67  */
68 
72  static double maximumValuePossible( Qgis::DataType );
73 
77  static double minimumValuePossible( Qgis::DataType );
78 
82  static QString contrastEnhancementAlgorithmString( ContrastEnhancementAlgorithm algorithm );
83 
87  static ContrastEnhancementAlgorithm contrastEnhancementAlgorithmFromString( const QString &contrastEnhancementString );
88 
89  /*
90  *
91  * Non-Static Inline methods
92  *
93  */
95  double maximumValue() const { return mMaximumValue; }
96 
98  double minimumValue() const { return mMinimumValue; }
99 
100  ContrastEnhancementAlgorithm contrastEnhancementAlgorithm() const { return mContrastEnhancementAlgorithm; }
101 
102  /*
103  *
104  * Non-Static methods
105  *
106  */
107 
111  int enhanceContrast( double value );
112 
117  bool isValueInDisplayableRange( double value );
118 
126  void setContrastEnhancementAlgorithm( ContrastEnhancementAlgorithm algorithm, bool generateTable = true );
127 
132  void setContrastEnhancementFunction( QgsContrastEnhancementFunction *function SIP_TRANSFER );
133 
144  void setMaximumValue( double value, bool generateTable = true );
145 
156  void setMinimumValue( double value, bool generateTable = true );
157 
158  void writeXml( QDomDocument &doc, QDomElement &parentElem ) const;
159 
160  void readXml( const QDomElement &elem );
161 
162  private:
163 #ifdef SIP_RUN
164  const QgsContrastEnhancement &operator=( const QgsContrastEnhancement & );
165 #endif
166 
168  ContrastEnhancementAlgorithm mContrastEnhancementAlgorithm = NoEnhancement;
169 
171  std::unique_ptr< QgsContrastEnhancementFunction > mContrastEnhancementFunction;
172 
174  bool mEnhancementDirty = false;
175 
177  double mLookupTableOffset;
178 
180  int *mLookupTable = nullptr;
181 
183  double mMinimumValue;
184 
186  double mMaximumValue;
187 
189  Qgis::DataType mRasterDataType;
190 
192  double mRasterDataTypeRange;
193 
195  bool generateLookupTable();
196 
198  int calculateContrastEnhancementValue( double );
199 
200 };
201 
202 #endif
double maximumValue() const
Returns the maximum value for the contrast enhancement range.
DataType
Raster data types.
Definition: qgis.h:91
double minimumValue() const
Returns the minimum value for the contrast enhancement range.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
A contrast enhancement function is the base class for all raster contrast enhancements.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call
ContrastEnhancementAlgorithm
This enumerator describes the types of contrast enhancement algorithms that can be used...
ContrastEnhancementAlgorithm contrastEnhancementAlgorithm() const
Manipulates raster pixel values so that they enhanceContrast or clip into a specified numerical range...
Eight bit unsigned integer (quint8)
Definition: qgis.h:94