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

This class provides piecewise linear remapping of input pixels to output pixels. More...

#include <ossimPiecewiseRemapper.h>

Inheritance diagram for ossimPiecewiseRemapper:
ossimTableRemapper ossimImageSourceFilter ossimImageSource ossimConnectableObjectListener ossimSource ossimListener ossimConnectableObject ossimErrorStatusInterface ossimObject ossimListenerManager ossimPropertyInterface ossimReferenced

Classes

class  ossimBandRemap
 Private container class. More...
 
class  ossimRemapSet
 Private container class. More...
 

Public Types

enum  PiecewiseRemapType { UNKNOWN = 0, LINEAR_NATIVE = 1 }
 
- Public Types inherited from ossimTableRemapper
enum  RemapTableType { UKNOWN = 0, NATIVE = 1, MIN_MAX = 2, NORMALIZED = 3 }
 
- Public Types inherited from ossimConnectableObject
enum  ossimConnectableObjectDirectionType { CONNECTABLE_DIRECTION_NONE = 0, CONNECTABLE_DIRECTION_INPUT = 1, CONNECTABLE_DIRECTION_OUTPUT = 2 }
 
typedef std::vector< ossimRefPtr< ossimConnectableObject > > ConnectableObjectList
 

Public Member Functions

 ossimPiecewiseRemapper ()
 default constructor More...
 
virtual ossimString getClassName () const
 
virtual ossimString getLongName () const
 
virtual ossimString getShortName () const
 
virtual ossimRefPtr< ossimImageDatagetTile (const ossimIrect &tileRect, ossim_uint32 resLevel=0)
 Get tile method. More...
 
virtual void initialize ()
 Initialization method. More...
 
void setRemapType (const std::string &type)
 Sets remap type. More...
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 Saves the state to a keyword list. More...
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 Loads (recreates) the state of an object from a keyword list. More...
 
virtual ostream & print (ostream &os) const
 Print method. More...
 
virtual double getMinPixelValue (ossim_uint32 band=0) const
 
virtual double getMaxPixelValue (ossim_uint32 band=0) const
 
- Public Member Functions inherited from ossimTableRemapper
 ossimTableRemapper ()
 default constructor More...
 
virtual ossimScalarType getOutputScalarType () const
 This will be used to query the output pixel type of the tile source. More...
 
- Public Member Functions inherited from ossimImageSourceFilter
 ossimImageSourceFilter (ossimObject *owner=NULL)
 
 ossimImageSourceFilter (ossimImageSource *inputSource)
 
 ossimImageSourceFilter (ossimObject *owner, ossimImageSource *inputSource)
 
virtual void getOutputBandList (std::vector< ossim_uint32 > &bandList) const
 
virtual ossim_uint32 getNumberOfInputBands () const
 
bool canConnectMyInputTo (ossim_int32 inputIndex, const ossimConnectableObject *object) const
 required to be overriden by derived classes More...
 
virtual void connectInputEvent (ossimConnectionEvent &event)
 
virtual void disconnectInputEvent (ossimConnectionEvent &event)
 
virtual void propertyEvent (ossimPropertyEvent &event)
 
virtual void refreshEvent (ossimRefreshEvent &event)
 
virtual void setProperty (ossimRefPtr< ossimProperty > property)
 
virtual ossimRefPtr< ossimPropertygetProperty (const ossimString &name) const
 
virtual void getPropertyNames (std::vector< ossimString > &propertyNames) const
 
- Public Member Functions inherited from ossimImageSource
 ossimImageSource (ossimObject *owner=0)
 
 ossimImageSource (ossimObject *owner, ossim_uint32 inputListSize, ossim_uint32 outputListSize, bool inputListIsFixedFlag=true, bool outputListIsFixedFlag=true)
 
virtual ~ossimImageSource ()
 
virtual ossimRefPtr< ossimImageDatagetTile (const ossimIpt &origin, ossim_uint32 resLevel=0)
 
virtual bool getTile (ossimImageData *result, ossim_uint32 resLevel=0)
 Method to get a tile. More...
 
virtual ossimObjectgetObject ()
 For RTTI support. More...
 
virtual const ossimObjectgetObject () const
 For RTTI support. More...
 
virtual void getDecimationFactor (ossim_uint32 resLevel, ossimDpt &result) const
 Will return the decimation factor for the given resolution level. More...
 
virtual void getDecimationFactors (std::vector< ossimDpt > &decimations) const
 Will return an array of all decimations for each resolution level. More...
 
virtual ossim_uint32 getNumberOfDecimationLevels () const
 Will return the number of resolution levels. More...
 
virtual ossim_uint32 getNumberOfOutputBands () const
 Returns the number of bands in a tile returned from this TileSource. More...
 
virtual ossim_uint32 getTileWidth () const
 Returns the default processing tile width. More...
 
virtual ossim_uint32 getTileHeight () const
 Returns the default processing tile height. More...
 
virtual double getNullPixelValue (ossim_uint32 band=0) const
 Each band has a null pixel associated with it. More...
 
virtual ossimIrect getBoundingRect (ossim_uint32 resLevel=0) const
 This will return the bounding rect of the source. More...
 
virtual void getBoundingRect (ossimIrect &rect, ossim_uint32 resLevel=0) const
 Gets the bounding rectangle of the source. More...
 
virtual void getValidImageVertices (std::vector< ossimIpt > &validVertices, ossimVertexOrdering ordering=OSSIM_CLOCKWISE_ORDER, ossim_uint32 resLevel=0) const
 ordering specifies how the vertices should be arranged. More...
 
virtual ossimRefPtr< ossimImageGeometrygetImageGeometry ()
 Returns the image geometry object associated with this tile source or NULL if not defined. More...
 
virtual void setImageGeometry (const ossimImageGeometry *geom)
 Default implementation sets geometry of the first input to the geometry specified. More...
 
virtual void saveImageGeometry () const
 Default method to call input's saveImageGeometry. More...
 
virtual void saveImageGeometry (const ossimFilename &geometry_file) const
 Default method to call input's saveImageGeometry. More...
 
virtual bool isIndexedData () const
 
- Public Member Functions inherited from ossimSource
 ossimSource (ossimObject *owner=0)
 
 ossimSource (ossimObject *owner, ossim_uint32 inputListSize, ossim_uint32 outputListSize, bool inputListIsFixedFlag=true, bool outputListIsFixedFlag=true)
 
virtual ~ossimSource ()
 
virtual bool isSourceEnabled () const
 
virtual void enableSource ()
 
virtual void disableSource ()
 
virtual bool getEnableFlag () const
 
virtual void setEnableFlag (bool flag)
 
virtual bool isInitialized () const
 
virtual void setInitializedFlag (bool flag)
 
- Public Member Functions inherited from ossimConnectableObject
 ossimConnectableObject (ossimObject *owner=0)
 Base constructor of this object. More...
 
 ossimConnectableObject (ossimObject *owner, ossim_int32 inputListSize, ossim_int32 outputListSize, bool inputListIsFixedFlag=true, bool outputListIsFixedFlag=true)
 
virtual ~ossimConnectableObject ()
 
void setId (const ossimId &id)
 All connectable objects will have id's. More...
 
const ossimIdgetId () const
 Will allow us to get this object's id. More...
 
const ossimObjectgetOwner () const
 Fetches the current owner, most likely a container but not limited to one. More...
 
virtual void changeOwner (ossimObject *owner)
 Permits changing the object's owner. More...
 
virtual void setDescription (const ossimString &description)
 
virtual ossimString getDescription () const
 
virtual bool isConnected (ossimConnectableObjectDirectionType direction=CONNECTABLE_DIRECTION_INPUT) const
 will check the direction specified to see if all slots are full. More...
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findConnectableObject(const ossimId &id))
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findObjectOfType(RTTItypeid typeId, ossimConnectableObjectDirectionType directionType, bool recurse=true))
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findObjectOfType(const ossimString &obj, ossimConnectableObjectDirectionType directionType, bool recurse=true))
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findInputObjectOfType(const ossimString &className))
 
virtual ossim_int32 findInputIndex (const ossimConnectableObject *object)
 Return a valid index of the input list if the passed in object is found else return -1. More...
 
virtual ossim_int32 findInputIndex (const ossimId &id)
 Return a valid index of the input list if the passed id is found else return -1. More...
 
virtual ossim_int32 findOutputIndex (const ossimConnectableObject *object)
 Return a valid index of the output list if the passed in object is found else return -1. More...
 
virtual ossim_int32 findOutputIndex (const ossimId &id)
 Return a valid index of the output list if the passed in object is found else return -1. More...
 
virtual ossim_int32 getMyInputIndexToConnectTo (ossimConnectableObject *object) const
 Should return the first available index to connect to. More...
 
virtual ossim_int32 getMyOutputIndexToConnectTo (ossimConnectableObject *object) const
 Should return the first available index to connect to. More...
 
virtual bool canConnectMyOutputTo (ossim_int32 myOutputIndex, const ossimConnectableObject *object) const
 default implementation is to allow anyone to connect to us. More...
 
virtual void disconnect (ossimConnectableObject *object=0)
 Will disconnect the object passed in. More...
 
virtual void disconnect (const ossimId &id)
 Will disconnect the object passed in. More...
 
virtual ossimRefPtr< ossimConnectableObjectdisconnectMyInput (ossim_int32 inputIndex, bool disconnectOutputFlag=true, bool createEventFlag=true)
 Will disconnect the object at the given input index and generate a connection event. More...
 
virtual void disconnectMyInput (ossimConnectableObject *input, bool disconnectOutputFlag=true, bool createEventFlag=true)
 Finds the index of the passed in input and calls disconnectMyInput(inputIndex, disconnectOutputFlag, createEventFlag);. More...
 
virtual void disconnectMyInputs (ConnectableObjectList &inputList, bool disconnectOutputFlag=true, bool createEventFlag=true)
 
virtual ossimRefPtr< ossimConnectableObjectdisconnectMyOutput (ossim_int32 outputIndex, bool disconnectInputFlag=true, bool createEventFlag=true)
 Will disconnect the object at the given output index and generate a connection event. More...
 
virtual void disconnectMyOutput (ossimConnectableObject *output, bool disconnectInputFlag=true, bool createEventFlag=true)
 Will disconnect the output object. More...
 
virtual void disconnectMyOutputs (ConnectableObjectList &outputList, bool disconnectOutputFlag=true, bool createEventFlag=true)
 
virtual void disconnectAllInputs ()
 Will disconnect all of the input objects. More...
 
virtual void disconnectAllOutputs ()
 Will disconnect all of the output objects. More...
 
virtual ossim_int32 connectMyInputTo (ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
 Will try to connect this objects input to the passed in object. More...
 
virtual ossim_int32 connectMyInputTo (ossim_int32 inputIndex, ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
 Will connect the specified input to the passed in object. More...
 
virtual bool connectMyInputTo (ConnectableObjectList &inputList, bool makeOutputConnection=true, bool createEventFlag=true)
 
virtual ossim_int32 connectMyOutputTo (ossimConnectableObject *outputObject, bool makeInputConnection=true, bool createEventFlag=true)
 Will try to connect this objects output to the passed in object. More...
 
virtual bool connectMyOutputTo (ConnectableObjectList &outputList, bool makeInputConnection=true, bool createEventFlag=true)
 
virtual bool connectInputList (ConnectableObjectList &inputList)
 Will disconnect itself from all inputs and reset to the passed in input list. More...
 
virtual bool connectOutputList (ConnectableObjectList &outputList)
 Will disconnect itself from all outputs and reset to the passed in output list. More...
 
virtual ossim_uint32 getNumberOfInputs () const
 Returns the number of input objects. More...
 
virtual ossim_uint32 getNumberOfOutputs () const
 Return the number of output objects. More...
 
ossimConnectableObjectgetInput (ossim_uint32 index=0)
 returns the object at the specified index. More...
 
const ossimConnectableObjectgetInput (ossim_uint32 index=0) const
 returns the object at the specified index. More...
 
ossimConnectableObjectgetOutput (ossim_uint32 index=0)
 returns the object at the specified index. More...
 
const ossimConnectableObjectgetOutput (ossim_uint32 index=0) const
 returns the object at the specified index. More...
 
virtual void setNumberOfInputs (ossim_int32 numberOfInputs)
 Will set the number of inputs. More...
 
virtual bool getInputListIsFixedFlag () const
 
virtual bool getOutputListIsFixedFlag () const
 
virtual void setNumberOfOutputs (ossim_int32 numberOfInputs)
 Will set the number of outputs. More...
 
const ConnectableObjectListgetInputList () const
 
const ConnectableObjectListgetOutputList () const
 
ConnectableObjectListgetInputList ()
 
ConnectableObjectListgetOutputList ()
 
 OSSIM_DEPRECATE_METHOD (virtual void findAllObjectsOfType(ConnectableObjectList &result, const RTTItypeid &typeInfo, bool recurse=true))
 
 OSSIM_DEPRECATE_METHOD (virtual void findAllObjectsOfType(ConnectableObjectList &result, const ossimString &className, bool recurse=true))
 
virtual void propagateEventToOutputs (ossimEvent &event)
 
virtual void propagateEventToInputs (ossimEvent &event)
 
virtual void setProperty (const ossimString &name, const ossimString &value)
 
virtual ossim_uint32 saveStateOfAllInputs (ossimKeywordlist &kwl, bool saveThisStateFlag=true, ossim_uint32 objectIndex=1, const char *prefix=0) const
 Save the state of all inputs to a keyword list. More...
 
virtual bool fillContainer (ossimConnectableContainer &container)
 Inserts this object and all of its children and inputs into the container provided. More...
 
bool moveInputUp (const ossimId &id)
 Moves the input connection matching id up one in the connection list. More...
 
bool moveInputDown (const ossimId &id)
 Moves the input connection matching id down one in the connection list. More...
 
bool moveInputToTop (const ossimId &id)
 Moves the input connection matching id to the top of the connection list. More...
 
bool moveInputToBottom (const ossimId &id)
 Moves the input connection matching id to the bottom of the connection list. More...
 
virtual void accept (ossimVisitor &visitor)
 We will add a visitor interface for all connectable objects. More...
 
- Public Member Functions inherited from ossimObject
 ossimObject ()
 
virtual ~ossimObject ()
 
virtual ossimObjectdup () 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 bool isEqualTo (const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
 
- 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
 
- Public Member Functions inherited from ossimListenerManager
 ossimListenerManager ()
 
virtual ~ossimListenerManager ()
 
virtual void fireEvent (ossimEvent &event)
 
virtual bool addListener (ossimListener *listener)
 
virtual bool removeListener (ossimListener *listener)
 
virtual bool findListener (ossimListener *listener)
 
- Public Member Functions inherited from ossimPropertyInterface
 ossimPropertyInterface ()
 
virtual ~ossimPropertyInterface ()
 
virtual ossimString getPropertyValueAsString (const ossimString &name) const
 
void getPropertyList (std::vector< ossimRefPtr< ossimProperty > > &propertyList) const
 
void setProperties (std::vector< ossimRefPtr< ossimProperty > > &propertyList)
 
- Public Member Functions inherited from ossimErrorStatusInterface
 ossimErrorStatusInterface ()
 
virtual ~ossimErrorStatusInterface ()
 
virtual ossimErrorCode getErrorStatus () const
 
virtual ossimString getErrorStatusString () const
 
virtual void setErrorStatus (ossimErrorCode error_status) const
 
virtual void setErrorStatus () const
 
virtual void clearErrorStatus () const
 
bool hasError () const
 
- Public Member Functions inherited from ossimConnectableObjectListener
 ossimConnectableObjectListener ()
 
virtual ~ossimConnectableObjectListener ()
 
virtual void processEvent (ossimEvent &event)
 ProcessEvent. More...
 
virtual void objectDestructingEvent (ossimObjectDestructingEvent &)
 
virtual void connectionEvent (ossimConnectionEvent &)
 
virtual void disconnectOutputEvent (ossimConnectionEvent &)
 
virtual void connectOutputEvent (ossimConnectionEvent &)
 
virtual void addObjectEvent (ossimContainerEvent &)
 
virtual void removeObjectEvent (ossimContainerEvent &)
 
virtual void containerEvent (ossimContainerEvent &)
 
- Public Member Functions inherited from ossimListener
 ossimListener ()
 
virtual ~ossimListener ()
 
void enableListener ()
 
void disableListener ()
 
void setListenerEnableFlag (bool flag)
 
bool isListenerEnabled () const
 
bool getListenerEnableFlag () const
 

Protected Member Functions

virtual ~ossimPiecewiseRemapper ()
 Protected virtual destructor. More...
 
- Protected Member Functions inherited from ossimTableRemapper
virtual ~ossimTableRemapper ()
 virtual destructor More...
 
void allocate (const ossimIrect &rect)
 
void destroy ()
 
void remapFromNativeTable (ossimRefPtr< ossimImageData > &inputTile)
 
template<class T >
void remapFromNativeTable (T dummy, ossimRefPtr< ossimImageData > &inputTile)
 
void remapFromNormalizedTable (ossimRefPtr< ossimImageData > &inputTile)
 
template<class T >
void dumpTable (T dummy, ostream &os) const
 
 ossimTableRemapper (const ossimTableRemapper &tr)
 
ossimTableRemapperoperator= (const ossimTableRemapper &tr)
 
- Protected Member Functions inherited from ossimImageSourceFilter
virtual ~ossimImageSourceFilter ()
 
- Protected Member Functions inherited from ossimImageSource
 ossimImageSource (const ossimImageSource &rhs)
 
const ossimImageSourceoperator= (const ossimImageSource &)
 
- Protected Member Functions inherited from ossimSource
 ossimSource (const ossimSource &rhs)
 
const ossimSourceoperator= (const ossimSource &rhs)
 
- Protected Member Functions inherited from ossimConnectableObject
ossimConnectableObjectfindObjectOfType (ConnectableObjectList *connectableList, ossimVisitor &visitor)
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 
- Protected Member Functions inherited from ossimListenerManager
 ossimListenerManager (const ossimListenerManager &rhs)
 

Private Member Functions

void getRemapTypeString (ossimPiecewiseRemapper::PiecewiseRemapType remapType, std::string &s) const
 Gets a string from remap type. More...
 
void getLinearRemapSetString (const ossimPiecewiseRemapper::ossimRemapSet &set, std::string &s) const
 Gets a string from remap set. More...
 
void buildTable ()
 Builds the table. More...
 
void buildLinearNativeTable ()
 Builds the linear native table. More...
 
template<class T >
void buildLinearNativeTable (T dummy)
 Builds the linear native table for scalar type T. More...
 
void setupTable ()
 Initialized base class (ossimTableRemapper) values: More...
 
void initMinMax ()
 Computes min/max from remaps in m_bandRemap. More...
 
 ossimPiecewiseRemapper (const ossimPiecewiseRemapper &obj)
 (not allowed) copy constructor. More...
 
ossimPiecewiseRemapperoperator= (const ossimPiecewiseRemapper &hr)
 (not allowed) assignment(operator=) More...
 

Private Attributes

bool m_dirty
 Dirty flag to indicate table needs to be rebuilt. More...
 
PiecewiseRemapType m_remapType
 
std::vector< ossimPiecewiseRemapper::ossimBandRemapm_bandRemap
 
vector< ossim_float64m_min
 
vector< ossim_float64m_max
 

Additional Inherited Members

- Protected Attributes inherited from ossimTableRemapper
ossimRefPtr< ossimImageDatatheTile
 
ossimRefPtr< ossimImageDatatheTmpTile
 
std::vector< ossim_uint8theTable
 
ossim_float64theNormBuf
 
ossim_uint32 theTableBinCount
 
ossim_uint32 theTableBandCount
 
RemapTableType theTableType
 
ossimScalarType theInputScalarType
 
ossimScalarType theOutputScalarType
 
- Protected Attributes inherited from ossimImageSourceFilter
ossimImageSourcetheInputConnection
 
- Protected Attributes inherited from ossimSource
bool theEnableFlag
 
bool theInitializedFlag
 
- Protected Attributes inherited from ossimConnectableObject
ossimId theId
 
ossimString theDescription
 
ossimObjecttheOwner
 
bool theInputListIsFixedFlag
 Indicates whether the theInputObjectList is fixed. More...
 
bool theOutputListIsFixedFlag
 Indicates whether the theOutputObjectList is fixed. More...
 
ConnectableObjectList theInputObjectList
 Holds a list of input objects. More...
 
ConnectableObjectList theOutputObjectList
 Holds a list of output objects. More...
 
- Protected Attributes inherited from ossimListenerManager
std::list< ossimListener * > theListenerList
 
bool theEnabledFlag
 
std::list< ossimListener * > theDelayedAdd
 
std::list< ossimListener * > theDelayedRemove
 
bool theFireEventFlag
 
- Protected Attributes inherited from ossimErrorStatusInterface
ossimErrorCode theErrorStatus
 
- Protected Attributes inherited from ossimListener
bool theListenerEnableFlag
 

Detailed Description

This class provides piecewise linear remapping of input pixels to output pixels.

The object's state is represented as:

band0.remap0: ( <segment0>, <segment1>, ...) band0.remap1: ( <segment0>, ... )

The vertices of each linear segment are specified as four numbers in parentheses:

(<min_in>, <max_in>, <min_out>, <max_out>)

A linear function is computed to map min_in to min_out and likewise max_in to max_out, with all intermediate points distributed linearly between the two extremes. Multiple remaps are cascaded: if an input pixel's value falls outside the ranges defined in the first remapper, then the second remapper's table is referenced. The cascading continues until a value is found. If no lookup is available, the output pixel is assigned to the NULL value.

Example: Given object2 with a state of:

object2.type: ossimPiecewiseRemapper object2.remap_type: linear_native object2.band0.remap0: ( (0, 127, 0, 127), (128, 255, 128, 382) ) object2.band0.remap1: ( (0, 382, 0, 255) )

remap0 applied:
The input range 0 <-> 127 passes through with a one-to-one mapping. 128 <-> 255 is stretched out to 128 <-> 382.

remap0 output is fed to remap1: 0 maps to 0 and 382 maps to 255 (compression).

Notes:

1) Currently there is only one remap type (linear_native) is supported so it's not needed but left in the code for future type remaps, e.g. a remap where there is a linear and a logarithmic section.

2) Any number of "remaps" are allowed.

Definition at line 63 of file ossimPiecewiseRemapper.h.

Member Enumeration Documentation

◆ PiecewiseRemapType

Enumerator
UNKNOWN 
LINEAR_NATIVE 

Definition at line 67 of file ossimPiecewiseRemapper.h.

Constructor & Destructor Documentation

◆ ossimPiecewiseRemapper() [1/2]

ossimPiecewiseRemapper::ossimPiecewiseRemapper ( )

default constructor

Definition at line 287 of file ossimPiecewiseRemapper.cpp.

288  :
289  ossimTableRemapper(), // base class
290  m_dirty(false),
292  m_bandRemap(0),
293  m_min(0),
294  m_max(0)
295 {
296  if (traceDebug())
297  {
299  << "ossimPiecewiseRemapper::ossimPiecewiseRemapper entered...\n";
300 #ifdef OSSIM_ID_ENABLED
302  << "OSSIM_ID: " << OSSIM_ID << "\n";
303 #endif
304  }
305 }
vector< ossim_float64 > m_min
PiecewiseRemapType m_remapType
vector< ossim_float64 > m_max
std::vector< ossimPiecewiseRemapper::ossimBandRemap > m_bandRemap
ossimTableRemapper()
default constructor
bool m_dirty
Dirty flag to indicate table needs to be rebuilt.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ ~ossimPiecewiseRemapper()

ossimPiecewiseRemapper::~ossimPiecewiseRemapper ( )
protectedvirtual

Protected virtual destructor.

This class is derived from ossimReferenced; hence, will auto destruct provided it is wrapped/stored in an ossimRefPtr. Example usage:

ossimRefPtr<ossimPiecewiseRemapper> pwr = new ossimPiecewiseRemapper();

Definition at line 307 of file ossimPiecewiseRemapper.cpp.

308 {
309 }

◆ ossimPiecewiseRemapper() [2/2]

ossimPiecewiseRemapper::ossimPiecewiseRemapper ( const ossimPiecewiseRemapper obj)
private

(not allowed) copy constructor.

Definition at line 939 of file ossimPiecewiseRemapper.cpp.

940 : m_dirty(true),
942 {
943 }
PiecewiseRemapType m_remapType
bool m_dirty
Dirty flag to indicate table needs to be rebuilt.

Member Function Documentation

◆ buildLinearNativeTable() [1/2]

void ossimPiecewiseRemapper::buildLinearNativeTable ( )
private

Builds the linear native table.

Definition at line 720 of file ossimPiecewiseRemapper.cpp.

References ossimTableRemapper::getOutputScalarType(), OSSIM_SCALAR_UNKNOWN, OSSIM_SINT16, OSSIM_SINT32, OSSIM_UINT16, OSSIM_UINT32, OSSIM_UINT8, OSSIM_USHORT11, OSSIM_USHORT12, OSSIM_USHORT13, OSSIM_USHORT14, and OSSIM_USHORT15.

Referenced by buildTable().

721 {
722  switch ( getOutputScalarType() )
723  {
724  case OSSIM_UINT8:
725  {
727  break;
728  }
729  case OSSIM_USHORT11:
730  case OSSIM_USHORT12:
731  case OSSIM_USHORT13:
732  case OSSIM_USHORT14:
733  case OSSIM_USHORT15:
734  case OSSIM_UINT16:
735  {
737  break;
738  }
739  case OSSIM_SINT16:
740  {
742  break;
743  }
744  case OSSIM_UINT32:
745  {
747  break;
748  }
749  case OSSIM_SINT32:
750  {
752  break;
753  }
755  default:
756  {
757  if(traceDebug())
758  {
759  // Shouldn't hit this.
761  << "ossimHistogramRemapper::buildLinearNativeTable OSSIM_SCALAR_UNKNOWN!" << endl;
762  }
763  break;
764  }
765 
766  } // End of "switch (theTableType)"
767 
768 } // End: void ossimPiecewiseRemapper::buildLinearNativeTable()
16 bit unsigned integer (15 bits used)
void buildLinearNativeTable()
Builds the linear native table.
16 bit unsigned integer
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
16 bit signed integer
16 bit unsigned integer (14 bits used)
16 bit unsigned integer (13 bits used)
unsigned short ossim_uint16
32 bit unsigned integer
signed short ossim_sint16
32 bit signed integer
unsigned int ossim_uint32
signed int ossim_sint32
16 bit unsigned integer (11 bits used)
8 bit unsigned integer
unsigned char ossim_uint8
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
16 bit unsigned integer (12 bits used)

◆ buildLinearNativeTable() [2/2]

template<class T >
void ossimPiecewiseRemapper::buildLinearNativeTable ( dummy)
private

Builds the linear native table for scalar type T.

Definition at line 770 of file ossimPiecewiseRemapper.cpp.

References getMaxPixelValue(), getMinPixelValue(), ossimImageSource::getNullPixelValue(), ossimImageSource::getNumberOfOutputBands(), m_bandRemap, ossimTableRemapper::print(), ossimTableRemapper::theTable, and ossimTableRemapper::theTableBinCount.

771 {
772  const ossim_uint32 BANDS = getNumberOfOutputBands();
773 
774  if ( BANDS && (m_bandRemap.size() == BANDS) && theTable.size() )
775  {
776  T* table = reinterpret_cast<T*>(&theTable.front());
777 
778  ossim_uint32 index = 0;
779 
780  bool isInteger = std::numeric_limits<T>::is_integer; // Flag to round or not.
781 
782  // Band loop:
783  for(ossim_uint32 band = 0; band < BANDS; ++band)
784  {
785  // First bin is always for null.
786  table[index++] = (T)getNullPixelValue(band);
787 
788  const ossim_float64 MIN_PIX = getMinPixelValue(band);
789  const ossim_float64 MAX_PIX = getMaxPixelValue(band);
790 
791  for( ossim_uint32 bin = 1; bin < theTableBinCount; ++bin )
792  {
793  ossim_float64 p = MIN_PIX + bin - 1;
794 
795 #if 0 /* Please keep for debug. (drb) */
796  cout << "\ninput pix[" << bin << "]: " << p << endl;
797 #endif
798 
799  // Loop through remaps:
800  std::vector<ossimRemapSet>::const_iterator i = m_bandRemap[band].m_remap.begin();
801  while ( i != m_bandRemap[band].m_remap.end() )
802  {
803  //---
804  // Each remap set holds a group of tuples for the band.
805  // Tuple format example: <min_in> <max_in> <min_out> <max_out>
806  //---
807  const ossim_uint32 TUPLES = (*i).m_set.size() / 4;
808  for ( ossim_uint32 set = 0; set < TUPLES; ++set )
809  {
810  // Range check it:
811  if ( ( p >= (*i).m_set[set*4] ) && // input min
812  ( p <= (*i).m_set[set*4+1] ) ) // input max
813  {
814  //---
815  // p = (p - output_min) * (output_max-output_min)/(input_max-input_min)
816  // + output_min;
817  //---
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]) +
821  (*i).m_set[set*4];
822 
823 #if 0 /* Please keep for debug. (drb) */
824  cout << "remapp_pix[" << bin << "][" << set << "]: " << p << endl;
825 #endif
826  }
827 
828  } // End: TUPLE loop
829 
830  ++i; // Next remap.
831 
832  } // End: remap loop:
833 
834  if ( isInteger )
835  {
836  p = ossim::round<ossim_float64>(p); // Round to integer correctly.
837  }
838 
839 #if 0 /* Please keep for debug. (drb) */
840  cout << "output_pix[" << bin << "]: " << p << endl;
841 #endif
842 
843  // Assign to table with min/max clip:
844  table[bin] = (T)( ( p >= MIN_PIX ) ? ( ( p <= MAX_PIX ) ? p : MAX_PIX ) : MIN_PIX);
845 
846  } // End: bin loop
847 
848  } // End: band loop
849 
850  } // Matches: if ( theTable.size() )
851 
852 #if 0 /* Please leave for debug. (drb) */
854 #endif
855 
856 } // End: template <class T> void ossimPiecewiseRemapper::buildLinearNativeTable(T dummy)
virtual ostream & print(ostream &os) const
Outputs theErrorStatus as an ossimErrorCode and an ossimString.
virtual double getMinPixelValue(ossim_uint32 band=0) const
virtual double getMaxPixelValue(ossim_uint32 band=0) const
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
std::vector< ossim_uint8 > theTable
std::vector< ossimPiecewiseRemapper::ossimBandRemap > m_bandRemap
double ossim_float64
unsigned int ossim_uint32
ossim_uint32 theTableBinCount
virtual double getNullPixelValue(ossim_uint32 band=0) const
Each band has a null pixel associated with it.

◆ buildTable()

void ossimPiecewiseRemapper::buildTable ( )
private

Builds the table.

Definition at line 693 of file ossimPiecewiseRemapper.cpp.

References buildLinearNativeTable(), ossimImageSource::getNumberOfOutputBands(), LINEAR_NATIVE, m_bandRemap, m_dirty, m_remapType, setupTable(), and ossimTableRemapper::theTable.

Referenced by getTile().

694 {
695  const ossim_uint32 BANDS = getNumberOfOutputBands();
696  if ( BANDS && (m_bandRemap.size() == BANDS) &&
698  {
699  setupTable();
700 
701  if ( theTable.size() )
702  {
704  {
706  }
707  }
708  }
709  else
710  {
711  // No remaps:
712  theTable.clear();
713  }
714 
715  // Clear the dirty flag.
716  m_dirty = false;
717 
718 } // End: ossimPiecewiseRemapper::buildTable()
void buildLinearNativeTable()
Builds the linear native table.
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
PiecewiseRemapType m_remapType
std::vector< ossim_uint8 > theTable
std::vector< ossimPiecewiseRemapper::ossimBandRemap > m_bandRemap
unsigned int ossim_uint32
void setupTable()
Initialized base class (ossimTableRemapper) values:
bool m_dirty
Dirty flag to indicate table needs to be rebuilt.

◆ getClassName()

ossimString ossimPiecewiseRemapper::getClassName ( ) const
virtual
Returns
"ossimPiecewiseRemapper"

Reimplemented from ossimObject.

Definition at line 583 of file ossimPiecewiseRemapper.cpp.

584 {
585  return ossimString("ossimPiecewiseRemapper");
586 }

◆ getLinearRemapSetString()

void ossimPiecewiseRemapper::getLinearRemapSetString ( const ossimPiecewiseRemapper::ossimRemapSet set,
std::string &  s 
) const
private

Gets a string from remap set.

Example output: ((0, 127, 0, 127), (128, 255, 128, 382))

Parameters
set
sInitialized by this.

Referenced by ossimPiecewiseRemapper::ossimBandRemap::getRemapSetString().

◆ getLongName()

ossimString ossimPiecewiseRemapper::getLongName ( ) const
virtual
Returns
"OSSIM Piecewise Remapper"

Reimplemented from ossimObject.

Definition at line 588 of file ossimPiecewiseRemapper.cpp.

589 {
590  return ossimString("OSSIM Piecewise Remapper");
591 }

◆ getMaxPixelValue()

ossim_float64 ossimPiecewiseRemapper::getMaxPixelValue ( ossim_uint32  band = 0) const
virtual
Returns
The max pixel of the band.

Reimplemented from ossimImageSource.

Definition at line 608 of file ossimPiecewiseRemapper.cpp.

References ossimImageSource::getMaxPixelValue(), m_max, and ossimSource::theEnableFlag.

Referenced by buildLinearNativeTable().

609 {
611  if ( theEnableFlag && (band < m_max.size()) )
612  {
613  result = m_max[band];
614  }
615  return result;
616 }
bool theEnableFlag
Definition: ossimSource.h:62
vector< ossim_float64 > m_max
double ossim_float64
virtual double getMaxPixelValue(ossim_uint32 band=0) const
Returns the max pixel of the band.

◆ getMinPixelValue()

double ossimPiecewiseRemapper::getMinPixelValue ( ossim_uint32  band = 0) const
virtual
Returns
The min pixel of the band.

Reimplemented from ossimImageSource.

Definition at line 598 of file ossimPiecewiseRemapper.cpp.

References ossimImageSource::getMinPixelValue(), m_min, and ossimSource::theEnableFlag.

Referenced by buildLinearNativeTable().

599 {
601  if ( theEnableFlag && (band < m_min.size()) )
602  {
603  result = m_min[band];
604  }
605  return result;
606 }
vector< ossim_float64 > m_min
bool theEnableFlag
Definition: ossimSource.h:62
virtual double getMinPixelValue(ossim_uint32 band=0) const
Returns the min pixel of the band.
double ossim_float64

◆ getRemapTypeString()

void ossimPiecewiseRemapper::getRemapTypeString ( ossimPiecewiseRemapper::PiecewiseRemapType  remapType,
std::string &  s 
) const
private

Gets a string from remap type.

Parameters
remapType
sInitialized by this.

Definition at line 377 of file ossimPiecewiseRemapper.cpp.

References LINEAR_NATIVE.

Referenced by saveState().

379 {
380  if ( remapType == ossimPiecewiseRemapper::LINEAR_NATIVE )
381  {
382  s = "linear_native";
383  }
384  else
385  {
386  s = "unknown";
387  }
388 }

◆ getShortName()

ossimString ossimPiecewiseRemapper::getShortName ( ) const
virtual
Returns
"Piecewise Remapper"

Reimplemented from ossimObject.

Definition at line 593 of file ossimPiecewiseRemapper.cpp.

594 {
595  return ossimString("Piecewise Remapper");
596 }

◆ getTile()

ossimRefPtr< ossimImageData > ossimPiecewiseRemapper::getTile ( const ossimIrect tileRect,
ossim_uint32  resLevel = 0 
)
virtual

Get tile method.

Parameters
tileRectRegion of interest.
resLevelResolution level.
Therequested region of interest for resolution level.

Reimplemented from ossimTableRemapper.

Definition at line 345 of file ossimPiecewiseRemapper.cpp.

References buildTable(), ossimImageSource::getTile(), ossimTableRemapper::getTile(), m_dirty, ossimSource::theEnableFlag, ossimImageSourceFilter::theInputConnection, and ossimTableRemapper::theTable.

348 {
349  ossimRefPtr<ossimImageData> result = 0;
350 
351  if ( theInputConnection )
352  {
353  if ( m_dirty )
354  {
355  // Rebuild the table if dirty flag set:
356  buildTable();
357  }
358 
359  if ( theEnableFlag && theTable.size() )
360  {
361  //---
362  // Not bypassed and has a table...
363  // Base handles the rest...
364  //---
365  result = ossimTableRemapper::getTile(tileRect, resLevel);
366  }
367  else
368  {
369  // Fetch tile from pointer from the input source.
370  result = theInputConnection->getTile(tileRect, resLevel);
371  }
372  }
373 
374  return result;
375 }
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &tile_rect, ossim_uint32 resLevel=0)
bool theEnableFlag
Definition: ossimSource.h:62
void buildTable()
Builds the table.
std::vector< ossim_uint8 > theTable
ossimImageSource * theInputConnection
bool m_dirty
Dirty flag to indicate table needs to be rebuilt.
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)

◆ initialize()

void ossimPiecewiseRemapper::initialize ( )
virtual

Initialization method.

Called on state change of chain.

Reimplemented from ossimTableRemapper.

Definition at line 311 of file ossimPiecewiseRemapper.cpp.

312 {
313  if (traceDebug())
314  {
316  << "ossimPiecewiseRemapper::initialize entered..." << endl;
317  }
318 
319  //---
320  // Call the base class initialize.
321  // Note: This will reset "theInputConnection" if it changed...
322  //---
324 
325  if (traceDebug())
326  {
328  << "ossimPiecewiseRemapper::initialize exited..." << endl;
329  }
330 }
virtual void initialize()
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ initMinMax()

void ossimPiecewiseRemapper::initMinMax ( )
private

Computes min/max from remaps in m_bandRemap.

Definition at line 618 of file ossimPiecewiseRemapper.cpp.

References ossim::defaultMin(), ossimImageSource::getNumberOfOutputBands(), LINEAR_NATIVE, m_bandRemap, m_max, m_min, m_remapType, and OSSIM_SCALAR_UNKNOWN.

619 {
620 #if 0
622  {
623  //---
624  // Each remap set holds a group of tuples for the band.
625  // Tuple format example: <min_in> <max_in> <min_out> <max_out>
626  //---
627  const ossim_uint32 BANDS = getNumberOfOutputBands();
628 
629  if ( m_bandRemap.size() == BANDS )
630  {
631  m_min.resize( BANDS );
632  m_max.resize( BANDS );
633 
634  // First time through:
635  for( ossim_uint32 band = 0; band < BANDS; ++band )
636  {
637  const ossim_uint32 TUPLES = m_bandRemap[band].m_set.size() / 4;
638  for ( ossim_uint32 tuple = 0; tuple < TUPLES; ++tuple )
639  {
640  //---
641  // Min: get min of "min_out" from sets.
642  // Max: get max of "max_out" from sets.
643  //---
644  if ( tuple == 0 )
645  {
646  m_min[band] = m_bandRemap[band].m_set[tuple*4+2];
647  m_max[band] = m_bandRemap[band].m_set[tuple*4+3];
648  }
649  else
650  {
651  if ( m_bandRemap[band].m_set[tuple*4+2] < m_min[band] )
652  {
653  m_min[band] = m_bandRemap[band].m_set[tuple*4+2];
654  }
655  if ( m_bandRemap[band].m_set[tuple*4+3] > m_max[band] )
656  {
657  m_max[band] = m_bandRemap[band].m_set[tuple*4+3];
658  }
659  }
660  }
661 
662  //---
663  // Clamp min to scalar min as this is used for getMinPixelValue.
664  // This will keep a remap of:
665  // ((0, 127, 0, 127), (128, 255, 128, 382))
666  // From having a min and null of 0...
667  //---
668  if ( m_outputScalarType != OSSIM_SCALAR_UNKNOWN )
669  {
670  if ( m_min[band] < ossim::defaultMin( m_outputScalarType ) )
671  {
672  m_min[band] = ossim::defaultMin( m_outputScalarType );
673  }
674  }
675 
676  } // End: band loop...
677  }
678  }
679  else
680  {
681  m_min.clear();
682  m_max.clear();
683  }
684 #endif
685 
686  // Disabled for now (drb)
687  m_min.clear();
688  m_max.clear();
689 
690 
691 } // End: ossimPiecewiseRemapper::initMinMax()
vector< ossim_float64 > m_min
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
PiecewiseRemapType m_remapType
vector< ossim_float64 > m_max
std::vector< ossimPiecewiseRemapper::ossimBandRemap > m_bandRemap
OSSIM_DLL double defaultMin(ossimScalarType scalarType)
Definition: ossimCommon.cpp:73
unsigned int ossim_uint32

◆ loadState()

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

Loads (recreates) the state of an object from a keyword list.

Returns
true if ok or false on error.

Reimplemented from ossimTableRemapper.

Definition at line 390 of file ossimPiecewiseRemapper.cpp.

392 {
393  static const char MODULE[] = "ossimPiecewiseRemapper::loadState";
394  if (traceDebug())
395  {
397  << MODULE << " Entered..." << "\nprefix: " << (prefix?prefix:"null") << endl;
398  }
399 
400  bool status = false;
401  std::string p = ( prefix ? prefix : "" );
402 
403  // Check type first before going on:
404  std::string key = ossimKeywordNames::TYPE_KW;
405  std::string value;
406  value = kwl.findKey( p, key );
407 
408  if ( value == "ossimPiecewiseRemapper" )
409  {
410  // Load the base class states...
411  status = ossimTableRemapper::loadState(kwl, prefix);
412 
413  if (status)
414  {
415  // Look for scalar type keyword.
416  // ossim_int32 st = ossimScalarTypeLut::instance()->getEntryNumber(kwl, p.c_str(), true);
417 
418  // Lookup table returns -1 if not found so check return...
419  // if ( (st != -1) && (st != OSSIM_SCALAR_UNKNOWN) )
420  // {
421  // m_outputScalarType = static_cast<ossimScalarType>(st);
422  //}
423 
424  // Remap type "remap_type":
425  value = kwl.findKey( p, REMAP_TYPE_KW );
426  if ( value.size() )
427  {
428  setRemapType( value );
429 
431  {
432  // Get the number of bands "number_bands":
433  ossim_uint32 bands = 0;
435  value = kwl.findKey( p, key );
436  if ( value.size() )
437  {
438  bands = ossimString(value).toUInt32();
439  }
440 
441  if ( bands )
442  {
443  // Start with clean remap set:
444  m_bandRemap.clear();
445  m_bandRemap.resize( bands );
446 
447  m_min.clear();
448  m_max.clear();
449 
450  // Loop through bands:
451  for ( ossim_uint32 band = 0; band < bands; ++band )
452  {
453  // Band remap:
454  m_bandRemap[band].loadState( kwl, p, band );
455 
456  // Min:
457  std::string keyBase = ossimKeywordNames::MIN_VALUE_KW;
458  keyBase += ".band";
459  key = keyBase + ossimString::toString(band).string();
460  value = kwl.findKey( p, key );
461  if ( value.size() )
462  {
463  m_min.push_back( ossimString(value).toFloat64() );
464  }
465 
466  // Max:
468  keyBase += ".band";
469  key = keyBase + ossimString::toString(band).string();
470  value = kwl.findKey( p, key );
471  if ( value.size() )
472  {
473  m_max.push_back( ossimString(value).toFloat64() );
474  }
475 
476  } // End: Band loop
477 
478  if ( m_bandRemap.size() && ( !m_min.size() || !m_max.size() ) )
479  {
480  initMinMax(); // Initialize from the m_reampSet tuples.
481  }
482  }
483  }
484  }
485 
486  if ( m_bandRemap.size() )
487  {
488  m_dirty = true;
489  }
490 
491  } // Matches: status = ossimTableRemapper::loadState(kwl, prefix); if (status){...
492  else
493  {
494  // Sets base: ossimSource::theEnableFlag
495  setEnableFlag(false);
496  }
497 
498 
499  // Tmp drb:
500  // initMinMax();
501 
502  } // Matches: if ( value == "ossimPiecewiseRemapper" )
503 
504  if (traceDebug())
505  {
506  ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " DEBUG:\n";
508  ossimNotify(ossimNotifyLevel_DEBUG) << "\nExited..." << endl;
509  }
510  return status;
511 
512 } // End: ossimPiecewiseRemapper::loadState
static const char * MIN_VALUE_KW
vector< ossim_float64 > m_min
void setRemapType(const std::string &type)
Sets remap type.
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
PiecewiseRemapType m_remapType
void initMinMax()
Computes min/max from remaps in m_bandRemap.
static const char * MAX_VALUE_KW
vector< ossim_float64 > m_max
static ossimString toString(bool aValue)
Numeric to string methods.
virtual ostream & print(ostream &os) const
Print method.
ossim_uint32 toUInt32() const
static const char * TYPE_KW
std::vector< ossimPiecewiseRemapper::ossimBandRemap > m_bandRemap
unsigned int ossim_uint32
static const char * NUMBER_BANDS_KW
virtual void setEnableFlag(bool flag)
Definition: ossimSource.cpp:99
return status
bool m_dirty
Dirty flag to indicate table needs to be rebuilt.
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
const std::string & string() const
Definition: ossimString.h:414

◆ operator=()

ossimPiecewiseRemapper & ossimPiecewiseRemapper::operator= ( const ossimPiecewiseRemapper hr)
private

(not allowed) assignment(operator=)

Definition at line 946 of file ossimPiecewiseRemapper.cpp.

947 {
948  return *this;
949 }

◆ print()

ostream & ossimPiecewiseRemapper::print ( ostream &  os) const
virtual

Print method.

Called by ossimObject::operator<<.

Reimplemented from ossimTableRemapper.

Definition at line 570 of file ossimPiecewiseRemapper.cpp.

References saveState().

571 {
572  ossimKeywordlist kwl;
573  saveState( kwl, 0 );
574 
575  os << setiosflags(ios::fixed) << setprecision(15)
576  << "\nossimPiecewiseRemapper::print:\n"
577  << kwl
578  << "\n";
579 
580  return os;
581 }
Represents serializable keyword/value map.
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Saves the state to a keyword list.

◆ saveState()

bool ossimPiecewiseRemapper::saveState ( ossimKeywordlist kwl,
const char *  prefix = 0 
) const
virtual

Saves the state to a keyword list.

Returns
true if ok or false on error.

Reimplemented from ossimTableRemapper.

Definition at line 514 of file ossimPiecewiseRemapper.cpp.

References ossimKeywordlist::addPair(), ossimImageSource::getNumberOfOutputBands(), getRemapTypeString(), m_bandRemap, m_remapType, ossimKeywordNames::NUMBER_BANDS_KW, ossimString::string(), ossimString::toString(), and UNKNOWN.

Referenced by print().

516 {
517  bool result = false;
518 
519  const ossim_uint32 BANDS = getNumberOfOutputBands();
520 
522  ( m_bandRemap.size() == BANDS ) )
523  {
524  std::string p = ( prefix ? prefix : "" );
525 
526  // Bands:
527  std::string value = ossimString::toString(BANDS).string();
528  kwl.addPair( p, std::string(ossimKeywordNames::NUMBER_BANDS_KW), value );
529 
530  // Remap type:
532  kwl.addPair( p, REMAP_TYPE_KW, value );
533 
534  // Save the band remaps.
535  if ( m_bandRemap.size() == BANDS )
536  {
537  for ( ossim_uint32 band = 0; band < BANDS; ++band )
538  {
539  m_bandRemap[band].saveState( kwl, p, m_remapType, band );
540  }
541  }
542 
543  // Min/max values:
544  if ( ( m_min.size() == BANDS ) && ( m_max.size() == BANDS ) )
545  {
546  std::string minBase = ossimKeywordNames::MIN_VALUE_KW;
547  minBase += ".band";
548  std::string maxBase = ossimKeywordNames::MAX_VALUE_KW;
549  maxBase += ".band";
550 
551  for ( ossim_uint32 band = 0; band < BANDS; ++band )
552  {
553  // Min:
554  std::string key = minBase + ossimString::toString(band).string();
555  kwl.add( p.c_str(), key.c_str(), m_min[band] );
556 
557  // Max:
558  key = maxBase + ossimString::toString(band).string();
559  kwl.add( p.c_str(), key.c_str(), m_max[band] );
560  }
561  }
562 
563  // Base class:
564  result = ossimTableRemapper::saveState(kwl, prefix);
565  }
566 
567  return result;
568 }
static const char * MIN_VALUE_KW
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.
void getRemapTypeString(ossimPiecewiseRemapper::PiecewiseRemapType remapType, std::string &s) const
Gets a string from remap type.
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
PiecewiseRemapType m_remapType
static const char * MAX_VALUE_KW
vector< ossim_float64 > m_max
static ossimString toString(bool aValue)
Numeric to string methods.
void addPair(const std::string &key, const std::string &value, bool overwrite=true)
std::vector< ossimPiecewiseRemapper::ossimBandRemap > m_bandRemap
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
unsigned int ossim_uint32
static const char * NUMBER_BANDS_KW
const std::string & string() const
Definition: ossimString.h:414

◆ setRemapType()

void ossimPiecewiseRemapper::setRemapType ( const std::string &  type)

Sets remap type.

Current types: "linear_native"

Parameters
type

Definition at line 332 of file ossimPiecewiseRemapper.cpp.

References LINEAR_NATIVE, m_remapType, and UNKNOWN.

333 {
334  if ( (type == "linear_native") ||
335  (ossimString(type).downcase() == "linear_native") )
336  {
338  }
339  else
340  {
342  }
343 }
PiecewiseRemapType m_remapType

◆ setupTable()

void ossimPiecewiseRemapper::setupTable ( )
private

Initialized base class (ossimTableRemapper) values:

  • theTableBinCount
  • theTableBandCount
  • theTableType
  • theTable (resizes if not correct size.

Definition at line 858 of file ossimPiecewiseRemapper.cpp.

References ossimImageSource::getNumberOfOutputBands(), ossimTableRemapper::NATIVE, ossimTableRemapper::NORMALIZED, OSSIM_DOUBLE, OSSIM_FLOAT, OSSIM_NORMALIZED_DOUBLE, OSSIM_NORMALIZED_FLOAT, OSSIM_SINT16, OSSIM_SINT32, OSSIM_UINT16, OSSIM_UINT32, OSSIM_UINT8, OSSIM_USHORT11, OSSIM_USHORT12, OSSIM_USHORT13, OSSIM_USHORT14, OSSIM_USHORT15, ossimTableRemapper::theOutputScalarType, ossimTableRemapper::theTable, ossimTableRemapper::theTableBandCount, ossimTableRemapper::theTableBinCount, and ossimTableRemapper::theTableType.

Referenced by buildTable().

859 {
860  const ossim_uint32 BANDS = getNumberOfOutputBands();
861  if ( BANDS )
862  {
863  ossim_uint32 values_per_band = 0;
864  ossim_uint32 bytes_per_pixel = 0;
865 
866  switch (theOutputScalarType)
867  {
868  case OSSIM_UINT8:
869  values_per_band = 256; // 2 ^ 8
870  bytes_per_pixel = 1;
872  break;
873 
874  case OSSIM_USHORT11:
875  values_per_band = 2048; // 2 ^ 11
876  bytes_per_pixel = 2;
878  break;
879  case OSSIM_USHORT12:
880  values_per_band = 4096; // 2 ^ 12
881  bytes_per_pixel = 2;
883  break;
884  case OSSIM_USHORT13:
885  values_per_band = 8192; // 2 ^ 13
886  bytes_per_pixel = 2;
888  break;
889  case OSSIM_USHORT14:
890  values_per_band = 16384; // 2 ^ 14
891  bytes_per_pixel = 2;
893  break;
894  case OSSIM_USHORT15:
895  values_per_band = 32768; // 2 ^ 15
896  bytes_per_pixel = 2;
898  break;
899 
900  case OSSIM_UINT16:
901  case OSSIM_SINT16:
902  values_per_band = 65536; // 2 ^ 16
903  bytes_per_pixel = 2;
905  break;
906 
907  case OSSIM_UINT32:
908  case OSSIM_SINT32:
909  values_per_band = 65536; // 2 ^ 16
910  bytes_per_pixel = 4;
912  break;
913 
915  case OSSIM_FLOAT:
916  bytes_per_pixel = 4;
917  break;
918 
920  case OSSIM_DOUBLE:
921  bytes_per_pixel = 8;
923  break;
924 
925  default:
926  break;
927  }
928 
929  theTableBinCount = values_per_band;
930  theTableBandCount = BANDS;
931 
932  ossim_uint32 size_in_bytes = values_per_band * BANDS * bytes_per_pixel;
933  theTable.resize(size_in_bytes);
934  }
935 
936 } // End: ossimPiecwiseRemapper::getTableSize()
16 bit unsigned integer (15 bits used)
RemapTableType theTableType
16 bit unsigned integer
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
std::vector< ossim_uint8 > theTable
16 bit signed integer
16 bit unsigned integer (14 bits used)
16 bit unsigned integer (13 bits used)
32 bit unsigned integer
32 bit signed integer
unsigned int ossim_uint32
32 bit normalized floating point
64 bit normalized floating point
16 bit unsigned integer (11 bits used)
ossim_uint32 theTableBandCount
ossimScalarType theOutputScalarType
ossim_uint32 theTableBinCount
8 bit unsigned integer
32 bit floating point
64 bit floating point
16 bit unsigned integer (12 bits used)

Member Data Documentation

◆ m_bandRemap

std::vector<ossimPiecewiseRemapper::ossimBandRemap> ossimPiecewiseRemapper::m_bandRemap
private

◆ m_dirty

bool ossimPiecewiseRemapper::m_dirty
private

Dirty flag to indicate table needs to be rebuilt.

Definition at line 256 of file ossimPiecewiseRemapper.h.

Referenced by buildTable(), and getTile().

◆ m_max

vector<ossim_float64> ossimPiecewiseRemapper::m_max
private

Definition at line 266 of file ossimPiecewiseRemapper.h.

Referenced by getMaxPixelValue(), and initMinMax().

◆ m_min

vector<ossim_float64> ossimPiecewiseRemapper::m_min
private

Definition at line 265 of file ossimPiecewiseRemapper.h.

Referenced by getMinPixelValue(), and initMinMax().

◆ m_remapType

PiecewiseRemapType ossimPiecewiseRemapper::m_remapType
private

Definition at line 258 of file ossimPiecewiseRemapper.h.

Referenced by buildTable(), initMinMax(), saveState(), and setRemapType().


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