31 static const std::string REMAP_KW =
"remap";
32 static const std::string REMAP_TYPE_KW =
"remap_type";
34 static ossimTrace traceDebug(
"ossimPiecewiseRemapper:debug");
36 #ifdef OSSIM_ID_ENABLED 37 static const char OSSIM_ID[] =
"$Id$";
87 const std::string& prefix,
100 std::string keyBase =
"band";
110 while ( found < NUMBER_REMAPS )
113 std::string value = kwl.
findKey( prefix, key );
117 if ( initRemapSetFromString( value,
set ) )
119 m_remap.push_back(
set );
125 if ( index > (NUMBER_REMAPS+100) )
135 const std::string& prefix,
146 std::vector<ossimRemapSet>::const_iterator i = m_remap.begin();
147 while ( i != m_remap.end() )
149 std::string key =
"band";
155 getRemapSetString( remapType, (*i), value );
156 kwl.
addPair( prefix, key, value );
180 while ( !in.bad() && !in.eof() )
183 if ( c ==
'(' )
break;
187 while( !in.bad() && !in.eof() )
194 while( !in.bad() && !in.eof() )
205 if ( (c ==
'(') || (c ==
',') )
211 set.m_set.push_back(d);
220 if (
set.m_set.size() )
238 std::string& s )
const 248 std::string& s )
const 255 if (
set.m_set.size() )
261 os << std::setprecision(15)
267 <<
set.m_set[ setIdx ]
269 <<
set.m_set[ setIdx + 1 ]
271 <<
set.m_set[ setIdx + 2 ]
273 <<
set.m_set[ setIdx + 3 ]
275 if ( i < (TUPLES-1) )
299 <<
"ossimPiecewiseRemapper::ossimPiecewiseRemapper entered...\n";
300 #ifdef OSSIM_ID_ENABLED 302 <<
"OSSIM_ID: " << OSSIM_ID <<
"\n";
316 <<
"ossimPiecewiseRemapper::initialize entered..." << endl;
328 <<
"ossimPiecewiseRemapper::initialize exited..." << endl;
334 if ( (type ==
"linear_native") ||
335 (
ossimString(type).downcase() ==
"linear_native") )
393 static const char MODULE[] =
"ossimPiecewiseRemapper::loadState";
397 << MODULE <<
" Entered..." <<
"\nprefix: " << (prefix?prefix:
"null") << endl;
401 std::string p = ( prefix ? prefix :
"" );
408 if ( value ==
"ossimPiecewiseRemapper" )
425 value = kwl.
findKey( p, REMAP_TYPE_KW );
515 const char* prefix)
const 524 std::string p = ( prefix ? prefix :
"" );
532 kwl.
addPair( p, REMAP_TYPE_KW, value );
544 if ( (
m_min.size() == BANDS ) && (
m_max.size() == BANDS ) )
555 kwl.
add( p.c_str(), key.c_str(),
m_min[band] );
559 kwl.
add( p.c_str(), key.c_str(),
m_max[band] );
575 os << setiosflags(ios::fixed) << setprecision(15)
576 <<
"\nossimPiecewiseRemapper::print:\n" 603 result =
m_min[band];
613 result =
m_max[band];
631 m_min.resize( BANDS );
632 m_max.resize( BANDS );
761 <<
"ossimHistogramRemapper::buildLinearNativeTable OSSIM_SCALAR_UNKNOWN!" << endl;
776 T* table =
reinterpret_cast<T*
>(&
theTable.front());
780 bool isInteger = std::numeric_limits<T>::is_integer;
796 cout <<
"\ninput pix[" << bin <<
"]: " << p << endl;
800 std::vector<ossimRemapSet>::const_iterator i =
m_bandRemap[band].m_remap.begin();
811 if ( ( p >= (*i).m_set[
set*4] ) &&
812 ( p <= (*i).m_set[
set*4+1] ) )
818 p = (p - (*i).m_set[
set*4]) *
819 ((*i).m_set[
set*4+3]-(*i).m_set[
set*4+2]) /
820 ((*i).m_set[
set*4+1]-(*i).m_set[
set*4]) +
824 cout <<
"remapp_pix[" << bin <<
"][" <<
set <<
"]: " << p << endl;
836 p = ossim::round<ossim_float64>(p);
840 cout <<
"output_pix[" << bin <<
"]: " << p << endl;
844 table[bin] = (T)( ( p >= MIN_PIX ) ? ( ( p <= MAX_PIX ) ? p : MAX_PIX ) : MIN_PIX);
869 values_per_band = 256;
875 values_per_band = 2048;
880 values_per_band = 4096;
885 values_per_band = 8192;
890 values_per_band = 16384;
895 values_per_band = 32768;
902 values_per_band = 65536;
909 values_per_band = 65536;
932 ossim_uint32 size_in_bytes = values_per_band * BANDS * bytes_per_pixel;
16 bit unsigned integer (15 bits used)
void getLinearRemapSetString(const ossimPiecewiseRemapper::ossimRemapSet &set, std::string &s) const
Gets a string from remap set.
static const char * MIN_VALUE_KW
virtual ostream & print(ostream &os) const
Outputs theErrorStatus as an ossimErrorCode and an ossimString.
void buildLinearNativeTable()
Builds the linear native table.
RemapTableType theTableType
virtual double getMinPixelValue(ossim_uint32 band=0) const
ossim_uint32 numberOf(const char *str) const
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
vector< ossim_float64 > m_min
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
virtual double getMaxPixelValue(ossim_uint32 band=0) const
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &tile_rect, ossim_uint32 resLevel=0)
void setRemapType(const std::string &type)
Sets remap type.
Represents serializable keyword/value map.
void getRemapTypeString(ossimPiecewiseRemapper::PiecewiseRemapType remapType, std::string &s) const
Gets a string from remap type.
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
void getLinearRemapSetString(const ossimPiecewiseRemapper::ossimRemapSet &set, std::string &s) const
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
PiecewiseRemapType m_remapType
void initMinMax()
Computes min/max from remaps in m_bandRemap.
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
static const char * MAX_VALUE_KW
void buildTable()
Builds the table.
std::vector< ossim_uint8 > theTable
vector< ossim_float64 > m_max
static ossimString toString(bool aValue)
Numeric to string methods.
virtual void initialize()
Initialization method.
std::vector< ossim_float64 > m_set
virtual ostream & print(ostream &os) const
Print method.
void addPair(const std::string &key, const std::string &value, bool overwrite=true)
16 bit unsigned integer (14 bits used)
ossim_uint32 toUInt32() const
void saveState(ossimKeywordlist &kwl, const std::string &prefix, ossimPiecewiseRemapper::PiecewiseRemapType remapType, ossim_uint32 band) const
16 bit unsigned integer (13 bits used)
unsigned short ossim_uint16
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Saves the state to a keyword list.
bool initRemapSetFromString(const std::string &s, ossimPiecewiseRemapper::ossimRemapSet &set) const
Initializes set from string.
ossimPiecewiseRemapper()
default constructor
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Loads (recreates) the state of an object from a keyword list.
static const char * TYPE_KW
std::vector< ossimPiecewiseRemapper::ossimBandRemap > m_bandRemap
virtual ossimString getClassName() const
virtual void initialize()
virtual double getMinPixelValue(ossim_uint32 band=0) const
Returns the min pixel of the band.
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
OSSIM_DLL double defaultMin(ossimScalarType scalarType)
void getRemapSetString(ossimPiecewiseRemapper::PiecewiseRemapType remapType, const ossimPiecewiseRemapper::ossimRemapSet &set, std::string &s) const
Gets a string from remap set for type.
void loadState(const ossimKeywordlist &kwl, const std::string &prefix, ossim_uint32 band)
ossimPiecewiseRemapper & operator=(const ossimPiecewiseRemapper &hr)
(not allowed) assignment(operator=)
signed short ossim_sint16
const ossimBandRemap & operator=(const ossimBandRemap &rhs)
ossimImageSource * theInputConnection
unsigned int ossim_uint32
32 bit normalized floating point
std::vector< ossimRemapSet > m_remap
virtual ossimString getLongName() const
static const char * NUMBER_BANDS_KW
virtual void setEnableFlag(bool flag)
void setupTable()
Initialized base class (ossimTableRemapper) values:
const ossimRemapSet & operator=(const ossimRemapSet &rhs)
64 bit normalized floating point
16 bit unsigned integer (11 bits used)
ossim_uint32 theTableBandCount
virtual ~ossimPiecewiseRemapper()
Protected virtual destructor.
virtual double getMaxPixelValue(ossim_uint32 band=0) const
Returns the max pixel of the band.
ossimScalarType theOutputScalarType
bool m_dirty
Dirty flag to indicate table needs to be rebuilt.
ossim_uint32 theTableBinCount
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
#define RTTI_DEF1(cls, name, b1)
std::basic_istringstream< char > istringstream
Class for char input memory streams.
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &tileRect, ossim_uint32 resLevel=0)
Get tile method.
This class provides piecewise linear remapping of input pixels to output pixels.
virtual ossimString getShortName() const
unsigned char ossim_uint8
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)
std::basic_ostream< char > ostream
Base class for char output streams.
const std::string & string() const
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)
16 bit unsigned integer (12 bits used)