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

#include <ossimBandLutFilter.h>

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

Public Types

enum  Mode { UNKNOWN =0, LITERAL = 1, INTERPOLATED = 2 }
 
- 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

 ossimBandLutFilter ()
 
virtual ossimRefPtr< ossimImageDatagetTile (const ossimIrect &origin, ossim_uint32 resLevel=0)
 
void setMode (Mode mode)
 
Mode getMode () const
 
virtual ossimScalarType getOutputScalarType () const
 This will be used to query the output pixel type of the tile source. More...
 
virtual void setOutputScalarType (ossimScalarType scalarType)
 Sets the output scalar type. More...
 
virtual void setOutputScalarType (ossimString scalarType)
 
void setLut (const ossimFilename &file)
 This opens the keyword list and initializes lut. More...
 
virtual void initialize ()
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=NULL) const
 Method to save the state of an object to a keyword list. More...
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=NULL)
 Method to the load (recreate) the state of an object from a keyword list. 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 double getMinPixelValue (ossim_uint32 band=0) const
 Returns the min pixel of the band. More...
 
virtual double getMaxPixelValue (ossim_uint32 band=0) const
 Returns the max pixel of the band. 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)
 
virtual std::ostream & print (std::ostream &out) const
 Outputs theErrorStatus as an ossimErrorCode and an ossimString. More...
 
- 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 ossimString getShortName () const
 
virtual ossimString getLongName () 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 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 ~ossimBandLutFilter ()
 
void allocate ()
 Called on first getTile, will initialize all data needed. More...
 
bool initializeLut (const ossimKeywordlist &kwl, const char *prefix=0)
 
- 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)
 

Protected Attributes

std::vector< std::map< double, double > > theLut
 
Mode theMode
 
ossimRefPtr< ossimImageDatatheTile
 
ossimFilename theLutFile
 
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

Definition at line 100 of file ossimBandLutFilter.h.

Member Enumeration Documentation

◆ Mode

Enumerator
UNKNOWN 
LITERAL 
INTERPOLATED 

Definition at line 103 of file ossimBandLutFilter.h.

Constructor & Destructor Documentation

◆ ossimBandLutFilter()

ossimBandLutFilter::ossimBandLutFilter ( )

Definition at line 26 of file ossimBandLutFilter.cpp.

References ossimConnectableObject::setDescription().

29  theTile(0),
30  theLutFile(""),
32 {
33  setDescription("Look-up-table remapper for band-independent remapping.");
34 }
virtual void setDescription(const ossimString &description)
ossimImageSourceFilter(ossimObject *owner=NULL)
ossimScalarType theOutputScalarType
ossimRefPtr< ossimImageData > theTile
ossimFilename theLutFile

◆ ~ossimBandLutFilter()

ossimBandLutFilter::~ossimBandLutFilter ( )
protectedvirtual

Definition at line 36 of file ossimBandLutFilter.cpp.

37 {
38 }

Member Function Documentation

◆ allocate()

void ossimBandLutFilter::allocate ( )
protected

Called on first getTile, will initialize all data needed.

Definition at line 169 of file ossimBandLutFilter.cpp.

References ossimImageDataFactory::create(), ossimImageSourceFilter::getNumberOfInputBands(), ossimImageData::initialize(), ossimImageDataFactory::instance(), OSSIM_NORMALIZED_FLOAT, OSSIM_SSHORT16, OSSIM_UCHAR, OSSIM_USHORT11, OSSIM_USHORT12, OSSIM_USHORT13, OSSIM_USHORT14, OSSIM_USHORT15, OSSIM_USHORT16, ossimImageData::setMaxPix(), ossimImageData::setMinPix(), ossimImageSourceFilter::theInputConnection, theOutputScalarType, theTile, and ossimRefPtr< T >::valid().

Referenced by getTile(), and setOutputScalarType().

170 {
171  if(!theInputConnection)
172  return;
173 
175  if(!theTile.valid())
176  return;
177 
178  switch(theOutputScalarType)
179  {
180  case OSSIM_SSHORT16:
181  theTile->setMinPix(-32768);
182  theTile->setMaxPix(32767);
183  break;
185  theTile->setMinPix(0.0);
186  theTile->setMaxPix(1.0);
187  break;
188  case OSSIM_UCHAR:
189  theTile->setMinPix(0);
190  theTile->setMaxPix(255);
191  break;
192  case OSSIM_USHORT16:
193  theTile->setMinPix(0);
194  theTile->setMaxPix(65535);
195  break;
196  case OSSIM_USHORT11:
197  theTile->setMinPix(0);
198  theTile->setMaxPix(2047);
199  break;
200  case OSSIM_USHORT12:
201  theTile->setMinPix(0);
202  theTile->setMaxPix(4095);
203  break;
204  case OSSIM_USHORT13:
205  theTile->setMinPix(0);
206  theTile->setMaxPix(8191);
207  break;
208  case OSSIM_USHORT14:
209  theTile->setMinPix(0);
210  theTile->setMaxPix(16383);
211  break;
212  case OSSIM_USHORT15:
213  theTile->setMinPix(0);
214  theTile->setMaxPix(32767);
215  break;
216  default:
217  break;
218  }
219 
220  theTile->initialize();
221 }
16 bit unsigned integer (15 bits used)
virtual ossim_uint32 getNumberOfInputBands() const
bool valid() const
Definition: ossimRefPtr.h:75
ossimScalarType theOutputScalarType
16 bit unsigned integer (14 bits used)
16 bit unsigned integer (13 bits used)
virtual void initialize()
Initialize the data buffer.
static ossimImageDataFactory * instance()
ossimImageSource * theInputConnection
32 bit normalized floating point
ossimRefPtr< ossimImageData > theTile
virtual ossimRefPtr< ossimImageData > create(ossimSource *owner, ossimScalarType scalar, ossim_uint32 bands=1) const
16 bit unsigned integer (11 bits used)
virtual void setMaxPix(ossim_float64 max_pix)
virtual void setMinPix(ossim_float64 min_pix)
16 bit unsigned iteger
16 bit signed integer
8 bit unsigned iteger
16 bit unsigned integer (12 bits used)

◆ getMode()

Mode ossimBandLutFilter::getMode ( ) const
inline

Definition at line 111 of file ossimBandLutFilter.h.

111 { return theMode; }

◆ getOutputScalarType()

virtual ossimScalarType ossimBandLutFilter::getOutputScalarType ( ) const
inlinevirtual

This will be used to query the output pixel type of the tile source.

Please ignore the argument. It will soon be removed.

Reimplemented from ossimImageSource.

Definition at line 113 of file ossimBandLutFilter.h.

113 { return theOutputScalarType; }
ossimScalarType theOutputScalarType

◆ getTile()

ossimRefPtr< ossimImageData > ossimBandLutFilter::getTile ( const ossimIrect rect,
ossim_uint32  resLevel = 0 
)
virtual
Returns
the requested region of interest

Reimplemented from ossimImageSource.

Definition at line 40 of file ossimBandLutFilter.cpp.

References allocate(), ossimImageData::getBuf(), ossimDataObject::getDataObjectStatus(), ossimImageData::getDoubleBuf(), ossimImageData::getFloatBuf(), ossimImageData::getHeight(), ossimImageData::getNullPix(), ossimImageSource::getNullPixelValue(), ossimImageSourceFilter::getNumberOfInputBands(), ossimImageData::getPix(), ossimImageData::getSshortBuf(), ossimImageSource::getTile(), ossimImageData::getUcharBuf(), ossimImageData::getUshortBuf(), ossimImageData::getWidth(), LITERAL, ossimImageData::makeBlank(), OSSIM_DEFAULT_MAX_PIX_DOUBLE, OSSIM_DEFAULT_MIN_PIX_DOUBLE, OSSIM_DOUBLE, OSSIM_EMPTY, OSSIM_FLOAT, OSSIM_NORMALIZED_FLOAT, OSSIM_SSHORT16, OSSIM_UCHAR, OSSIM_USHORT11, OSSIM_USHORT12, OSSIM_USHORT13, OSSIM_USHORT14, OSSIM_USHORT15, OSSIM_USHORT16, ossimImageData::setImageRectangle(), ossimImageData::setMaxPix(), ossimImageData::setMinPix(), ossimImageSourceFilter::theInputConnection, theLut, theMode, theOutputScalarType, theTile, and ossimImageData::validate().

42 {
43  if(!theInputConnection || (theLut.size() == 0))
44  return 0;
45 
46  ossimRefPtr<ossimImageData> inputTile = theInputConnection->getTile(tileRect, resLevel);
47  if (!inputTile || !inputTile->getBuf())
48  return 0;
49 
50  if(!theTile)
51  {
52  allocate();
53  if (!theTile)
54  return 0;
55  }
56 
57  theTile->setImageRectangle(tileRect);
58  theTile->makeBlank();
59 
60  // Quick handling special case of empty input tile:
61  if (inputTile->getDataObjectStatus() == OSSIM_EMPTY)
62  return theTile;
63 
64  const double null_index = theInputConnection->getNullPixelValue();
65  const double null_value = theTile->getNullPix(0); // assuming same null for all bands
66  ossim_uint32 maxLength = inputTile->getWidth()*inputTile->getHeight();
67 
68  double index, value;
69  double min_value=OSSIM_DEFAULT_MAX_PIX_DOUBLE;
70  double max_value=OSSIM_DEFAULT_MIN_PIX_DOUBLE;
71 
73  for (ossim_uint32 band = 0; band < numBands; ++band)
74  {
75  map<double, double>& bandMap = theLut[band];
76  std::map<double, double>::const_iterator lut_entry;
77  for (ossim_uint32 pixel=0; pixel<maxLength; ++pixel)
78  {
79  // Do not remap null pixels, leave the output pixel "blank" which is null-pixel value:
80  index = inputTile->getPix(pixel, band);
81  if (index == null_index)
82  continue;
83 
84  // Now perform look-up depending on mode:
85  if (theMode == LITERAL)
86  {
87  lut_entry = bandMap.find(index);
88  if (lut_entry == bandMap.end())
89  value = null_value;
90  else
91  value = lut_entry->second;
92  }
93  else
94  {
95  // Interpolated mode performs interpolation here between the line segments vertices:
96  lut_entry = bandMap.find(index);
97  if (lut_entry != bandMap.end())
98  {
99  // Got exact match, no interpolation needed:
100  value = lut_entry->second;
101  }
102  else
103  {
104  lut_entry = bandMap.upper_bound(index);
105  if ((lut_entry == bandMap.end()) || (lut_entry == bandMap.begin()))
106  value = null_value;
107  else
108  {
109  // Need to linearly interpolate:
110  double index_hi = lut_entry->first;
111  double value_hi (lut_entry->second);
112  --lut_entry;
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;
118  }
119  }
120  }
121 
122  if (value < min_value)
123  min_value = value;
124  if (value > max_value)
125  max_value = value;
126 
127  // Assign this output pixel according to desired scalar type:
128  switch(theOutputScalarType)
129  {
130  case OSSIM_DOUBLE:
131  theTile->getDoubleBuf(band)[pixel] = value;
132  theTile->setMinPix(min_value);
133  theTile->setMaxPix(max_value);
134  break;
135  case OSSIM_SSHORT16:
136  theTile->getSshortBuf(band)[pixel] = value;
137  break;
138  case OSSIM_FLOAT:
139  theTile->setMinPix(min_value);
140  theTile->setMaxPix(max_value);
141  theTile->getFloatBuf(band)[pixel] = value;
142  break;
144  theTile->getFloatBuf(band)[pixel] = value;
145  break;
146  case OSSIM_UCHAR:
147  theTile->getUcharBuf(band)[pixel] = value;
148  break;
149  case OSSIM_USHORT16:
150  theTile->getUshortBuf(band)[pixel] = value;
151  break;
152  case OSSIM_USHORT11:
153  case OSSIM_USHORT12:
154  case OSSIM_USHORT13:
155  case OSSIM_USHORT14:
156  case OSSIM_USHORT15:
157  theTile->getUshortBuf(band)[pixel] = value;
158  break;
159  default:
160  break;
161  }
162  } // end loop over band's pixels
163  } // end loop over tile's bands
164 
165  theTile->validate();
166  return theTile;
167 }
16 bit unsigned integer (15 bits used)
void allocate()
Called on first getTile, will initialize all data needed.
virtual ossim_uint32 getWidth() const
virtual ossim_uint32 getNumberOfInputBands() const
virtual void setImageRectangle(const ossimIrect &rect)
virtual const ossim_uint16 * getUshortBuf() const
virtual const ossim_uint8 * getUcharBuf() const
#define OSSIM_DEFAULT_MAX_PIX_DOUBLE
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
#define OSSIM_DEFAULT_MIN_PIX_DOUBLE
virtual ossimDataObjectStatus validate() const
ossimImageSource * theInputConnection
unsigned int ossim_uint32
virtual const ossim_float64 * getNullPix() const
32 bit normalized floating point
ossimRefPtr< ossimImageData > theTile
virtual const ossim_float32 * getFloatBuf() const
std::vector< std::map< double, double > > theLut
virtual void makeBlank()
Initializes data to null pixel values.
16 bit unsigned integer (11 bits used)
virtual void setMaxPix(ossim_float64 max_pix)
virtual const void * getBuf() const
32 bit floating point
virtual void setMinPix(ossim_float64 min_pix)
16 bit unsigned iteger
64 bit floating point
16 bit signed integer
virtual double getNullPixelValue(ossim_uint32 band=0) const
Each band has a null pixel associated with it.
8 bit unsigned iteger
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)
16 bit unsigned integer (12 bits used)
virtual const ossim_float64 * getDoubleBuf() const

◆ initialize()

void ossimBandLutFilter::initialize ( )
virtual

Reimplemented from ossimImageSourceFilter.

Definition at line 223 of file ossimBandLutFilter.cpp.

References ossimImageSourceFilter::initialize(), ossimImageSource::initialize(), ossimImageSourceFilter::theInputConnection, and theTile.

224 {
225  // This assigns theInputConnection if one is there.
227 
228  // theTile will get allocated on first getTile call.
229  theTile = 0;
230  if ( theInputConnection )
231  {
232  // Initialize the chain on the left hand side of us.
234  }
235 }
ossimImageSource * theInputConnection
ossimRefPtr< ossimImageData > theTile
virtual void initialize()=0

◆ initializeLut()

bool ossimBandLutFilter::initializeLut ( const ossimKeywordlist kwl,
const char *  prefix = 0 
)
protected

Definition at line 317 of file ossimBandLutFilter.cpp.

References ossimString::empty(), ossimKeywordlist::find(), ossimImageSourceFilter::getNumberOfInputBands(), ossimKeywordlist::numberOf(), ossimImageSourceFilter::theInputConnection, theLut, and ossimString::toDouble().

318 {
319  theLut.clear();
320  ossim_uint32 numBands = getNumberOfInputBands();
321  bool usingBandPrefix = true;
322  if (numBands <= 1)
323  {
324  ossim_uint32 numEntries = kwl.numberOf(prefix, "band0.in");
325  if (numEntries == 0)
326  {
327  usingBandPrefix = false;
328  numBands = 1;
329  }
330  }
331 
332  ossim_uint32 band = 0;
333  while (true)
334  {
335  ossim_uint32 entry = 0;
336  map<double,double> bandMap;
337  while (true)
338  {
339  ostringstream inKey, outKey;
340  if (usingBandPrefix)
341  {
342  inKey << "band" << band << ".entry" << entry <<".in";
343  outKey << "band" << band << ".entry" << entry <<".out";
344  }
345  else
346  {
347  inKey << "entry" << entry <<".in";
348  outKey << "entry" << entry <<".out";
349  }
350 
351  ossimString inVal = kwl.find(prefix, inKey.str().c_str());
352  if (inVal.empty())
353  break;
354  ossimString outVal = kwl.find(prefix, outKey.str().c_str());
355  if (outVal.empty())
356  break;
357 
358  bandMap.insert(std::pair<double,double>(inVal.toDouble(), outVal.toDouble()));
359  ++entry;
360  }
361 
362  if (bandMap.empty())
363  break;
364 
365  theLut.push_back(bandMap);
366 
367  ++band;
368  if ((numBands == 1) || !usingBandPrefix)
369  break;
370 
371  }
372 
373  // Band still 0 would indicate a failure reading the first band entry:
374  if (band == 0)
375  return false;
376 
377  // Check that the correct number of bands are represented:
378  if (theInputConnection && (numBands > band))
379  {
380  if (!usingBandPrefix)
381  {
382  // Use the same map for all bands
383  for (ossim_uint32 i=1; i<numBands; ++i)
384  theLut.push_back(theLut[0]);
385  }
386  else
387  {
388  // Not enough bands were specified in the KWL to represent all input bands. Set remaining
389  // bands to no entries:
390  map<double,double> nullBandMap;
391  for (; band<numBands; ++band)
392  theLut.push_back(nullBandMap);
393  }
394  }
395  return true;
396 }
virtual ossim_uint32 getNumberOfInputBands() const
ossim_uint32 numberOf(const char *str) const
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
const char * find(const char *key) const
ossimImageSource * theInputConnection
unsigned int ossim_uint32
double toDouble() const
std::vector< std::map< double, double > > theLut
bool empty() const
Definition: ossimString.h:411

◆ loadState()

bool ossimBandLutFilter::loadState ( const ossimKeywordlist kwl,
const char *  prefix = NULL 
)
virtual

Method to the load (recreate) the state of an object from a keyword list.

Return true if ok or false on error.

Reimplemented from ossimImageSourceFilter.

Definition at line 287 of file ossimBandLutFilter.cpp.

References ossimKeywordlist::find(), and theLutFile.

Referenced by ossimShorelineTool::doThreshold(), and setLut().

288 {
289  bool return_state = true;
290  ossimKeywordlist kwl (orig_kwl); // need non-const copy
291 
292  // First look for a LUT filename, and add its contents to the original KWL:
293  theLutFile = kwl.find(prefix, LUT_FILE_KW);
294  if (!theLutFile.empty())
295  {
296  // Need new (non const) KWL to hold merged contents, maintaining proper prefix if any:
297  ossimKeywordlist lut_kwl;
298  if (lut_kwl.addFile(theLutFile))
299  kwl.add(prefix, lut_kwl, false); // appends all entries of lut_kwl with prefix before adding
300  }
301 
303  ossimString lookup = kwl.find(prefix, MODE_KW);
304  if (lookup.contains("literal"))
305  theMode = LITERAL;
306 
307  int scalar = ossimScalarTypeLut::instance()->getEntryNumber(kwl, prefix);
308  if (scalar != ossimLookUpTable::NOT_FOUND)
309  setOutputScalarType(static_cast<ossimScalarType>(scalar));
310 
311  return_state &= initializeLut(kwl, prefix);
312  return_state &= ossimImageSourceFilter::loadState(orig_kwl, prefix);
313 
314  return return_state;
315 }
Represents serializable keyword/value map.
bool addFile(const char *file)
const char * find(const char *key) const
bool contains(char aChar) const
Definition: ossimString.h:58
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.
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
ossimFilename theLutFile
virtual void setOutputScalarType(ossimScalarType scalarType)
Sets the output scalar type.
bool empty() const
Definition: ossimString.h:411
bool initializeLut(const ossimKeywordlist &kwl, const char *prefix=0)

◆ saveState()

bool ossimBandLutFilter::saveState ( ossimKeywordlist kwl,
const char *  prefix = NULL 
) const
virtual

Method to save the state of an object to a keyword list.

Return true if ok or false on error.

Reimplemented from ossimImageSourceFilter.

Definition at line 237 of file ossimBandLutFilter.cpp.

References ossimKeywordlist::add(), INTERPOLATED, LITERAL, theLut, and theMode.

238 {
239  if (theLut.empty())
240  return true;
241 
242  ossimString value;
243  switch (theMode)
244  {
245  case LITERAL:
246  value = "literal";
247  break;
248  case INTERPOLATED:
249  default:
250  value = "interpolated";
251  break;
252  }
253  kwl.add(prefix, MODE_KW, value.c_str(), true);
254 
255  bool rtn_stat = true;
256 
257  // Save the actual LUT:
258  int numBands = theLut.size();
259  for (int band=0; band<numBands; ++band)
260  {
261  ostringstream base_keyword;
262  if (numBands > 1)
263  base_keyword << "band" << band << ".";
264 
265  std::map<double, double>::const_iterator iter = theLut[band].begin();
266  ossim_uint32 entry = 0;
267  while (iter != theLut[band].end())
268  {
269  ostringstream inKey, outKey;
270  inKey << base_keyword.str() << "entry" << entry <<".in";
271  outKey << base_keyword.str() << "entry" << entry <<".out";
272 
273  ostringstream inVal, outVal;
274  inVal << iter->first;
275  outVal << iter->second;
276 
277  kwl.add(prefix, inKey.str().c_str(), inVal.str().c_str());
278  kwl.add(prefix, outKey.str().c_str(), outVal.str().c_str());
279  ++iter;
280  ++entry;
281  }
282  }
283  rtn_stat &= ossimImageSourceFilter::saveState(kwl, prefix);
284  return rtn_stat;
285 }
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
unsigned int ossim_uint32
std::vector< std::map< double, double > > theLut
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
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

◆ setLut()

void ossimBandLutFilter::setLut ( const ossimFilename file)

This opens the keyword list and initializes lut.

Parameters
fileKeyword list containing lut.

Definition at line 398 of file ossimBandLutFilter.cpp.

References ossimFilename::exists(), loadState(), and theLutFile.

399 {
400  theLutFile = file;
401  if(file.exists())
402  {
404  loadState(kwl);
405  }
406 }
Represents serializable keyword/value map.
bool exists() const
ossimFilename theLutFile
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=NULL)
Method to the load (recreate) the state of an object from a keyword list.

◆ setMode()

void ossimBandLutFilter::setMode ( Mode  mode)
inline

Definition at line 110 of file ossimBandLutFilter.h.

110 { theMode = mode; }

◆ setOutputScalarType() [1/2]

void ossimBandLutFilter::setOutputScalarType ( ossimScalarType  scalarType)
virtual

Sets the output scalar type.

Definition at line 408 of file ossimBandLutFilter.cpp.

References allocate(), OSSIM_SCALAR_UNKNOWN, ossimNotify(), ossimNotifyLevel_WARN, and theOutputScalarType.

Referenced by setOutputScalarType().

409 {
410  if (scalarType == OSSIM_SCALAR_UNKNOWN)
411  {
413  << "ossimScalarRemapper::setOutputScalarType WARN:\n"
414  << "OSSIM_SCALAR_UNKNOWN passed to method. No action taken..."
415  << std::endl;
416  return;
417  }
418 
419  theOutputScalarType = scalarType;
420  allocate();
421 }
void allocate()
Called on first getTile, will initialize all data needed.
ossimScalarType theOutputScalarType
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ setOutputScalarType() [2/2]

void ossimBandLutFilter::setOutputScalarType ( ossimString  scalarType)
virtual

Definition at line 423 of file ossimBandLutFilter.cpp.

References ossimString::c_str(), ossimLookUpTable::getEntryNumber(), ossimScalarTypeLut::instance(), ossimLookUpTable::NOT_FOUND, ossimNotify(), ossimNotifyLevel_WARN, and setOutputScalarType().

424 {
425  int scalar = ossimScalarTypeLut::instance()->getEntryNumber(scalarType.c_str());
426 
427  if (scalar != ossimLookUpTable::NOT_FOUND)
428  {
429  setOutputScalarType(static_cast<ossimScalarType>(scalar));
430  }
431  else
432  {
434  << "ossimScalarRemapper ERROR:"
435  << "\nUnknown scalar type: " << scalarType.c_str() << std::endl;
436  }
437 }
virtual ossim_int32 getEntryNumber(const char *entry_string, bool case_insensitive=true) const
static ossimScalarTypeLut * instance()
Returns the static instance of an ossimScalarTypeLut object.
virtual void setOutputScalarType(ossimScalarType scalarType)
Sets the output scalar type.
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
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

Member Data Documentation

◆ theLut

std::vector< std::map<double, double> > ossimBandLutFilter::theLut
protected

Definition at line 142 of file ossimBandLutFilter.h.

Referenced by getTile(), initializeLut(), and saveState().

◆ theLutFile

ossimFilename ossimBandLutFilter::theLutFile
protected

Definition at line 146 of file ossimBandLutFilter.h.

Referenced by loadState(), and setLut().

◆ theMode

Mode ossimBandLutFilter::theMode
protected

Definition at line 144 of file ossimBandLutFilter.h.

Referenced by getTile(), and saveState().

◆ theOutputScalarType

ossimScalarType ossimBandLutFilter::theOutputScalarType
protected

Definition at line 147 of file ossimBandLutFilter.h.

Referenced by allocate(), getTile(), and setOutputScalarType().

◆ theTile

ossimRefPtr<ossimImageData> ossimBandLutFilter::theTile
protected

Definition at line 145 of file ossimBandLutFilter.h.

Referenced by allocate(), getTile(), and initialize().


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