23 static const char* MODE_KW =
"mode";
24 static const char* LUT_FILE_KW =
"lut_file";
28 theMode(INTERPOLATED),
33 setDescription(
"Look-up-table remapper for band-independent remapping.");
47 if (!inputTile || !inputTile->
getBuf())
75 map<double, double>& bandMap =
theLut[band];
76 std::map<double, double>::const_iterator lut_entry;
80 index = inputTile->
getPix(pixel, band);
81 if (index == null_index)
87 lut_entry = bandMap.find(index);
88 if (lut_entry == bandMap.end())
91 value = lut_entry->second;
96 lut_entry = bandMap.find(index);
97 if (lut_entry != bandMap.end())
100 value = lut_entry->second;
104 lut_entry = bandMap.upper_bound(index);
105 if ((lut_entry == bandMap.end()) || (lut_entry == bandMap.begin()))
110 double index_hi = lut_entry->first;
111 double value_hi (lut_entry->second);
113 double index_lo = lut_entry->first;
114 double value_lo (lut_entry->second);
115 double w_lo = (index_hi - index)/(index_hi - index_lo);
116 double w_hi = 1.0 - w_lo;
117 value = value_hi*w_hi + value_lo*w_lo;
122 if (value < min_value)
124 if (value > max_value)
250 value =
"interpolated";
253 kwl.
add(prefix, MODE_KW, value.
c_str(),
true);
255 bool rtn_stat =
true;
258 int numBands =
theLut.size();
259 for (
int band=0; band<numBands; ++band)
263 base_keyword <<
"band" << band <<
".";
265 std::map<double, double>::const_iterator iter =
theLut[band].begin();
267 while (iter !=
theLut[band].end())
270 inKey << base_keyword.str() <<
"entry" << entry <<
".in";
271 outKey << base_keyword.str() <<
"entry" << entry <<
".out";
274 inVal << iter->first;
275 outVal << iter->second;
277 kwl.
add(prefix, inKey.str().c_str(), inVal.str().c_str());
278 kwl.
add(prefix, outKey.str().c_str(), outVal.str().c_str());
289 bool return_state =
true;
299 kwl.
add(prefix, lut_kwl,
false);
321 bool usingBandPrefix =
true;
327 usingBandPrefix =
false;
336 map<double,double> bandMap;
342 inKey <<
"band" << band <<
".entry" << entry <<
".in";
343 outKey <<
"band" << band <<
".entry" << entry <<
".out";
347 inKey <<
"entry" << entry <<
".in";
348 outKey <<
"entry" << entry <<
".out";
358 bandMap.insert(std::pair<double,double>(inVal.
toDouble(), outVal.
toDouble()));
365 theLut.push_back(bandMap);
368 if ((numBands == 1) || !usingBandPrefix)
380 if (!usingBandPrefix)
390 map<double,double> nullBandMap;
391 for (; band<numBands; ++band)
392 theLut.push_back(nullBandMap);
413 <<
"ossimScalarRemapper::setOutputScalarType WARN:\n" 414 <<
"OSSIM_SCALAR_UNKNOWN passed to method. No action taken..." 434 <<
"ossimScalarRemapper ERROR:" 435 <<
"\nUnknown scalar type: " << scalarType.
c_str() << std::endl;
16 bit unsigned integer (15 bits used)
void allocate()
Called on first getTile, will initialize all data needed.
virtual ossim_uint32 getWidth() const
virtual void initialize()
virtual void setDescription(const ossimString &description)
virtual ossim_uint32 getNumberOfInputBands() const
virtual ~ossimBandLutFilter()
ossim_uint32 numberOf(const char *str) const
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
virtual void setImageRectangle(const ossimIrect &rect)
virtual const ossim_uint16 * getUshortBuf() const
virtual const ossim_uint8 * getUcharBuf() const
Represents serializable keyword/value map.
bool addFile(const char *file)
#define OSSIM_DEFAULT_MAX_PIX_DOUBLE
const char * find(const char *key) const
bool contains(char aChar) const
ossimScalarType theOutputScalarType
virtual ossimDataObjectStatus getDataObjectStatus() const
virtual ossim_uint32 getHeight() const
16 bit unsigned integer (14 bits used)
16 bit unsigned integer (13 bits used)
virtual ossim_float64 getPix(const ossimIpt &position, ossim_uint32 band=0) const
Will return the pixel at location position.
virtual const ossim_sint16 * getSshortBuf() const
void setLut(const ossimFilename &file)
This opens the keyword list and initializes lut.
virtual void initialize()
Initialize the data buffer.
virtual void initialize()
virtual ossim_int32 getEntryNumber(const char *entry_string, bool case_insensitive=true) const
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
static ossimScalarTypeLut * instance()
Returns the static instance of an ossimScalarTypeLut object.
static ossimImageDataFactory * instance()
#define OSSIM_DEFAULT_MIN_PIX_DOUBLE
virtual ossimDataObjectStatus validate() const
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=NULL) const
Method to save the state of an object to a keyword list.
ossimImageSource * theInputConnection
unsigned int ossim_uint32
virtual const ossim_float64 * getNullPix() const
32 bit normalized floating point
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
ossimRefPtr< ossimImageData > theTile
virtual ossimRefPtr< ossimImageData > create(ossimSource *owner, ossimScalarType scalar, ossim_uint32 bands=1) const
virtual const ossim_float32 * getFloatBuf() const
std::vector< std::map< double, double > > theLut
virtual void makeBlank()
Initializes data to null pixel values.
virtual void setOutputScalarType(ossimScalarType scalarType)
Sets the output scalar type.
16 bit unsigned integer (11 bits used)
virtual void setMaxPix(ossim_float64 max_pix)
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
virtual const void * getBuf() const
RTTI_DEF1(ossimBandLutFilter, "ossimBandLutFilter", ossimImageSourceFilter)
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string's contents...
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &origin, ossim_uint32 resLevel=0)
virtual void initialize()=0
bool initializeLut(const ossimKeywordlist &kwl, const char *prefix=0)
virtual void setMinPix(ossim_float64 min_pix)
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=NULL)
Method to the load (recreate) the state of an object from a keyword list.
virtual double getNullPixelValue(ossim_uint32 band=0) const
Each band has a null pixel associated with it.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)
16 bit unsigned integer (12 bits used)
virtual const ossim_float64 * getDoubleBuf() const