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

This filter outputs a single band that is the weighted average of all the input bands retrieved from the getTile. More...

#include <ossimBandAverageFilter.h>

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

Public Member Functions

 ossimBandAverageFilter ()
 
 ossimBandAverageFilter (ossimImageSource *input, const std::vector< double > &weights)
 
virtual ~ossimBandAverageFilter ()
 
virtual ossim_uint32 getNumberOfOutputBands () const
 The data object argument is deprecated and should not be used. More...
 
virtual ossimRefPtr< ossimImageDatagetTile (const ossimIrect &rect, ossim_uint32 resLevel=0)
 Since this filter is going to operate in native pixel type we will use a tmeplate method to do this. More...
 
virtual double getNullPixelValue (ossim_uint32 band=0) const
 Since we are merging all bands we will use the null pix of the first input band as our null pix. More...
 
virtual double getMinPixelValue (ossim_uint32 band=0) const
 We will use the min of all bands as our min. More...
 
virtual double getMaxPixelValue (ossim_uint32 band=0) const
 We will use the max of all bands as our max. More...
 
double getWeight (ossim_uint32 band) const
 simple access method to get a weight More...
 
void setWeight (ossim_uint32 band, double weight)
 Sinple access method to set the weight of a band, We make sure that it is a positive weight. More...
 
virtual void initialize ()
 allocates its tile buffer More...
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 loads its weights to a keywordlist More...
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 Saves its weights to a keywordlist. 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 ossimScalarType getOutputScalarType () const
 This will be used to query the output pixel type of the tile source. 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 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

void checkWeights ()
 
template<class T >
void averageInput (T dummyVariable, ossimRefPtr< ossimImageData > inputDataObject)
 
- 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

ossimRefPtr< ossimImageDatatheTile
 
std::vector< double > theWeights
 
- 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
 

Additional Inherited Members

- 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
 

Detailed Description

This filter outputs a single band that is the weighted average of all the input bands retrieved from the getTile.

This filter will work with any input scalar type. Note the OSSIMDLLEXPORT is used for the different compilers that require importing and exporting symbols for shared library support.

Definition at line 24 of file ossimBandAverageFilter.h.

Constructor & Destructor Documentation

◆ ossimBandAverageFilter() [1/2]

ossimBandAverageFilter::ossimBandAverageFilter ( )

Definition at line 29 of file ossimBandAverageFilter.cpp.

31  theTile(NULL)
32 {
33 }
ossimRefPtr< ossimImageData > theTile
ossimImageSourceFilter(ossimObject *owner=NULL)

◆ ossimBandAverageFilter() [2/2]

ossimBandAverageFilter::ossimBandAverageFilter ( ossimImageSource input,
const std::vector< double > &  weights 
)

Definition at line 35 of file ossimBandAverageFilter.cpp.

37  :ossimImageSourceFilter(input),
38  theTile(NULL),
39  theWeights(weights)
40 {
41 }
ossimRefPtr< ossimImageData > theTile
ossimImageSourceFilter(ossimObject *owner=NULL)
std::vector< double > theWeights

◆ ~ossimBandAverageFilter()

ossimBandAverageFilter::~ossimBandAverageFilter ( )
virtual

Definition at line 43 of file ossimBandAverageFilter.cpp.

44 {
45 }

Member Function Documentation

◆ averageInput()

template<class T >
void ossimBandAverageFilter::averageInput ( dummyVariable,
ossimRefPtr< ossimImageData inputDataObject 
)
protected

Definition at line 257 of file ossimBandAverageFilter.cpp.

References ossimImageData::getBuf(), ossimImageData::getHeight(), ossimImageData::getNullPix(), ossimImageData::getNumberOfBands(), ossimImageData::getWidth(), theTile, and theWeights.

Referenced by getTile().

260 {
261  // since we have already checked the input for empty or
262  // null we will now execute the algorithm. We will make
263  //
264  //
265  std::vector<T*> inputBands(inputDataObject->getNumberOfBands());
266  std::vector<double> nullValues(inputDataObject->getNumberOfBands());
267  ossim_uint32 i = 0;
268 
269  // for efficiency we will copy the band pointers and
270  // null values so we don't have extra function calls
271  // on a per band basis
272  //
273  for(i = 0; i < inputDataObject->getNumberOfBands(); ++i)
274  {
275  inputBands[i] = static_cast<T*>(inputDataObject->getBuf(i));
276  nullValues[i] = inputDataObject->getNullPix(i);
277  }
278 
279  // store the output buffer pointer
280  T* outputBuf = static_cast<T*>(theTile->getBuf(0));
281 
282  // setup index values and boundary values
283  ossim_uint32 upperBound = theTile->getWidth()*theTile->getHeight();
284  ossim_uint32 bandIndex = 0;
285  ossim_uint32 numberOfBands = inputDataObject->getNumberOfBands();
286  double outputNullPix = theTile->getNullPix(0);
287 
288  for(i = 0; i < upperBound; ++i)
289  {
290  double value=0.0;
291  double sumWeights=0.0;
292 
293  // loop over each band only using the valid pixel data
294  // in the weighted average.
295  //
296  for(bandIndex = 0; bandIndex < numberOfBands; ++bandIndex)
297  {
298  // if valid then muliply the value by the weight and add it to
299  // current pixel value
300  if(*inputBands[bandIndex] != nullValues[bandIndex])
301  {
302  value += theWeights[bandIndex]*((double)*inputBands[bandIndex]);
303  sumWeights += theWeights[bandIndex];
304  }
305  // increment to the next pixel for the next time around
306  ++inputBands[bandIndex];
307  }
308 
309  // check to see if we had any valid data. If we did the weight
310  // should be greater than 0
311  if(sumWeights != 0.0)
312  {
313  value /= sumWeights;
314  }
315  else
316  {
317  // else we set the pixel to the output null value
318  value = outputNullPix;
319  }
320  // store the result in the outputBuffer.
321  *outputBuf = static_cast<T>(value);
322 
323  // advance the output buffer to the next pixel value
324  ++outputBuf;
325  }
326 }
virtual ossim_uint32 getWidth() const
virtual ossim_uint32 getNumberOfBands() const
ossimRefPtr< ossimImageData > theTile
virtual ossim_uint32 getHeight() const
unsigned int ossim_uint32
virtual const ossim_float64 * getNullPix() const
virtual const void * getBuf() const
std::vector< double > theWeights

◆ checkWeights()

void ossimBandAverageFilter::checkWeights ( )
protected

Definition at line 234 of file ossimBandAverageFilter.cpp.

References ossimImageSource::getNumberOfOutputBands(), ossimImageSourceFilter::theInputConnection, theTile, and theWeights.

Referenced by initialize().

235 {
236  // we have not been initialzed yet
237  //
238  if(!theTile)
239  {
240  return;
241  }
242 
243  // Check to see if the weights array is the same size as the input
244  // list. If not then resize it and populate them with the same weight
245  // value. It does not matter if they sum to one since we will perform
246  // a weighted average in the execution of the algorithm
247  //
249  {
251 
252  std::fill(theWeights.begin(), theWeights.end(), 1);
253  }
254 }
ossimRefPtr< ossimImageData > theTile
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
ossimImageSource * theInputConnection
std::vector< double > theWeights

◆ getMaxPixelValue()

double ossimBandAverageFilter::getMaxPixelValue ( ossim_uint32  band = 0) const
virtual

We will use the max of all bands as our max.

If we aredisabled we just return the inputs max

Reimplemented from ossimImageSource.

Definition at line 210 of file ossimBandAverageFilter.cpp.

References ossim::defaultMin(), ossimImageSource::getMaxPixelValue(), ossimImageSource::getNumberOfOutputBands(), ossimSource::isSourceEnabled(), OSSIM_DOUBLE, and ossimImageSourceFilter::theInputConnection.

211 {
212  if(!isSourceEnabled())
213  {
215  }
216 
217  // loop through each band and find the max pix value
218  ossim_uint32 bandIndex = 0;
220  double maxValue = ossim::defaultMin(OSSIM_DOUBLE);
221  for(bandIndex = 0; bandIndex < inputBands; ++bandIndex)
222  {
223  double maxPix = theInputConnection->getMaxPixelValue(bandIndex);
224 
225  if(maxPix > maxValue)
226  {
227  maxValue = maxPix;
228  }
229  }
230 
231  return maxValue;
232 }
virtual bool isSourceEnabled() const
Definition: ossimSource.cpp:79
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
OSSIM_DLL double defaultMin(ossimScalarType scalarType)
Definition: ossimCommon.cpp:73
ossimImageSource * theInputConnection
unsigned int ossim_uint32
virtual double getMaxPixelValue(ossim_uint32 band=0) const
Returns the max pixel of the band.
64 bit floating point

◆ getMinPixelValue()

double ossimBandAverageFilter::getMinPixelValue ( ossim_uint32  band = 0) const
virtual

We will use the min of all bands as our min.

If we aredisabled we just return the inputs min

Reimplemented from ossimImageSource.

Definition at line 186 of file ossimBandAverageFilter.cpp.

References ossim::defaultMax(), ossimImageSource::getMinPixelValue(), ossimImageSource::getNumberOfOutputBands(), ossimSource::isSourceEnabled(), OSSIM_DOUBLE, and ossimImageSourceFilter::theInputConnection.

187 {
189  {
191  }
192 
193  // loop through each band and find the min pix value
194  ossim_uint32 bandIndex = 0;
196  double minValue = ossim::defaultMax(OSSIM_DOUBLE);
197  for(bandIndex = 0; bandIndex < inputBands; ++bandIndex)
198  {
199  double minPix = theInputConnection->getMinPixelValue(bandIndex);
200 
201  if(minPix < minValue)
202  {
203  minValue = minPix;
204  }
205  }
206 
207  return minValue;
208 }
virtual bool isSourceEnabled() const
Definition: ossimSource.cpp:79
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
virtual double getMinPixelValue(ossim_uint32 band=0) const
Returns the min pixel of the band.
ossimImageSource * theInputConnection
unsigned int ossim_uint32
OSSIM_DLL double defaultMax(ossimScalarType scalarType)
64 bit floating point

◆ getNullPixelValue()

double ossimBandAverageFilter::getNullPixelValue ( ossim_uint32  band = 0) const
virtual

Since we are merging all bands we will use the null pix of the first input band as our null pix.

If we are disabled we just return the input s null

Reimplemented from ossimImageSource.

Definition at line 176 of file ossimBandAverageFilter.cpp.

References ossimImageSource::getMinPixelValue(), ossimImageSource::getNullPixelValue(), and ossimSource::isSourceEnabled().

177 {
178  if(!isSourceEnabled())
179  {
181  }
182  // lets use the first band's null value as our null
184 }
virtual bool isSourceEnabled() const
Definition: ossimSource.cpp:79
virtual double getMinPixelValue(ossim_uint32 band=0) const
Returns the min pixel of the band.
virtual double getNullPixelValue(ossim_uint32 band=0) const
Each band has a null pixel associated with it.

◆ getNumberOfOutputBands()

ossim_uint32 ossimBandAverageFilter::getNumberOfOutputBands ( ) const
virtual

The data object argument is deprecated and should not be used.

eventually we will remove it from the base classes. This method will return 1 if our source is enabled else it calls the base class getNumberOfOutputBands.

Reimplemented from ossimImageSource.

Definition at line 47 of file ossimBandAverageFilter.cpp.

References ossimImageSource::getNumberOfOutputBands(), and ossimSource::isSourceEnabled().

48 {
49  if(isSourceEnabled())
50  {
51  return 1;
52  }
53 
55 }
virtual bool isSourceEnabled() const
Definition: ossimSource.cpp:79
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.

◆ getTile()

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

Since this filter is going to operate in native pixel type we will use a tmeplate method to do this.

It will check the scalar tpe of the input and then cat it to set the template variabel to be used within the template method averageInput.

Reimplemented from ossimImageSource.

Definition at line 57 of file ossimBandAverageFilter.cpp.

References averageInput(), ossimObject::getClassName(), ossimDataObject::getDataObjectStatus(), ossimImageData::getNumberOfBands(), ossimRectilinearDataObject::getScalarType(), ossimImageSource::getTile(), initialize(), ossimSource::isSourceEnabled(), ossimImageData::makeBlank(), OSSIM_DOUBLE, OSSIM_EMPTY, ossimErrorCodes::OSSIM_ERROR, OSSIM_FLOAT, OSSIM_NORMALIZED_DOUBLE, OSSIM_NORMALIZED_FLOAT, OSSIM_NULL, OSSIM_SSHORT16, OSSIM_UCHAR, OSSIM_USHORT11, OSSIM_USHORT12, OSSIM_USHORT13, OSSIM_USHORT14, OSSIM_USHORT15, OSSIM_USHORT16, ossimSetError(), ossimImageData::setImageRectangle(), ossimImageSourceFilter::theInputConnection, theTile, ossimRefPtr< T >::valid(), and ossimImageData::validate().

58 {
59  // first we will check to see if we have an input connection
60  //
62  {
63  // this will probably be null since we aren't initialized.
64  // we really need to creae a default blank tile in OSSIM that is returned
65  return theTile;
66  }
67 
68  ossimRefPtr<ossimImageData> inputData =
69  theInputConnection->getTile(rect, resLevel);
70 
71  if(!inputData.valid())
72  {
73  return inputData;
74  }
75 
76  // If we are disabled or if the data object is empty or NULL or
77  // not enough bands we don't need to run our algorithm so return the input
78  // tile.
79  if(!isSourceEnabled() ||
80  (inputData->getDataObjectStatus() == OSSIM_NULL)||
81  (inputData->getDataObjectStatus() == OSSIM_EMPTY)||
82  (inputData->getNumberOfBands() < 2))
83  {
84  return inputData;
85  }
86 
87  // check to see if we are initialized
88  if(!theTile.valid())
89  {
90  initialize();
91  }
92 
94 
95  // now lets set up the template method to operate in native type and run
96  // the algorithm
97  //
98  switch(inputData->getScalarType())
99  {
100  case OSSIM_UCHAR:
101  {
102  averageInput((ossim_uint8)0, // setup template variable
103  inputData);
104  break;
105  }
106  case OSSIM_USHORT11:
107  case OSSIM_USHORT12:
108  case OSSIM_USHORT13:
109  case OSSIM_USHORT14:
110  case OSSIM_USHORT15:
111  case OSSIM_USHORT16:
112  {
113  averageInput((ossim_uint16)0, // setup template variable
114  inputData);
115  break;
116  }
117  case OSSIM_SSHORT16:
118  {
119  averageInput((ossim_sint16)0, // setup template variable
120  inputData);
121  break;
122  }
124  case OSSIM_FLOAT:
125  {
126  averageInput((float)0, // setup template variable
127  inputData);
128  break;
129  }
131  case OSSIM_DOUBLE:
132  {
133  averageInput((double)0, // setup template variable
134  inputData);
135  break;
136  }
137  default:
138  {
141  "Unsupported scalar type in file %d at line %d",
142  __FILE__,
143  __LINE__);
144 
145 
146  theTile->makeBlank();
147  break;
148  }
149  }
150 
151  theTile->validate();
152 
153 
154  return theTile;
155 }
OSSIMDLLEXPORT void ossimSetError(const char *className, ossim_int32 error, const char *fmtString=0,...)
16 bit unsigned integer (15 bits used)
virtual bool isSourceEnabled() const
Definition: ossimSource.cpp:79
virtual void initialize()
allocates its tile buffer
virtual ossim_uint32 getNumberOfBands() const
virtual void setImageRectangle(const ossimIrect &rect)
ossimRefPtr< ossimImageData > theTile
bool valid() const
Definition: ossimRefPtr.h:75
virtual ossimDataObjectStatus getDataObjectStatus() const
16 bit unsigned integer (14 bits used)
static const ossimErrorCode OSSIM_ERROR
virtual ossimString getClassName() const
Definition: ossimObject.cpp:64
16 bit unsigned integer (13 bits used)
unsigned short ossim_uint16
virtual ossimDataObjectStatus validate() const
signed short ossim_sint16
ossimImageSource * theInputConnection
32 bit normalized floating point
virtual ossimScalarType getScalarType() const
virtual void makeBlank()
Initializes data to null pixel values.
64 bit normalized floating point
16 bit unsigned integer (11 bits used)
32 bit floating point
16 bit unsigned iteger
64 bit floating point
16 bit signed integer
unsigned char ossim_uint8
8 bit unsigned iteger
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)
16 bit unsigned integer (12 bits used)
void averageInput(T dummyVariable, ossimRefPtr< ossimImageData > inputDataObject)

◆ getWeight()

double ossimBandAverageFilter::getWeight ( ossim_uint32  band) const

simple access method to get a weight

Definition at line 382 of file ossimBandAverageFilter.cpp.

References theWeights.

383 {
384  if(band < theWeights.size())
385  {
386  return theWeights[band];
387  }
388 
389  return 0.0;
390 }
std::vector< double > theWeights

◆ initialize()

void ossimBandAverageFilter::initialize ( )
virtual

allocates its tile buffer

Reimplemented from ossimImageSourceFilter.

Definition at line 159 of file ossimBandAverageFilter.cpp.

References checkWeights(), ossimImageDataFactory::create(), ossimImageSourceFilter::initialize(), ossimImageData::initialize(), ossimImageDataFactory::instance(), ossimImageSourceFilter::theInputConnection, and theTile.

Referenced by getTile().

160 {
162 
163  // theInputConnection is defined in ossimImageSourceFilter
164  // It is automatically set when an input is connected to this
165  // object
167  {
169 
170  // now initialize the tile
171  theTile->initialize();
172  checkWeights();
173  }
174 }
ossimRefPtr< ossimImageData > theTile
virtual void initialize()
Initialize the data buffer.
static ossimImageDataFactory * instance()
ossimImageSource * theInputConnection
virtual ossimRefPtr< ossimImageData > create(ossimSource *owner, ossimScalarType scalar, ossim_uint32 bands=1) const

◆ loadState()

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

loads its weights to a keywordlist

Reimplemented from ossimImageSourceFilter.

Definition at line 329 of file ossimBandAverageFilter.cpp.

References ossimKeywordlist::find().

331 {
332  // get the value of the stored keyword
333  ossimString weightString = kwl.find(prefix, WEIGHTS_KW);
334  weightString = weightString.trim();
335 
336 
337  theWeights.clear();
338  if(weightString != "")
339  {
340  // split the string list into an array of strings
341  std::vector<ossimString> weightList = weightString.split(" ");
342 
343  // resize the weights to the size of the weight list
344  //
345  theWeights.resize(weightList.size());
346  ossim_uint32 i = 0;
347 
348  // now store the weights to the array
349  for(i = 0; i < theWeights.size(); ++i)
350  {
351  theWeights[i] = weightList[i].toDouble();
352  }
353  }
354 
355  // call base class to continue the load state
356  return ossimImageSourceFilter::loadState(kwl, prefix);
357 }
const char * find(const char *key) const
void split(std::vector< ossimString > &result, const ossimString &separatorList, bool skipBlankFields=false) const
Splits this string into a vector of strings (fields) using the delimiter list specified.
unsigned int ossim_uint32
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
std::vector< double > theWeights

◆ saveState()

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

Saves its weights to a keywordlist.

Reimplemented from ossimImageSourceFilter.

Definition at line 359 of file ossimBandAverageFilter.cpp.

References ossimKeywordlist::add(), theWeights, and ossimString::trim().

361 {
362  std::stringstream out;
363 
364  // copy the weights to a memory stream separated by space
365  std::copy(theWeights.begin(),
366  theWeights.end(),
367  ostream_iterator<double>(out, " "));
368 
369  ossimString weightString = out.str();
370  weightString = weightString.trim();
371 
372 
373  kwl.add(prefix, // prefix to help uniquely id or attributes
374  WEIGHTS_KW, // the keyword to identity our attribute
375  weightString.c_str(), // the value
376  true); // overwrite if already in the keywordlist
377 
378  // call base classes save to allow us to pass the information up
379  return ossimImageSourceFilter::saveState(kwl, prefix);
380 }
std::basic_stringstream< char > stringstream
Class for char mixed input and output memory streams.
Definition: ossimIosFwd.h:38
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
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
std::vector< double > theWeights

◆ setWeight()

void ossimBandAverageFilter::setWeight ( ossim_uint32  band,
double  weight 
)

Sinple access method to set the weight of a band, We make sure that it is a positive weight.

Definition at line 392 of file ossimBandAverageFilter.cpp.

References theWeights.

393 {
394  if(band < theWeights.size())
395  {
396  theWeights[band] = fabs(weight);
397  }
398 }
std::vector< double > theWeights

Member Data Documentation

◆ theTile

ossimRefPtr<ossimImageData> ossimBandAverageFilter::theTile
protected

Definition at line 97 of file ossimBandAverageFilter.h.

Referenced by averageInput(), checkWeights(), getTile(), and initialize().

◆ theWeights

std::vector<double> ossimBandAverageFilter::theWeights
protected

Definition at line 98 of file ossimBandAverageFilter.h.

Referenced by averageInput(), checkWeights(), getWeight(), saveState(), and setWeight().


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