OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimNormalizedU16RemapTable.h
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: MIT
4 //
5 // See LICENSE.txt file in the top level directory for more details.
6 //
7 // Description:
8 //
9 // Contains class declaration for ossimNormalizedU16RemapTable. Table for
10 // normalizing unsigned 16 bit data.
11 //
12 //*******************************************************************
13 // $Id: ossimNormalizedU16RemapTable.h 16034 2009-12-03 14:49:25Z dburken $
14 
15 #ifndef ossimNormalizedU16RemapTable_HEADER
16 #define ossimNormalizedU16RemapTable_HEADER
17 
19 #include <ossim/base/ossimCommon.h> /* for round */
20 
28 {
29 public:
30 
35 
36  enum
37  {
38  TABLE_ENTRIES = 65536 // 2^16
39  };
40 
45  virtual ossim_int32 getEntries() const;
46 
53  virtual ossim_float64 operator[](ossim_int32 pix) const;
54 
61  virtual ossim_float64 normFromPix(ossim_int32 pix) const;
62 
68  virtual ossim_int32 pixFromNorm(ossim_float64 normPix) const;
69 
70 protected:
71 
72  static ossim_float64 theTable[TABLE_ENTRIES];
73  static bool theTableIsInitialized;
74 
75 };
76 
78 {
79  return TABLE_ENTRIES;
80 }
81 
83  ossim_int32 pix) const
84 {
85  return ( (pix < TABLE_ENTRIES) ? (pix >= 0 ? theTable[pix] : 0.0) : 1.0);
86 }
87 
89  ossim_int32 pix) const
90 {
91  return ( (pix < TABLE_ENTRIES) ? (pix >= 0 ? theTable[pix] : 0.0) : 1.0);
92 }
93 
95  ossim_float64 normPix) const
96 {
97  if(normPix <= 0.0) return 0;
98 
99  // un-normalize...
100  ossim_float64 p = normPix * getNormalizer();
101 
102  // Ensure pixel is in range.
103  p = ( (p < TABLE_ENTRIES) ? (p >= 0.0 ? p : 0.0) : getNormalizer());
104 
105  // Since going from double to int round...
106  p = ossim::round<ossim_int32>(p);
107 
108  if(p == 0.0)
109  {
110  p = 1.0;
111  }
112 
113  return static_cast<ossim_int32>(p);
114 }
115 
116 #endif
static ossim_float64 theTable[TABLE_ENTRIES]
virtual ossim_float64 normFromPix(ossim_int32 pix) const =0
Gets a normalized value (between &#39;0.0&#39; and &#39;1.0&#39;) from a pixel value.
virtual ossim_int32 getEntries() const
Gets the number of table entries.
double ossim_float64
virtual ossim_int32 getEntries() const =0
Pure virtual method to get the number of table entries.
virtual ossim_int32 pixFromNorm(ossim_float64 normPix) const =0
Returns an pixel value as an int from a normalized value.
Base class implemetation of normalized remap tables to go to/from normalized value to pixel value...
#define OSSIM_DLL
virtual ossim_float64 getNormalizer() const
Get the value used to normalize and un-normalize table entries.
virtual ossim_float64 normFromPix(ossim_int32 pix) const
Gets a normalized value (between &#39;0.0&#39; and &#39;1.0&#39;) from a pixel value.
virtual ossim_float64 operator[](ossim_int32 pix) const =0
Gets a normalized value (between &#39;0.0&#39; and &#39;1.0&#39;) from a pixel value.
virtual ossim_float64 operator[](ossim_int32 pix) const
Gets a normalized value (between &#39;0.0&#39; and &#39;1.0&#39;) from a pixel value.
virtual ossim_int32 pixFromNorm(ossim_float64 normPix) const
Returns an pixel value as an int from a normalized value.
int ossim_int32
Unsigned 16 bit normalized remap table to go to/from normalized value to pixel value.