OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Types | Public Member Functions | Static Private Attributes | List of all members
ossimNormalizedS16RemapTable Class Reference

Signed 16 bit normalized remap tables to go to/from normalized value to pixel value. More...

#include <ossimNormalizedS16RemapTable.h>

Inheritance diagram for ossimNormalizedS16RemapTable:
ossimNormalizedRemapTable

Public Types

enum  { TABLE_ENTRIES = 65536, OFFSET_TO_ZERO = 32768, NULL_PIX = -32768, MIN_PIX = -32767 }
 

Public Member Functions

 ossimNormalizedS16RemapTable ()
 default constructor More...
 
virtual ~ossimNormalizedS16RemapTable ()
 virtual destructor More...
 
virtual ossim_int32 getEntries () const
 Gets the number of table entries. More...
 
virtual ossim_float64 operator[] (ossim_int32 pix) const
 Gets normalized value (between '0.0' and '1.0') from an int which should in scalar range of a signed 16 bit. More...
 
virtual ossim_float64 normFromPix (ossim_int32 pix) const
 Gets normalized value (between '0.0' and '1.0') from an int which should in scalar range of a signed 16 bit. More...
 
virtual ossim_int32 pixFromNorm (ossim_float64 normPix) const
 Gets pixel value from normalized value. More...
 
- Public Member Functions inherited from ossimNormalizedRemapTable
 ossimNormalizedRemapTable ()
 default constructor More...
 
virtual ~ossimNormalizedRemapTable ()
 virtual destructor More...
 
virtual ossim_float64 getNormalizer () const
 Get the value used to normalize and un-normalize table entries. More...
 

Static Private Attributes

static ossim_float64 theTable [TABLE_ENTRIES]
 
static bool theTableIsInitialized = false
 

Detailed Description

Signed 16 bit normalized remap tables to go to/from normalized value to pixel value.

Definition at line 27 of file ossimNormalizedS16RemapTable.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
TABLE_ENTRIES 
OFFSET_TO_ZERO 
NULL_PIX 
MIN_PIX 

Definition at line 37 of file ossimNormalizedS16RemapTable.h.

Constructor & Destructor Documentation

◆ ossimNormalizedS16RemapTable()

ossimNormalizedS16RemapTable::ossimNormalizedS16RemapTable ( )

default constructor

Definition at line 19 of file ossimNormalizedS16RemapTable.cpp.

References getEntries(), ossimNormalizedRemapTable::getNormalizer(), theTable, and theTableIsInitialized.

21 {
23  {
24  const ossim_int32 ENTRIES = getEntries();
25  const ossim_float64 DENOMINATOR = getNormalizer();
26 
27  //---
28  // Initialize the remap table.
29  //
30  // Specialized for elevation, make -32768 and -32767 map to 0 since
31  // DTED NULL is -32767.
32  //
33  // NOTE: Zero will always remap back to -32768 with this hack. This
34  // could cause issues on writers that use pixFromNorm(). (drb)
35  //---
36  theTable[0] = 0.0; // Index zero always for null.
37  theTable[1] = 0.0; // Specialized for DTED.
38 
39  for (ossim_int32 i = 2; i < ENTRIES; ++i)
40  {
41  theTable[i] = static_cast<ossim_float64>(i)/DENOMINATOR;
42  }
43 
44  theTableIsInitialized = true;
45  }
46 }
virtual ossim_int32 getEntries() const
Gets the number of table entries.
double ossim_float64
ossimNormalizedRemapTable()
default constructor
virtual ossim_float64 getNormalizer() const
Get the value used to normalize and un-normalize table entries.
static ossim_float64 theTable[TABLE_ENTRIES]
int ossim_int32

◆ ~ossimNormalizedS16RemapTable()

ossimNormalizedS16RemapTable::~ossimNormalizedS16RemapTable ( )
virtual

virtual destructor

Definition at line 48 of file ossimNormalizedS16RemapTable.cpp.

49 {}

Member Function Documentation

◆ getEntries()

ossim_int32 ossimNormalizedS16RemapTable::getEntries ( ) const
inlinevirtual

Gets the number of table entries.

Returns
The number of entries in a table.

Implements ossimNormalizedRemapTable.

Definition at line 89 of file ossimNormalizedS16RemapTable.h.

References TABLE_ENTRIES.

Referenced by ossimNormalizedS16RemapTable().

◆ normFromPix()

ossim_float64 ossimNormalizedS16RemapTable::normFromPix ( ossim_int32  pix) const
inlinevirtual

Gets normalized value (between '0.0' and '1.0') from an int which should in scalar range of a signed 16 bit.

Note
This table is specialized to map both -32768 and -32767 to 0 since dted data has a null of -32767.
Returns
Value between 0.0 and 1.0.

Implements ossimNormalizedRemapTable.

Definition at line 107 of file ossimNormalizedS16RemapTable.h.

References OFFSET_TO_ZERO, and theTable.

Referenced by ossimS16ImageData::convertToNormalizedDouble(), ossimS16ImageData::copyTileToNormalizedBuffer(), and ossimS16ImageData::getNormalizedFloat().

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 }
double ossim_float64
static ossim_float64 theTable[TABLE_ENTRIES]
int ossim_int32

◆ operator[]()

ossim_float64 ossimNormalizedS16RemapTable::operator[] ( ossim_int32  pix) const
inlinevirtual

Gets normalized value (between '0.0' and '1.0') from an int which should in scalar range of a signed 16 bit.

Note
This table is specialized to map both -32768 and -32767 to 0 since dted data has a null of -32767.
Returns
Value between 0.0 and 1.0.

Implements ossimNormalizedRemapTable.

Definition at line 94 of file ossimNormalizedS16RemapTable.h.

References OFFSET_TO_ZERO, and theTable.

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 }
double ossim_float64
static ossim_float64 theTable[TABLE_ENTRIES]
int ossim_int32

◆ pixFromNorm()

ossim_int32 ossimNormalizedS16RemapTable::pixFromNorm ( ossim_float64  normPix) const
inlinevirtual

Gets pixel value from normalized value.

Valid returns range is signed 16 bit range or -32768 to 32767.

Returns
Value between -32768 to 32767.

Implements ossimNormalizedRemapTable.

Definition at line 120 of file ossimNormalizedS16RemapTable.h.

References ossimNormalizedRemapTable::getNormalizer(), MIN_PIX, NULL_PIX, and OFFSET_TO_ZERO.

Referenced by ossimS16ImageData::copyNormalizedBufferToTile(), and ossimS16ImageData::setNormalizedFloat().

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 }
double ossim_float64
virtual ossim_float64 getNormalizer() const
Get the value used to normalize and un-normalize table entries.
int ossim_int32

Member Data Documentation

◆ theTable

ossim_float64 ossimNormalizedS16RemapTable::theTable
staticprivate

◆ theTableIsInitialized

bool ossimNormalizedS16RemapTable::theTableIsInitialized = false
staticprivate

Definition at line 85 of file ossimNormalizedS16RemapTable.h.

Referenced by ossimNormalizedS16RemapTable().


The documentation for this class was generated from the following files: