OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimNormalizedS16RemapTable.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 ossimNormalizedS16RemapTable. Table for
10 // normalizing signed 16 bit data.
11 //
12 //*******************************************************************
13 // $Id: ossimNormalizedS16RemapTable.h 10456 2007-02-08 14:17:50Z gpotts $
14 
15 #ifndef ossimNormalizedS16RemapTable_HEADER
16 #define ossimNormalizedS16RemapTable_HEADER
17 
19 #include <ossim/base/ossimCommon.h> /* for round */
20 
28 {
29 public:
30 
33 
36 
37  enum
38  {
39  TABLE_ENTRIES = 65536, // 2^16 32767-(-32768)+1
40  OFFSET_TO_ZERO = 32768, // Gets -32768 to zero.
41  NULL_PIX = -32768,
42  MIN_PIX = -32767
43  };
44 
49  virtual ossim_int32 getEntries() const;
50 
60  virtual ossim_float64 operator[](ossim_int32 pix) const;
61 
71  virtual ossim_float64 normFromPix(ossim_int32 pix) const;
72 
80  virtual ossim_int32 pixFromNorm(ossim_float64 normPix) const;
81 
82 private:
83 
84  static ossim_float64 theTable[TABLE_ENTRIES];
85  static bool theTableIsInitialized;
86 
87 };
88 
90 {
91  return TABLE_ENTRIES;
92 }
93 
95  ossim_int32 pix) const
96 {
97  ossim_float64 result = 0;
98 
99  // Move pix into table range. This will take -32768 to 0.
100  ossim_int32 p = pix + OFFSET_TO_ZERO;
101 
102  result = (p < TABLE_ENTRIES ? ( p >= 0 ? theTable[p] : 0.0) : 1.0);
103 
104  return result;
105 }
106 
108  ossim_int32 pix) const
109 {
110  ossim_float64 result = 0;
111 
112  // Move pix into table range. This will take -32768 to 0.
113  ossim_int32 p = pix + OFFSET_TO_ZERO;
114 
115  result = (p < TABLE_ENTRIES ? ( p >= 0 ? theTable[p] : 0.0) : 1.0);
116 
117  return result;
118 }
119 
121  ossim_float64 normPix) const
122 {
123  if(normPix <= 0.0) return NULL_PIX;
124 
125  // Clamp between 0 and 1 on the way in.
126  ossim_float64 p = (normPix<1.0) ? ( (normPix>0.0) ? normPix : 0.0) : 1.0;
127 
128  // Un-normalize.
129  p = p * getNormalizer(); // TABLE_ENTRIES - 1;
130 
131  //---
132  // Move pixel into sign range then round it. This will take 65535 to
133  // 32767 which is the max pixel for this scalar type.
134  //---
135  p = ossim::round<ossim_int32>(p - OFFSET_TO_ZERO);
136 
137  if (p == NULL_PIX)
138  {
139  // norm pixel came in just above zero so should be at least min.
140  p = MIN_PIX;
141  }
142 
143  return static_cast<ossim_int32>(p);
144 }
145 
146 #endif
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_float64 operator[](ossim_int32 pix) const
Gets normalized value (between &#39;0.0&#39; and &#39;1.0&#39;) from an int which should in scalar range of a signed ...
Signed 16 bit normalized remap tables to go to/from normalized value to 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.
virtual ossim_int32 pixFromNorm(ossim_float64 normPix) const
Gets pixel value from normalized value.
Base class implemetation of normalized remap tables to go to/from normalized value to pixel value...
#define OSSIM_DLL
virtual ossim_float64 normFromPix(ossim_int32 pix) const
Gets normalized value (between &#39;0.0&#39; and &#39;1.0&#39;) from an int which should in scalar range of a signed ...
virtual ossim_float64 getNormalizer() const
Get the value used to normalize and un-normalize table entries.
static ossim_float64 theTable[TABLE_ENTRIES]
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.
int ossim_int32