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

class ossimNBandLutDataObject More...

#include <ossimNBandLutDataObject.h>

Inheritance diagram for ossimNBandLutDataObject:
ossimObject ossimReferenced

Public Types

typedef ossim_int32 LUT_ENTRY_TYPE
 

Public Member Functions

 ossimNBandLutDataObject (ossim_uint32 numberOfEntries=0, ossim_uint32 numberOfBands=0, ossimScalarType bandScalarType=OSSIM_UINT8, ossim_int32 nullPixelIndex=-1)
 
 ossimNBandLutDataObject (const ossimNBandLutDataObject &lut)
 
ossimObjectdup () const
 
void create (ossim_uint32 numberOfEntries, ossim_uint32 numberOfBands=3)
 
const LUT_ENTRY_TYPEoperator[] (ossim_uint32 idx) const
 
LUT_ENTRY_TYPEoperator[] (ossim_uint32 idx)
 
const LUT_ENTRY_TYPEoperator[] (ossim_int32 idx) const
 
LUT_ENTRY_TYPEoperator[] (ossim_int32 idx)
 
const LUT_ENTRY_TYPEoperator[] (double normalizedIndex) const
 
LUT_ENTRY_TYPEoperator[] (double normalizedIndex)
 
bool hasNullPixelIndex () const
 
void getMinMax (ossim_uint32 band, LUT_ENTRY_TYPE &minValue, LUT_ENTRY_TYPE &maxValue)
 Will return the min max value for a given band. More...
 
ossim_int32 getFirstNullAlphaIndex () const
 
void setNullPixelIndex (ossim_int32 idx)
 Allows you to specify which entry is to be designated as an invalid entry. More...
 
ossim_int32 getNullPixelIndex () const
 
ossim_uint32 getNumberOfBands () const
 
ossim_uint32 getNumberOfEntries () const
 
ossim_uint32 findIndex (ossim_int32 *values) const
 This method gives you a way to find an entry index closest to the passed in band values. More...
 
ossim_uint32 findIndex (ossim_int32 *values, ossim_uint32 size) const
 This method gives you a way to find an entry index closest to the passed in band values. More...
 
void clearLut ()
 Will do a simple memset to '\0' all. More...
 
const ossimNBandLutDataObjectoperator= (const ossimNBandLutDataObject &lut)
 does a deep copy from the passed in lut to the object. More...
 
bool operator== (const ossimNBandLutDataObject &lut) const
 Determines if the state of this lut is identical to the passed in lut. More...
 
bool open (const ossimFilename &lutFile)
 Reads in an external lut file. More...
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 
std::vector< ossimStringgetEntryLabels (ossim_uint32 band)
 
void setEntryLables (ossim_uint32 band, std::vector< ossimString > entryLabels)
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 Loads the state of the object by reading in the keywords listed in the save state. More...
 
- Public Member Functions inherited from ossimObject
 ossimObject ()
 
virtual ~ossimObject ()
 
virtual ossimString getShortName () const
 
virtual ossimString getLongName () const
 
virtual ossimString getDescription () const
 
virtual ossimString getClassName () const
 
virtual RTTItypeid getType () const
 
virtual bool canCastTo (ossimObject *obj) const
 
virtual bool canCastTo (const RTTItypeid &id) const
 
virtual bool canCastTo (const ossimString &parentClassName) const
 
virtual std::ostream & print (std::ostream &out) const
 Generic print method. More...
 
virtual bool isEqualTo (const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
 
virtual void accept (ossimVisitor &visitor)
 
- Public Member Functions inherited from ossimReferenced
 ossimReferenced ()
 
 ossimReferenced (const ossimReferenced &)
 
ossimReferencedoperator= (const ossimReferenced &)
 
void ref () const
 increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unref () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unref_nodelete () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
int referenceCount () const
 

Protected Member Functions

virtual ~ossimNBandLutDataObject ()
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 

Protected Attributes

LUT_ENTRY_TYPEtheLut
 
ossim_uint32 theNumberOfEntries
 
ossim_uint32 theNumberOfBands
 
ossimScalarType theBandScalarType
 
ossim_int32 theNullPixelIndex
 
std::map< ossim_uint32, std::vector< ossimString > > m_entryLabels
 

Friends

std::ostream & operator<< (std::ostream &out, const ossimNBandLutDataObject &lut)
 

Detailed Description

class ossimNBandLutDataObject

Sample CADRG LUT taken from an arbitrary CADRG image entry. This is a keywordlist support by the loadstate of this class.

entry0:  25 39 116 
entry1:  245 242 242 
entry10:  92 89 115 
entry100:  74 55 85 
entry101:  233 165 53 
entry102:  75 2 4 
entry103:  162 118 42 
entry104:  233 159 130 
entry105:  189 129 40 
entry106:  154 109 66 
entry107:  145 97 85 
entry108:  121 86 31 
entry109:  238 151 118 
entry11:  52 31 76 
entry110:  239 167 42 
entry111:  236 137 100 
entry112:  179 112 88 
entry113:  92 37 33 
entry114:  121 66 24 
entry115:  120 133 151 
entry116:  76 92 192 
entry117:  36 50 117 
entry118:  57 75 191 
entry119:  125 45 50 
entry12:  235 217 204 
entry120:  102 65 81 
entry121:  172 148 199 
entry122:  204 145 95 
entry123:  81 19 5 
entry124:  91 4 1 
entry125:  109 54 31 
entry126:  137 114 118 
entry127:  230 150 52 
entry128:  82 38 87 
entry129:  190 120 76 
entry13:  244 218 172 
entry130:  170 109 45 
entry131:  95 20 22 
entry132:  150 80 61 
entry133:  225 122 82 
entry134:  122 37 16 
entry135:  146 88 49 
entry136:  122 94 122 
entry137:  230 135 63 
entry138:  137 73 75 
entry139:  119 46 29 
entry14:  189 167 141 
entry140:  190 142 128 
entry141:  242 216 187 
entry142:  176 125 95 
entry143:  193 117 143 
entry144:  19 0 0 
entry145:  12 1 42 
entry146:  24 4 26 
entry147:  38 40 52 
entry148:  8 24 175 
entry149:  40 23 45 
entry15:  245 213 142 
entry150:  39 11 58 
entry151:  10 0 22 
entry152:  236 148 41 
entry153:  101 41 11 
entry154:  230 113 67 
entry155:  148 44 46 
entry156:  225 144 133 
entry157:  115 2 13 
entry158:  159 79 49 
entry159:  164 95 33 
entry16:  246 241 205 
entry160:  97 6 22 
entry161:  175 90 133 
entry162:  112 23 20 
entry163:  105 22 6 
entry164:  148 59 33 
entry165:  215 118 104 
entry166:  211 122 41 
entry167:  233 129 34 
entry168:  153 73 25 
entry169:  208 102 39 
entry17:  240 215 89 
entry170:  206 101 133 
entry171:  229 113 96 
entry172:  127 16 25 
entry173:  224 104 28 
entry174:  171 76 74 
entry175:  221 94 78 
entry176:  229 86 94 
entry177:  213 80 57 
entry178:  161 44 36 
entry179:  155 54 19 
entry18:  115 92 157 
entry180:  130 25 5 
entry181:  150 29 24 
entry182:  198 54 34 
entry183:  224 61 70 
entry184:  213 82 37 
entry185:  186 28 31 
entry186:  200 64 15 
entry187:  110 2 2 
entry188:  195 38 12 
entry189:  151 6 8 
entry19:  160 163 37 
entry190:  193 13 10 
entry191:  205 1 3 
entry192:  44 62 193 
entry193:  35 14 16 
entry194:  15 30 118 
entry195:  28 47 189 
entry196:  25 3 80 
entry197:  7 16 118 
entry198:  33 10 6 
entry199:  39 24 95 
entry2:  216 212 237 
entry20:  38 29 21 
entry200:  82 58 159 
entry201:  55 29 142 
entry202:  33 4 23 
entry203:  17 14 36 
entry204:  58 26 41 
entry205:  11 13 14 
entry206:  74 87 85 
entry207:  50 60 41 
entry208:  119 123 98 
entry209:  193 187 172 
entry21:  208 202 156 
entry210:  124 126 128 
entry211:  47 68 84 
entry212:  110 119 60 
entry213:  63 145 121 
entry214:  154 166 147 
entry215:  107 156 104 
entry22:  242 202 152 
entry23:  168 148 140 
entry24:  31 22 25 
entry25:  245 205 114 
entry26:  245 191 137 
entry27:  175 161 172 
entry28:  17 6 11 
entry29:  172 170 137 
entry3:  247 230 113 
entry30:  51 27 20 
entry31:  239 210 73 
entry32:  185 176 129 
entry33:  35 2 13 
entry34:  60 52 51 
entry35:  101 78 70 
entry36:  141 124 101 
entry37:  206 184 107 
entry38:  244 174 106 
entry39:  82 98 136 
entry4:  246 231 132 
entry40:  190 191 239 
entry41:  241 188 161 
entry42:  67 51 38 
entry43:  244 184 122 
entry44:  211 201 142 
entry45:  61 27 16 
entry46:  182 182 82 
entry47:  243 188 87 
entry48:  86 83 60 
entry49:  61 40 43 
entry5:  204 198 166 
entry50:  146 141 93 
entry51:  44 4 4 
entry52:  231 210 51 
entry53:  85 74 39 
entry54:  197 169 127 
entry55:  182 151 60 
entry56:  121 98 73 
entry57:  243 182 145 
entry58:  58 18 21 
entry59:  241 157 91 
entry6:  2 0 2 
entry60:  59 4 1 
entry61:  155 162 223 
entry62:  154 133 80 
entry63:  73 21 16 
entry64:  195 183 116 
entry65:  76 51 29 
entry66:  234 181 63 
entry67:  58 59 98 
entry68:  42 22 79 
entry69:  134 143 219 
entry7:  204 204 239 
entry70:  106 117 205 
entry71:  48 65 117 
entry72:  63 54 117 
entry73:  125 93 62 
entry74:  137 138 41 
entry75:  104 68 59 
entry76:  113 99 41 
entry77:  76 30 11 
entry78:  239 184 48 
entry79:  161 129 98 
entry8:  31 4 66 
entry80:  241 170 126 
entry81:  145 109 105 
entry82:  207 163 116 
entry83:  79 41 40 
entry84:  175 138 41 
entry85:  10 0 56 
entry86:  180 151 77 
entry87:  72 12 24 
entry88:  242 154 105 
entry89:  91 26 15 
entry9:  246 238 162 
entry90:  160 118 53 
entry91:  228 166 141 
entry92:  231 160 69 
entry93:  61 2 11 
entry94:  132 83 60 
entry95:  86 46 24 
entry96:  243 143 86 
entry97:  108 60 46 
entry98:  109 76 38 
entry99:  96 86 84 
null_value:  -1
number_bands:  3
number_entries:  216
scalar_type:  ossim_uint8
type:  ossimNBandLutDataObject
NOTES:
  • The null_value keyword above is the index in the lut that correspnds to an invalid pixel value.
  • Each entry will have number_bands. SO if number of bands is 3 then there will be 3 values Where the first value is for band 1, ... etc.
  • scalar_type is a hint as to the scalar type of the entries. Is the resulting lut for 8 bit, 16 bit , etc data.
  • You should always use the LUT_ENTRY_TYPE when getting values from the lut. This value could change to an ossim_float32 precision and if you use the LUT_ENTRY_TYPE then your code will not have to change.
 

Definition at line 259 of file ossimNBandLutDataObject.h.

Member Typedef Documentation

◆ LUT_ENTRY_TYPE

Definition at line 263 of file ossimNBandLutDataObject.h.

Constructor & Destructor Documentation

◆ ossimNBandLutDataObject() [1/2]

ossimNBandLutDataObject::ossimNBandLutDataObject ( ossim_uint32  numberOfEntries = 0,
ossim_uint32  numberOfBands = 0,
ossimScalarType  bandScalarType = OSSIM_UINT8,
ossim_int32  nullPixelIndex = -1 
)

Will allocate 256 values for the color table

Definition at line 51 of file ossimNBandLutDataObject.cpp.

References create().

55  :theLut(0),
58  theBandScalarType(bandScalarType),
59  theNullPixelIndex(nullPixelIndex)
60 {
61  create(numberOfEntries, numberOfBands);
62 }
void create(ossim_uint32 numberOfEntries, ossim_uint32 numberOfBands=3)

◆ ossimNBandLutDataObject() [2/2]

ossimNBandLutDataObject::ossimNBandLutDataObject ( const ossimNBandLutDataObject lut)

Definition at line 64 of file ossimNBandLutDataObject.cpp.

65  :theLut(0),
71 {
72  *this = lut;
73 }
std::map< ossim_uint32, std::vector< ossimString > > m_entryLabels

◆ ~ossimNBandLutDataObject()

ossimNBandLutDataObject::~ossimNBandLutDataObject ( )
protectedvirtual

Definition at line 75 of file ossimNBandLutDataObject.cpp.

References m_entryLabels, theLut, theNumberOfBands, and theNumberOfEntries.

76 {
77  if(theLut)
78  {
79  delete [] theLut;
80  theLut = 0;
81  }
83  theNumberOfBands = 0;
84  m_entryLabels.clear();
85 }
std::map< ossim_uint32, std::vector< ossimString > > m_entryLabels

Member Function Documentation

◆ clearLut()

void ossimNBandLutDataObject::clearLut ( )

Will do a simple memset to '\0' all.

Definition at line 150 of file ossimNBandLutDataObject.cpp.

References theLut, theNumberOfBands, and theNumberOfEntries.

Referenced by loadState().

◆ create()

void ossimNBandLutDataObject::create ( ossim_uint32  numberOfEntries,
ossim_uint32  numberOfBands = 3 
)

Definition at line 87 of file ossimNBandLutDataObject.cpp.

References theLut, theNumberOfBands, and theNumberOfEntries.

Referenced by ossimNitfImageHeader::createLut(), loadState(), operator=(), and ossimNBandLutDataObject().

89 {
90  if(theLut)
91  {
92  delete [] theLut;
93  theLut = 0;
94  }
95  if(numberOfEntries&&numberOfBands)
96  {
97  theLut = new ossimNBandLutDataObject::LUT_ENTRY_TYPE[numberOfEntries*numberOfBands];
98  theNumberOfEntries = numberOfEntries;
99  theNumberOfBands = numberOfBands;
100  }
101  else
102  {
103  theNumberOfEntries = 0;
104  theNumberOfBands = 0;
105  }
106 }

◆ dup()

ossimObject* ossimNBandLutDataObject::dup ( ) const
inlinevirtual

Reimplemented from ossimObject.

Definition at line 275 of file ossimNBandLutDataObject.h.

Referenced by ossimGdalWriter::setLut(), and ossimTiffWriter::setLut().

276  {
277  return new ossimNBandLutDataObject(*this);
278  }
ossimNBandLutDataObject(ossim_uint32 numberOfEntries=0, ossim_uint32 numberOfBands=0, ossimScalarType bandScalarType=OSSIM_UINT8, ossim_int32 nullPixelIndex=-1)

◆ findIndex() [1/2]

ossim_uint32 ossimNBandLutDataObject::findIndex ( ossim_int32 values) const

This method gives you a way to find an entry index closest to the passed in band values.

Parameters
valuesIs an array of band values. This array must be equal to the number of bands for the lut.
Returns
Returns the nearest index to the passed in value.

Definition at line 108 of file ossimNBandLutDataObject.cpp.

References theNumberOfBands.

Referenced by ossimNBandToIndexFilter::convertInputTileToOutputTemplate().

110 {
111  return findIndex(bandValues, theNumberOfBands);
112 }
ossim_uint32 findIndex(ossim_int32 *values) const
This method gives you a way to find an entry index closest to the passed in band values.

◆ findIndex() [2/2]

ossim_uint32 ossimNBandLutDataObject::findIndex ( ossim_int32 values,
ossim_uint32  size 
) const

This method gives you a way to find an entry index closest to the passed in band values.

Parameters
valuesIs an array of band values.
sizeSize of values array. Note if size is less than the LUT number of bands, the trailing bands get dropped. This allows finding an index dropping the alpha channel.
Returns
Returns the nearest index to the passed in value.

Definition at line 114 of file ossimNBandLutDataObject.cpp.

References DBL_EPSILON, distance(), size, theLut, theNumberOfBands, and theNumberOfEntries.

116 {
117  ossim_uint32 result = 0;
118 
119  if ( (theNumberOfEntries > 0) && (size <= theNumberOfBands) )
120  {
122  ossim_uint32 idx = 0;
123  ossim_uint32 bandIdx = 0;
125 
126  for(idx = 0; idx < theNumberOfEntries; ++idx,lutPtr+=theNumberOfBands)
127  {
128  ossim_float64 sumSquare = 0.0;
129 
130  for(bandIdx = 0; bandIdx < size; ++bandIdx)
131  {
132  ossim_int64 delta = lutPtr[bandIdx] - bandValues[bandIdx];
133  sumSquare += (delta*delta);
134  }
135  if((ossimNBandLutDataObject::LUT_ENTRY_TYPE)sumSquare == 0)
136  {
137  return idx;
138  }
139  else if( sumSquare < distance)
140  {
141  result = idx;
142  distance = sumSquare;
143  }
144  }
145  }
146 
147  return result;
148 }
double ossim_float64
yy_size_t size
unsigned int ossim_uint32
#define DBL_EPSILON
long long ossim_int64
float distance(double lat1, double lon1, double lat2, double lon2, int units)

◆ getEntryLabels()

std::vector< ossimString > ossimNBandLutDataObject::getEntryLabels ( ossim_uint32  band)

Definition at line 376 of file ossimNBandLutDataObject.cpp.

References m_entryLabels.

Referenced by ossimGdalWriter::writeColorMap().

377 {
378  std::map<ossim_uint32, std::vector<ossimString> >::iterator it = m_entryLabels.find(band);
379  if (it != m_entryLabels.end())
380  {
381  return it->second;
382  }
383  return std::vector<ossimString>();
384 }
std::map< ossim_uint32, std::vector< ossimString > > m_entryLabels

◆ getFirstNullAlphaIndex()

ossim_int32 ossimNBandLutDataObject::getFirstNullAlphaIndex ( ) const
Returns
First index with alpha of 0 or -1 if not found or there is no alpha.

Currently only works on 4 band data. May consider adding an alpha channel class data member in the future.

Definition at line 189 of file ossimNBandLutDataObject.cpp.

References theLut, theNumberOfBands, and theNumberOfEntries.

Referenced by ossimGdalTileSource::setPreservePaletteIndexesFlag().

190 {
191  ossim_int32 result = -1;
192  if ( (theNumberOfBands == 4) && (theNumberOfEntries > 0) )
193  {
194  ossim_uint32 idx = 0;
195  LUT_ENTRY_TYPE* bandPtr = theLut+3; // Index to the first alpha channel.
196  for ( idx = 0; idx < theNumberOfEntries; ++idx, bandPtr+=theNumberOfBands )
197  {
198  if ( *bandPtr == 0 )
199  {
200  result = *bandPtr;
201  break;
202  }
203  }
204  }
205  return result;
206 }
unsigned int ossim_uint32
int ossim_int32

◆ getMinMax()

void ossimNBandLutDataObject::getMinMax ( ossim_uint32  band,
ossimNBandLutDataObject::LUT_ENTRY_TYPE minValue,
ossimNBandLutDataObject::LUT_ENTRY_TYPE maxValue 
)

Will return the min max value for a given band.

Parameters
bandband number to query. This is 0 based so the first band is indicated by the value of 0.
minValueis the minimum value returned for the passed in band
maxValueis the maximum value returned for the passed in band

Definition at line 158 of file ossimNBandLutDataObject.cpp.

References theLut, theNullPixelIndex, theNumberOfBands, and theNumberOfEntries.

Referenced by ossimNBandToIndexFilter::initialize().

161 {
162  minValue = 0;
163  maxValue = 0;
164  ossim_uint32 idx = 0;
165  LUT_ENTRY_TYPE *bandPtr = theLut+band;
166  if((band < theNumberOfBands)&&
167  (theNumberOfEntries > 0))
168  {
169  minValue = theLut[band];
170  maxValue = theLut[band];
171 
172  for(idx = 0; idx < theNumberOfEntries; ++idx,bandPtr+=theNumberOfBands)
173  {
174  if((ossim_int32)idx != theNullPixelIndex)
175  {
176  if(bandPtr[band] < minValue)
177  {
178  minValue = bandPtr[band];
179  }
180  if(bandPtr[band] > maxValue)
181  {
182  maxValue = bandPtr[band];
183  }
184  }
185  }
186  }
187 }
unsigned int ossim_uint32
int ossim_int32

◆ getNullPixelIndex()

ossim_int32 ossimNBandLutDataObject::getNullPixelIndex ( ) const
inline
Returns
Return either a positive value indicating the entry designated for a null pixel value or a -1 to say no null pixel has been designated yet.

Definition at line 379 of file ossimNBandLutDataObject.h.

Referenced by ossimNBandToIndexFilter::getNullPixelValue(), ossimGdalTileSource::getNullPixelValue(), and ossimNBandToIndexFilter::initialize().

◆ getNumberOfBands()

ossim_uint32 ossimNBandLutDataObject::getNumberOfBands ( ) const
inline

◆ getNumberOfEntries()

ossim_uint32 ossimNBandLutDataObject::getNumberOfEntries ( ) const
inline

◆ hasNullPixelIndex()

bool ossimNBandLutDataObject::hasNullPixelIndex ( ) const
inline

Definition at line 342 of file ossimNBandLutDataObject.h.

343  {
344  return (theNullPixelIndex >= 0);
345  }

◆ loadState()

bool ossimNBandLutDataObject::loadState ( const ossimKeywordlist kwl,
const char *  prefix = 0 
)
virtual

Loads the state of the object by reading in the keywords listed in the save state.

Parameters
kwlThe keywordlist to extract the classes keywords from to restore its state.
prefixOptional prefix value used to prefix each keyword.

Reimplemented from ossimObject.

Definition at line 299 of file ossimNBandLutDataObject.cpp.

References ossimKeywordlist::addFile(), ossimString::c_str(), clearLut(), create(), ossimFilename::exists(), ossimKeywordNames::FILENAME_KW, ossimKeywordlist::find(), ossimLookUpTable::getEntryNumber(), ossimScalarTypeLut::instance(), ossimLookUpTable::NOT_FOUND, ossimKeywordNames::NULL_VALUE_KW, ossimKeywordNames::NUMBER_BANDS_KW, ossimKeywordNames::NUMBER_ENTRIES_KW, theBandScalarType, theLut, theNullPixelIndex, theNumberOfBands, theNumberOfEntries, ossimString::toInt32(), ossimString::toString(), and ossimString::trim().

Referenced by ossimNBandToIndexFilter::loadState(), open(), and ossimNBandToIndexFilter::setProperty().

300 {
301  const char* nullPixelIndex = kwl.find(prefix, ossimKeywordNames::NULL_VALUE_KW);
302  const char* lutFile = kwl.find(prefix, ossimKeywordNames::FILENAME_KW);
303  ossimKeywordlist fileLut;
304  const ossimKeywordlist* tempKwl = &kwl;
305  ossimString tempPrefix = prefix;
306 
307  // check to see if we should open an external file
308  // if so point the fileLut to the one that we use
309  if(lutFile)
310  {
311  ossimFilename filename(lutFile);
312  if(filename.exists())
313  {
314  fileLut.addFile(filename.c_str());
315  tempKwl = &fileLut;
316  tempPrefix = "";
317  }
318  }
319 
320  if(nullPixelIndex)
321  {
322  theNullPixelIndex = ossimString(nullPixelIndex).toInt32();
323  }
324  else
325  {
326  theNullPixelIndex = -1;
327  }
328  int scalar = ossimScalarTypeLut::instance()->getEntryNumber(kwl, prefix);
329 
330  if (scalar != ossimLookUpTable::NOT_FOUND)
331  {
332  theBandScalarType = static_cast<ossimScalarType>(scalar);
333  }
334  const char* numberOfBands = tempKwl->find(tempPrefix, ossimKeywordNames::NUMBER_BANDS_KW);
335  const char* numberOfEntries = tempKwl->find(tempPrefix, ossimKeywordNames::NUMBER_ENTRIES_KW);
336 
337  if (numberOfBands && numberOfEntries)
338  {
339  create(ossimString(numberOfEntries).toUInt32(),
340  ossimString(numberOfBands).toUInt32());
341  }
342 
343  clearLut();
345 
346  if(lutPtr)
347  {
348  ossim_uint32 entryIdx;
349  ossim_uint32 bandIdx;
350  for(entryIdx = 0; entryIdx < theNumberOfEntries; ++entryIdx)
351  {
352  ossimString newPrefix = "entry";
353  newPrefix += ossimString::toString(entryIdx);
354  ossimString v = tempKwl->find(tempPrefix, newPrefix.c_str());
355  v = v.trim();
356  if(v != "")
357  {
358  std::istringstream istr(v);
359  ossimString lutValue;
360  for(bandIdx = 0; bandIdx < theNumberOfBands; ++bandIdx)
361  {
362  if(!istr.fail())
363  {
364  istr >> lutValue;
365  lutPtr[bandIdx] = lutValue.toInt32();
366  }
367  }
368  }
369  lutPtr += theNumberOfBands;
370  }
371  }
372 
373  return true;
374 }
Represents serializable keyword/value map.
bool addFile(const char *file)
const char * find(const char *key) const
static const char * NULL_VALUE_KW
static ossimString toString(bool aValue)
Numeric to string methods.
static const char * NUMBER_ENTRIES_KW
virtual ossim_int32 getEntryNumber(const char *entry_string, bool case_insensitive=true) const
ossim_int32 toInt32() const
void clearLut()
Will do a simple memset to &#39;\0&#39; all.
static ossimScalarTypeLut * instance()
Returns the static instance of an ossimScalarTypeLut object.
unsigned int ossim_uint32
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
static const char * NUMBER_BANDS_KW
ossimScalarType
void create(ossim_uint32 numberOfEntries, ossim_uint32 numberOfBands=3)
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
std::basic_istringstream< char > istringstream
Class for char input memory streams.
Definition: ossimIosFwd.h:32
static const char * FILENAME_KW

◆ open()

bool ossimNBandLutDataObject::open ( const ossimFilename lutFile)

Reads in an external lut file.

The external file is in a keywordlist format specified by the saveState.

Definition at line 291 of file ossimNBandLutDataObject.cpp.

References ossimKeywordlist::addFile(), and loadState().

Referenced by ossimGdalWriter::setProperty(), and ossimTiffWriter::setProperty().

292 {
293  ossimKeywordlist kwl;
294  kwl.addFile(lutFile);
295 
296  return loadState(kwl);
297 }
Represents serializable keyword/value map.
bool addFile(const char *file)
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Loads the state of the object by reading in the keywords listed in the save state.

◆ operator=()

const ossimNBandLutDataObject & ossimNBandLutDataObject::operator= ( const ossimNBandLutDataObject lut)

does a deep copy from the passed in lut to the object.

Parameters
lutThe lut to copy.

Definition at line 208 of file ossimNBandLutDataObject.cpp.

References create(), theBandScalarType, theLut, theNullPixelIndex, theNumberOfBands, and theNumberOfEntries.

209 {
211  {
212  delete [] theLut;
213  theLut = 0;
214  }
215 
219  lut.theNumberOfBands);
220 
221  if(theLut)
222  {
224  }
225 
226  return *this;
227 }
void create(ossim_uint32 numberOfEntries, ossim_uint32 numberOfBands=3)

◆ operator==()

bool ossimNBandLutDataObject::operator== ( const ossimNBandLutDataObject lut) const

Determines if the state of this lut is identical to the passed in lut.

Parameters
lutChecks equality of the this object to the lut parameter.
Returns
True if equal and false otherwise

Definition at line 229 of file ossimNBandLutDataObject.cpp.

References theBandScalarType, theLut, theNullPixelIndex, theNumberOfBands, and theNumberOfEntries.

230 {
232  {
233  return false;
234  }
235 
236  if(!theLut && !lut.theLut) return true;
237  if(theNullPixelIndex != lut.theNullPixelIndex) return false;
238  if(theBandScalarType != lut.theBandScalarType) return false;
239 
240  if(theLut&&lut.theLut)
241  {
243  }
244  return false;
245 }

◆ operator[]() [1/6]

const LUT_ENTRY_TYPE* ossimNBandLutDataObject::operator[] ( ossim_uint32  idx) const
inline

Definition at line 281 of file ossimNBandLutDataObject.h.

282  {
283  if(theLut)
284  {
285  return &theLut[idx*theNumberOfBands];
286  }
287 
288  return 0;
289  }

◆ operator[]() [2/6]

LUT_ENTRY_TYPE* ossimNBandLutDataObject::operator[] ( ossim_uint32  idx)
inline

Definition at line 290 of file ossimNBandLutDataObject.h.

291  {
292  if(theLut)
293  {
294  return &theLut[idx*theNumberOfBands];
295  }
296 
297  return 0;
298  }

◆ operator[]() [3/6]

const LUT_ENTRY_TYPE* ossimNBandLutDataObject::operator[] ( ossim_int32  idx) const
inline

Definition at line 299 of file ossimNBandLutDataObject.h.

300  {
301  if(theLut)
302  {
303  return &theLut[idx*theNumberOfBands];
304  }
305 
306  return 0;
307  }

◆ operator[]() [4/6]

LUT_ENTRY_TYPE* ossimNBandLutDataObject::operator[] ( ossim_int32  idx)
inline

Definition at line 308 of file ossimNBandLutDataObject.h.

309  {
310  if(theLut)
311  {
312  return &theLut[idx*theNumberOfBands];
313  }
314 
315  return 0;
316  }

◆ operator[]() [5/6]

const LUT_ENTRY_TYPE* ossimNBandLutDataObject::operator[] ( double  normalizedIndex) const
inline

Definition at line 317 of file ossimNBandLutDataObject.h.

318  {
319  int idx = int(normalizedIndex*theNumberOfEntries);
320  if (idx < 0)
321  {
322  idx = 0;
323  }
324  return (*this)[idx];
325  }

◆ operator[]() [6/6]

LUT_ENTRY_TYPE* ossimNBandLutDataObject::operator[] ( double  normalizedIndex)
inline
Parameters
normalizedIndexIf a double precision value is passed in then it is assumed to be in normalized space where the value ranges from 0.0 to 1.0
Returns
the starting address of the band values.

Definition at line 332 of file ossimNBandLutDataObject.h.

333  {
334  ossim_uint32 idx = int(normalizedIndex*(theNumberOfEntries-1));
335  if (idx >= theNumberOfEntries)
336  {
337  idx = theNumberOfEntries-1;
338  }
339  return (*this)[idx];
340  }
unsigned int ossim_uint32

◆ saveState()

bool ossimNBandLutDataObject::saveState ( ossimKeywordlist kwl,
const char *  prefix = 0 
) const
virtual
Keywords:
entry0:
entry1:
:
entry<number_entries-1>:
null_value:  -1
number_bands:  3
number_entries:  216
scalar_type:  ossim_uint8
type:  ossimNBandLutDataObject
Where entry<idx> is repeasted for each entry number where idx start from 0 and goes to number_entries-1
each entry must have number_bands values.
Parameters
kwlThe keyword list to store the keywords to. Each keyword could be prefixed by an optional prefix parameter.
prefixThe optional prefix parameter used to prefix each keyword.

Reimplemented from ossimObject.

Definition at line 247 of file ossimNBandLutDataObject.cpp.

References ossimKeywordlist::add(), ossimString::c_str(), ossimKeywordNames::ENTRY_KW, ossimObject::getClassName(), ossimScalarTypeLut::instance(), ossimKeywordNames::NULL_VALUE_KW, ossimKeywordNames::NUMBER_BANDS_KW, ossimKeywordNames::NUMBER_ENTRIES_KW, ossimKeywordNames::SCALAR_TYPE_KW, theBandScalarType, theLut, theNullPixelIndex, theNumberOfBands, theNumberOfEntries, ossimString::toString(), and ossimKeywordNames::TYPE_KW.

Referenced by ossimInfo::getImagePalette(), and ossimNBandToIndexFilter::saveState().

248 {
249  kwl.add(prefix,
251  getClassName(),
252  true);
253  kwl.add(prefix,
256  true);
257  kwl.add(prefix,
260  true);
261  kwl.add(prefix,
264  true);
265  kwl.add(prefix,
268  true);
269 
271  for(ossim_uint32 idx = 0; idx < theNumberOfEntries; ++idx, lutPtr+=theNumberOfBands)
272  {
274  newPrefix += ossimString::toString(idx);
275  std::ostringstream ostr;
276  ossim_uint32 bandIdx = 0;
277  for(bandIdx = 0; bandIdx < theNumberOfBands; ++bandIdx)
278  {
279  ostr << lutPtr[bandIdx]
280  << " ";
281  }
282  kwl.add(prefix,
283  newPrefix,
284  ostr.str().c_str(),
285  true);
286  }
287 
288  return true;
289 }
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
static const char * NULL_VALUE_KW
static ossimString toString(bool aValue)
Numeric to string methods.
static const char * NUMBER_ENTRIES_KW
virtual ossimString getClassName() const
Definition: ossimObject.cpp:64
static const char * TYPE_KW
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
static ossimScalarTypeLut * instance()
Returns the static instance of an ossimScalarTypeLut object.
unsigned int ossim_uint32
static const char * NUMBER_BANDS_KW
static const char * ENTRY_KW
static const char * SCALAR_TYPE_KW

◆ setEntryLables()

void ossimNBandLutDataObject::setEntryLables ( ossim_uint32  band,
std::vector< ossimString entryLabels 
)

Definition at line 386 of file ossimNBandLutDataObject.cpp.

References m_entryLabels.

Referenced by ossimGdalTileSource::populateLut().

387 {
388  m_entryLabels[band] = entryLabels;
389 }
std::map< ossim_uint32, std::vector< ossimString > > m_entryLabels

◆ setNullPixelIndex()

void ossimNBandLutDataObject::setNullPixelIndex ( ossim_int32  idx)
inline

Allows you to specify which entry is to be designated as an invalid entry.

Note: setting this to -1 indicates no null entry is set.

Parameters
idxis the entry number that will be used for the null value

Definition at line 372 of file ossimNBandLutDataObject.h.

Referenced by ossimGdalTileSource::populateLut(), and ossimGdalTileSource::setPreservePaletteIndexesFlag().

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const ossimNBandLutDataObject lut 
)
friend

Definition at line 23 of file ossimNBandLutDataObject.cpp.

25 {
26  if(lut.theLut)
27  {
29  << lut.theNumberOfEntries << std::endl;
31  << lut.theNumberOfBands << std::endl;
32  out << "null_pixel_index: " << lut.theNullPixelIndex << std::endl;
33  for(ossim_uint32 idx = 0; idx < lut.theNumberOfEntries; ++idx)
34  {
35  const ossimNBandLutDataObject::LUT_ENTRY_TYPE *bandPtr =lut[idx];
36  ossim_uint32 bandIdx = 0;
37  out << ossimKeywordNames::ENTRY_KW << idx << ": ";
38  for(bandIdx = 0; bandIdx < lut.theNumberOfBands; ++bandIdx)
39  {
40  out << bandPtr[bandIdx] << " ";
41  }
42  if(idx < (lut.theNumberOfEntries-1))
43  {
44  out << std::endl;
45  }
46  }
47  }
48  return out;
49 }
static const char * NUMBER_ENTRIES_KW
unsigned int ossim_uint32
static const char * NUMBER_BANDS_KW
static const char * ENTRY_KW

Member Data Documentation

◆ m_entryLabels

std::map<ossim_uint32, std::vector<ossimString> > ossimNBandLutDataObject::m_entryLabels
protected

◆ theBandScalarType

ossimScalarType ossimNBandLutDataObject::theBandScalarType
protected

Definition at line 482 of file ossimNBandLutDataObject.h.

Referenced by loadState(), operator=(), operator==(), and saveState().

◆ theLut

LUT_ENTRY_TYPE* ossimNBandLutDataObject::theLut
protected

◆ theNullPixelIndex

ossim_int32 ossimNBandLutDataObject::theNullPixelIndex
protected

◆ theNumberOfBands

ossim_uint32 ossimNBandLutDataObject::theNumberOfBands
protected

◆ theNumberOfEntries

ossim_uint32 ossimNBandLutDataObject::theNumberOfEntries
protected

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