cmtkColormap.h

Go to the documentation of this file.
00001 /*
00002 //
00003 //  Copyright 1997-2009 Torsten Rohlfing
00004 //
00005 //  Copyright 2004-2011 SRI International
00006 //
00007 //  This file is part of the Computational Morphometry Toolkit.
00008 //
00009 //  http://www.nitrc.org/projects/cmtk/
00010 //
00011 //  The Computational Morphometry Toolkit is free software: you can
00012 //  redistribute it and/or modify it under the terms of the GNU General Public
00013 //  License as published by the Free Software Foundation, either version 3 of
00014 //  the License, or (at your option) any later version.
00015 //
00016 //  The Computational Morphometry Toolkit is distributed in the hope that it
00017 //  will be useful, but WITHOUT ANY WARRANTY; without even the implied
00018 //  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 //  GNU General Public License for more details.
00020 //
00021 //  You should have received a copy of the GNU General Public License along
00022 //  with the Computational Morphometry Toolkit.  If not, see
00023 //  <http://www.gnu.org/licenses/>.
00024 //
00025 //  $Revision: 2752 $
00026 //
00027 //  $LastChangedDate: 2011-01-17 11:33:31 -0800 (Mon, 17 Jan 2011) $
00028 //
00029 //  $LastChangedBy: torstenrohlfing $
00030 //
00031 */
00032 
00033 #ifndef __cmtkColormap_h_included_
00034 #define __cmtkColormap_h_included_
00035 
00036 #include <cmtkconfig.h>
00037 
00038 #include <Pipeline/cmtkPipelineObject.h>
00039 #include <Pipeline/cmtkRGB.h>
00040 
00041 #include <Base/cmtkTypedArray.h>
00042 
00043 #include <IO/cmtkStudy.h>
00044 
00045 #include <vector>
00046 
00047 namespace
00048 cmtk
00049 {
00050 
00053 
00061 class Colormap : 
00063   public PipelineObject 
00064 {
00065 public:
00067   static Colormap* New() { return new Colormap(); }
00068 
00070   igsClassParameter(bool,HaveUserMap);
00071 
00073   igsClassParameter2Array(Types::DataItem,HueRange);
00074 
00076   igsClassParameter2Array(cmtk::Types::DataItem,SaturationRange);
00077 
00079   igsClassParameter2Array(cmtk::Types::DataItem,ValueRange);
00080 
00081   // Gamma correction coefficient.
00082   igsClassParameter(cmtk::Types::DataItem,Gamma);
00083 
00085   igsClassParameter(int,TableEntries);
00086 
00092   igsClassParameter2Array(cmtk::Types::DataItem,DataRange);
00093 
00096   igsClassParameter(bool,Reverse);
00097 
00103   void SetStandardColormap( const int index );
00104 
00106   static const char *StandardColormaps[];
00107 
00120   void Apply( void *const outPtr, const TypedArray* inPtr, const bool generateAlpha = false );
00121 
00123   void SetFromStudy( const Study* study );
00124 
00126   static void HSV2RGB( RGB& rgb, Types::DataItem H, Types::DataItem S, Types::DataItem V );
00127 
00128 protected:
00130   Colormap();
00131 
00134   virtual ~Colormap() {}
00135   
00140   virtual void Execute();
00141 
00142 private:
00148   std::vector<RGB> LookupTable;
00149 
00151   Types::DataItem InvDataRangeWidth;
00152 
00165   template<class T>
00166   void ApplyPrimitive( RGB *const outPtr, const T* inPtr, const unsigned int count, const bool paddingFlag, const T paddingData ) const;
00167 
00180   template<class T>
00181   void ApplyPrimitive( RGBA *const outPtr, const T* inPtr, const unsigned int count, const bool paddingFlag, const T paddingData ) const;
00182 
00184   SegmentationLabelMap LabelColorMap;
00185 };
00186 
00188 
00189 } // namespace cmtk
00190 
00191 #endif // #ifndef __cmtkColormap_h_included_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines