Quantum GIS API Documentation  1.8
src/core/raster/qgscontrastenhancement.h
Go to the documentation of this file.
00001 /* **************************************************************************
00002                 qgscontrastenhancement.h -  description
00003                        -------------------
00004 begin                : Mon Oct 22 2007
00005 copyright            : (C) 2007 by Peter J. Ersts
00006 email                : ersts@amnh.org
00007 
00008 This class contains code that was originally part of the larger QgsRasterLayer
00009 class originally created circa 2004 by T.Sutton, Gary E.Sherman, Steve Halasz
00010 ****************************************************************************/
00011 
00012 /* **************************************************************************
00013  *                                                                         *
00014  *   This program is free software; you can redistribute it and/or modify  *
00015  *   it under the terms of the GNU General Public License as published by  *
00016  *   the Free Software Foundation; either version 2 of the License, or     *
00017  *   (at your option) any later version.                                   *
00018  *                                                                         *
00019  ***************************************************************************/
00020 
00021 #ifndef QGSCONTRASTENHANCEMENT_H
00022 #define QGSCONTRASTENHANCEMENT_H
00023 
00024 #include <limits>
00025 
00026 class QgsContrastEnhancementFunction;
00027 
00033 class CORE_EXPORT QgsContrastEnhancement
00034 {
00035 
00036   public:
00037 
00039     enum ContrastEnhancementAlgorithm
00040     {
00041       NoEnhancement,                  //this should be the default color scaling algorithm
00042       StretchToMinimumMaximum,        //linear histogram enhanceContrast
00043       StretchAndClipToMinimumMaximum,
00044       ClipToMinimumMaximum,
00045       UserDefinedEnhancement
00046     };
00047 
00055     enum QgsRasterDataType
00056     {
00057       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,
00069       QGS_TypeCount = 12          /* maximum type # + 1 */
00070     };
00071 
00072     QgsContrastEnhancement( QgsContrastEnhancement::QgsRasterDataType theDatatype = QGS_Byte );
00073     ~QgsContrastEnhancement();
00074 
00075     /*
00076      *
00077      * Static methods
00078      *
00079      */
00081     static double maximumValuePossible( QgsRasterDataType );
00082 
00084     static double minimumValuePossible( QgsRasterDataType );
00085 
00086     /*
00087      *
00088      * Non-Static Inline methods
00089      *
00090      */
00092     double maximumValue() const { return mMaximumValue; }
00093 
00095     double minimumValue() const { return mMinimumValue; }
00096 
00097     ContrastEnhancementAlgorithm contrastEnhancementAlgorithm() const { return mContrastEnhancementAlgorithm; }
00098 
00099     /*
00100      *
00101      * Non-Static methods
00102      *
00103      */
00105     int enhanceContrast( double );
00106 
00108     bool isValueInDisplayableRange( double );
00109 
00111     void setContrastEnhancementAlgorithm( ContrastEnhancementAlgorithm, bool generateTable = true );
00112 
00114     void setContrastEnhancementFunction( QgsContrastEnhancementFunction* );
00115 
00117     void setMaximumValue( double, bool generateTable = true );
00118 
00120     void setMinimumValue( double, bool generateTable = true );
00121 
00122   private:
00124     ContrastEnhancementAlgorithm mContrastEnhancementAlgorithm;
00125 
00127     QgsContrastEnhancementFunction* mContrastEnhancementFunction;
00128 
00130     bool mEnhancementDirty;
00131 
00133     double mLookupTableOffset;
00134 
00136     int *mLookupTable;
00137 
00139     double mMinimumValue;
00140 
00142     double mMaximumValue;
00143 
00145     QgsRasterDataType mRasterDataType;
00146 
00148     double mRasterDataTypeRange;
00149 
00150 
00151 
00153     bool generateLookupTable();
00154 
00156     int calculateContrastEnhancementValue( double );
00157 };
00158 
00159 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines