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

#include <ossimDilationFilter.h>

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

Public Member Functions

 ossimDilationFilter (ossimObject *owner=NULL)
 
virtual void initialize ()
 
virtual ossimRefPtr< ossimImageDatagetTile (const ossimIrect &rect, ossim_uint32 resLevel=0)
 
void setWindowSize (ossim_uint32 windowSize)
 Size of resampling kernel width & height. More...
 
ossim_uint32 getWindowSize () const
 
void setRecursiveFlag (bool flag=true)
 Set if getTile is to be called recursively until all pixels have been assigned non-null. More...
 
bool getRecursiveFlag () const
 
virtual void setProperty (ossimRefPtr< ossimProperty > property)
 
virtual ossimRefPtr< ossimPropertygetProperty (const ossimString &name) const
 
virtual void getPropertyNames (std::vector< ossimString > &propertyNames) const
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 Method to save the state of an object to a keyword list. More...
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 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)
 
- 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 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 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 ~ossimDilationFilter ()
 
template<class T >
void doDilation (T scalarType, ossimRefPtr< ossimImageData > &inputData)
 
- 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
 
ossimRefPtr< ossimImageDatatheTempTile
 
ossim_uint32 theWindowSize
 

Used for recursion when recursive fill enabled

More...
 
bool theRecursiveFlag
 
ossimPolygon theValidImagePoly
 
bool theNullFoundFlag
 
- 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

class ossimDilationFilter

Allows you to change between a median or mean filter. You can also specify a window size which the median or mean is computed and the center pixel is replaced.

Definition at line 23 of file ossimDilationFilter.h.

Constructor & Destructor Documentation

◆ ossimDilationFilter()

ossimDilationFilter::ossimDilationFilter ( ossimObject owner = NULL)

Definition at line 29 of file ossimDilationFilter.cpp.

References ossimConnectableObject::setDescription().

30  :ossimImageSourceFilter(owner),
31  theTile(0),
32  theTempTile(0),
33  theWindowSize(15),
34  theRecursiveFlag(false),
35  theNullFoundFlag(false)
36 {
37  setDescription(ossimString("Dilation Filter"));
38 }
virtual void setDescription(const ossimString &description)
ossimImageSourceFilter(ossimObject *owner=NULL)
ossim_uint32 theWindowSize
Used for recursion when recursive fill enabled
ossimRefPtr< ossimImageData > theTile
ossimRefPtr< ossimImageData > theTempTile

◆ ~ossimDilationFilter()

ossimDilationFilter::~ossimDilationFilter ( )
protectedvirtual

Definition at line 40 of file ossimDilationFilter.cpp.

41 {
42 }

Member Function Documentation

◆ doDilation()

template<class T >
void ossimDilationFilter::doDilation ( scalarType,
ossimRefPtr< ossimImageData > &  inputData 
)
protected

Definition at line 126 of file ossimDilationFilter.cpp.

References ossimRefPtr< T >::get(), ossimImageData::getBuf(), ossimDataObject::getDataObjectStatus(), ossimImageData::getHeight(), ossimImageData::getImageRectangle(), ossimImageData::getNullPix(), ossimImageData::getNumberOfBands(), ossimImageData::getWidth(), ossimPolygon::isPointWithin(), ossimImageData::loadTile(), ossim::min(), OSSIM_EMPTY, OSSIM_FULL, status, theNullFoundFlag, theRecursiveFlag, theTempTile, theTile, theValidImagePoly, theWindowSize, ossimIrect::ul(), ossimImageData::validate(), x, and y.

Referenced by getTile().

127 {
129 
130  if ((status == OSSIM_FULL) || (status == OSSIM_EMPTY))
131  {
132  // Nothing to do just copy the tile.
133  theTile->loadTile(inputData.get());
134  return;
135  }
136 
137  ossim_int32 halfWindow = (ossim_int32)(theWindowSize >> 1);
138  ossim_int32 x, y, kernelX, kernelY;
139  ossim_int32 iw = (ossim_int32)inputData->getWidth();
140  ossim_int32 ih = (ossim_int32)inputData->getHeight();
143  ossim_uint32 numBands = ossim::min(theTile->getNumberOfBands(), inputData->getNumberOfBands());
144 
145  // It may be that the input rect is the same size as the output (i.e., the tile bounds aren't
146  // expanded in the input's request to permit full kernels for output edge pixels:
147  ossim_uint32 i_offset = 0;
148  ossim_int32 delta = (ossim_int32)((iw - ow) >> 1);
149  ossim_int32 xi, yi;
150  if (delta > 0)
151  i_offset = (ossim_uint32) halfWindow*(iw + 1);
152 
153  ossimIpt tile_ul (theTile->getImageRectangle().ul());
154  vector<double> values;
155  for(ossim_uint32 bandIdx = 0; bandIdx < numBands; ++bandIdx)
156  {
157  T* inputBuf = (T*)inputData->getBuf(bandIdx);
158  T* outputBuf = (T*)theTile->getBuf(bandIdx);
159  if (!inputBuf || !outputBuf)
160  {
161  return; // Shouldn't happen...
162  }
163 
164  const T NP = (T)inputData->getNullPix(bandIdx);
165 
166  for(y = 0; y < oh; ++y)
167  {
168  for(x = 0; x < ow; ++x)
169  {
170  // Get the center input pixel. Only process those points inside the valid image
171  // (to avoid dilation beyond valid image)
172  const T CP = *(inputBuf+i_offset);
173  ossimDpt ipt (tile_ul.x+x, tile_ul.y+y);
174  if ((CP == NP) && theValidImagePoly.isPointWithin(ipt))
175  {
176  theNullFoundFlag = true; // Needed for recursion
177  values.clear();
178  for(kernelY = -halfWindow; kernelY <= halfWindow; ++kernelY)
179  {
180  yi = y + kernelY + delta;
181  if ((yi < 0) || (y > ih))
182  continue;
183 
184  for(kernelX = -halfWindow; kernelX <= halfWindow; ++kernelX)
185  {
186  xi = x + kernelX + delta;
187  if ((xi < 0) || (x > iw))
188  continue;
189 
190  T tempValue = *(inputBuf+kernelX+delta + (kernelY+delta)*iw);
191  if(tempValue != NP)
192  values.push_back((double)tempValue);
193  }
194  }
195 
196  if(values.size() > 0)
197  {
198  double accum = accumulate(values.begin(), values.end(), 0.0);
199  double average = accum/(double)values.size();
200  (*outputBuf) = (T)average;
201  }
202  else
203  {
204  (*outputBuf) = NP;
205  }
206 
207  }
208  else // Center pixel (CP) not null.
209  {
210  (*outputBuf) = CP;
211  }
212 
213  // Move over...
214  ++inputBuf;
215  ++outputBuf;
216 
217  } // End of loop in x direction.
218 
219  // Move down...
220  inputBuf += iw - ow;
221 
222  } // End of loop in y direction.
223 
224  } // End of band loop.
225 
226  theTile->validate();
227 
228  // Set up recursion for "dilation fill mode", we'll keep calling this getTile until all pixels
229  // are filled with non-null values:
230  if (theRecursiveFlag)
231  {
232  //cout << "Percent Full: "<<theTile->percentFull()<<endl; //###
233  //theTile->write("filtered.ras"); //###
234 
236  if (theNullFoundFlag)
237  {
238  theNullFoundFlag = false; // assume will fill, set true in next recursion if null found
240  doDilation(scalarType, theTempTile);
241  }
242  }
243 }
virtual ossim_uint32 getWidth() const
ossim_uint32 x
virtual ossim_uint32 getNumberOfBands() const
ossim_uint32 y
ossim_uint32 theWindowSize
Used for recursion when recursive fill enabled
const ossimIpt & ul() const
Definition: ossimIrect.h:274
virtual ossimDataObjectStatus getDataObjectStatus() const
virtual ossim_uint32 getHeight() const
ossimPolygon theValidImagePoly
virtual void loadTile(const void *src, const ossimIrect &src_rect, ossimInterleaveType il_type)
virtual ossimDataObjectStatus validate() const
unsigned int ossim_uint32
virtual const ossim_float64 * getNullPix() const
virtual ossimIrect getImageRectangle() const
T min(T a, T b)
Definition: ossimCommon.h:203
ossimRefPtr< ossimImageData > theTile
return status
bool isPointWithin(const ossimDpt &point) const
virtual const void * getBuf() const
void doDilation(T scalarType, ossimRefPtr< ossimImageData > &inputData)
ossimDataObjectStatus
Definitions for data object status.
ossimRefPtr< ossimImageData > theTempTile
int ossim_int32

◆ getProperty()

ossimRefPtr< ossimProperty > ossimDilationFilter::getProperty ( const ossimString name) const
virtual

Reimplemented from ossimImageSourceFilter.

Definition at line 268 of file ossimDilationFilter.cpp.

269 {
271  if (name == WINDOW_SIZE_KW)
272  {
273  prop = new ossimNumericProperty(WINDOW_SIZE_KW, ossimString::toString(theWindowSize), 3, 25);
274  prop->setCacheRefreshBit();
275  return prop;
276  }
277  else if (name == RECURSIVE_DILATION_KW)
278  {
279  prop = new ossimBooleanProperty(RECURSIVE_DILATION_KW, getRecursiveFlag());
280  prop->setFullRefreshBit();
281  return prop;
282  }
284 }
static ossimString toString(bool aValue)
Numeric to string methods.
ossim_uint32 theWindowSize
Used for recursion when recursive fill enabled
void setFullRefreshBit()
bool getRecursiveFlag() const
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
void setCacheRefreshBit()

◆ getPropertyNames()

void ossimDilationFilter::getPropertyNames ( std::vector< ossimString > &  propertyNames) const
virtual

Reimplemented from ossimImageSourceFilter.

Definition at line 286 of file ossimDilationFilter.cpp.

287 {
288  propertyNames.push_back(WINDOW_SIZE_KW);
289  propertyNames.push_back(RECURSIVE_DILATION_KW);
291 }
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const

◆ getRecursiveFlag()

bool ossimDilationFilter::getRecursiveFlag ( ) const
inline

Definition at line 41 of file ossimDilationFilter.h.

◆ getTile()

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

Reimplemented from ossimImageSource.

Definition at line 50 of file ossimDilationFilter.cpp.

References doDilation(), ossimImageData::dup(), ossimImageData::getBuf(), ossimImageData::getNumberOfBands(), ossimRectilinearDataObject::getScalarType(), ossimImageSource::getTile(), ossimImageSource::getValidImageVertices(), getWindowSize(), ossimSource::isSourceEnabled(), ossimIrect::lr(), OSSIM_CLOCKWISE_ORDER, OSSIM_FLOAT32, OSSIM_FLOAT64, OSSIM_NORMALIZED_DOUBLE, OSSIM_NORMALIZED_FLOAT, OSSIM_SINT16, OSSIM_UINT16, OSSIM_UINT32, OSSIM_UINT8, OSSIM_USHORT11, OSSIM_USHORT12, OSSIM_USHORT13, OSSIM_USHORT14, OSSIM_USHORT15, ossimNotify(), ossimNotifyLevel_WARN, ossimImageData::setImageRectangle(), ossimImageData::setImageRectangleAndBands(), theNullFoundFlag, theRecursiveFlag, theTile, theValidImagePoly, ossimIrect::ul(), ossimRefPtr< T >::valid(), ossimIpt::x, and ossimIpt::y.

52 {
53  if(!isSourceEnabled())
54  return ossimImageSourceFilter::getTile(rect, resLevel);
55 
57  if (theRecursiveFlag)
58  inputData = ossimImageSourceFilter::getTile(rect, resLevel);
59  else
60  {
61  ossim_uint32 halfSize = getWindowSize()>>1;
62  ossimIrect requestRect(rect.ul().x - halfSize,
63  rect.ul().y - halfSize,
64  rect.lr().x + halfSize,
65  rect.lr().y + halfSize);
66 
67  inputData = ossimImageSourceFilter::getTile(requestRect, resLevel);
68  }
69 
70  if(!inputData.valid() || !inputData->getBuf())
71  return inputData;
72 
73  vector<ossimIpt> viv;
76 
77  if(!theTile.valid())
78  {
79  theTile = (ossimImageData*)inputData->dup();
81  }
82  else
83  {
85  }
86 
87  theNullFoundFlag = false;
88  switch(inputData->getScalarType())
89  {
90  case OSSIM_UINT8:
91  doDilation(ossim_uint8(0), inputData);
92  break;
93  case OSSIM_USHORT11:
94  case OSSIM_USHORT12:
95  case OSSIM_USHORT13:
96  case OSSIM_USHORT14:
97  case OSSIM_USHORT15:
98  case OSSIM_UINT16:
99  doDilation(ossim_uint16(0), inputData);
100  break;
101  case OSSIM_SINT16:
102  doDilation(ossim_sint16(0), inputData);
103  break;
104  case OSSIM_UINT32:
105  doDilation(ossim_uint32(0), inputData);
106  break;
107  case OSSIM_FLOAT32:
109  doDilation(ossim_float32(0), inputData);
110  break;
111  case OSSIM_FLOAT64:
113  doDilation(ossim_float64(0), inputData);
114  break;
115  default:
116  {
118  << "ossimDilationFilter::applyFilter WARNING:\n"
119  << "Unhandled scalar type!" << endl;
120  }
121  }
122  return theTile;
123 }
16 bit unsigned integer (15 bits used)
virtual bool isSourceEnabled() const
Definition: ossimSource.cpp:79
virtual ossim_uint32 getNumberOfBands() const
64 bit floating point
virtual void setImageRectangle(const ossimIrect &rect)
16 bit unsigned integer
bool valid() const
Definition: ossimRefPtr.h:75
float ossim_float32
16 bit signed integer
const ossimIpt & ul() const
Definition: ossimIrect.h:274
16 bit unsigned integer (14 bits used)
16 bit unsigned integer (13 bits used)
32 bit floating point
unsigned short ossim_uint16
ossimPolygon theValidImagePoly
32 bit unsigned integer
virtual ossimObject * dup() const
double ossim_float64
signed short ossim_sint16
virtual void setImageRectangleAndBands(const ossimIrect &rect, ossim_uint32 numberOfBands)
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.
unsigned int ossim_uint32
32 bit normalized floating point
const ossimIpt & lr() const
Definition: ossimIrect.h:276
ossimRefPtr< ossimImageData > theTile
virtual ossimScalarType getScalarType() const
64 bit normalized floating point
16 bit unsigned integer (11 bits used)
ossim_int32 y
Definition: ossimIpt.h:142
virtual const void * getBuf() const
void doDilation(T scalarType, ossimRefPtr< ossimImageData > &inputData)
ossim_int32 x
Definition: ossimIpt.h:141
8 bit unsigned integer
ossim_uint32 getWindowSize() const
unsigned char ossim_uint8
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)
16 bit unsigned integer (12 bits used)

◆ getWindowSize()

ossim_uint32 ossimDilationFilter::getWindowSize ( ) const
inline

Definition at line 34 of file ossimDilationFilter.h.

Referenced by getTile().

34 { return theWindowSize; }
ossim_uint32 theWindowSize
Used for recursion when recursive fill enabled

◆ initialize()

void ossimDilationFilter::initialize ( )
virtual

Reimplemented from ossimImageSourceFilter.

Definition at line 44 of file ossimDilationFilter.cpp.

References ossimImageSourceFilter::initialize(), and theTile.

45 {
47  theTile = NULL;
48 }
ossimRefPtr< ossimImageData > theTile

◆ loadState()

bool ossimDilationFilter::loadState ( const ossimKeywordlist kwl,
const char *  prefix = 0 
)
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 300 of file ossimDilationFilter.cpp.

References ossimKeywordlist::find().

301 {
302  const char* lookup = kwl.find(prefix, WINDOW_SIZE_KW.c_str());
303  if (lookup)
304  theWindowSize = ossimString(lookup).toUInt32();
305 
306  lookup = kwl.find(prefix, RECURSIVE_DILATION_KW.c_str());
307  if (lookup)
308  setRecursiveFlag(ossimString(lookup).toBool());
309 
310  return ossimImageSourceFilter::loadState(kwl, prefix);
311 }
const char * find(const char *key) const
ossim_uint32 theWindowSize
Used for recursion when recursive fill enabled
ossim_uint32 toUInt32() const
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
void setRecursiveFlag(bool flag=true)
Set if getTile is to be called recursively until all pixels have been assigned non-null.
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

◆ saveState()

bool ossimDilationFilter::saveState ( ossimKeywordlist kwl,
const char *  prefix = 0 
) 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 293 of file ossimDilationFilter.cpp.

References ossimKeywordlist::add().

294 {
295  kwl.add(prefix, WINDOW_SIZE_KW.c_str(), theWindowSize, true);
296  kwl.add(prefix, RECURSIVE_DILATION_KW.c_str(), (theRecursiveFlag?"true":"false"), true);
297  return ossimImageSourceFilter::saveState(kwl, prefix);
298 }
ossim_uint32 theWindowSize
Used for recursion when recursive fill enabled
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
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

◆ setProperty()

void ossimDilationFilter::setProperty ( ossimRefPtr< ossimProperty property)
virtual

Reimplemented from ossimImageSourceFilter.

Definition at line 245 of file ossimDilationFilter.cpp.

References ossimRefPtr< T >::valid().

246 {
247  if (!property.valid())
248  return;
249 
250  ossimString name = property->getName();
251 
252  if (name == WINDOW_SIZE_KW)
253  {
254  theWindowSize = property->valueToString().toUInt32();
255  }
256  else if (name == RECURSIVE_DILATION_KW)
257  {
258  ossimString value;
259  property->valueToString(value);
260  setRecursiveFlag(value.toBool());
261  }
262  else
263  {
265  }
266 }
virtual void setProperty(ossimRefPtr< ossimProperty > property)
bool valid() const
Definition: ossimRefPtr.h:75
ossim_uint32 theWindowSize
Used for recursion when recursive fill enabled
bool toBool() const
String to numeric methods.
void setRecursiveFlag(bool flag=true)
Set if getTile is to be called recursively until all pixels have been assigned non-null.

◆ setRecursiveFlag()

void ossimDilationFilter::setRecursiveFlag ( bool  flag = true)
inline

Set if getTile is to be called recursively until all pixels have been assigned non-null.

This is only valid for "fill null" modes.

Definition at line 40 of file ossimDilationFilter.h.

◆ setWindowSize()

void ossimDilationFilter::setWindowSize ( ossim_uint32  windowSize)
inline

Size of resampling kernel width & height.

Definition at line 33 of file ossimDilationFilter.h.

33 { theWindowSize = windowSize; }
ossim_uint32 theWindowSize
Used for recursion when recursive fill enabled

Member Data Documentation

◆ theNullFoundFlag

bool ossimDilationFilter::theNullFoundFlag
protected

Definition at line 67 of file ossimDilationFilter.h.

Referenced by doDilation(), and getTile().

◆ theRecursiveFlag

bool ossimDilationFilter::theRecursiveFlag
protected

Definition at line 65 of file ossimDilationFilter.h.

Referenced by doDilation(), and getTile().

◆ theTempTile

ossimRefPtr<ossimImageData> ossimDilationFilter::theTempTile
protected

Definition at line 63 of file ossimDilationFilter.h.

Referenced by doDilation().

◆ theTile

ossimRefPtr<ossimImageData> ossimDilationFilter::theTile
protected

Definition at line 62 of file ossimDilationFilter.h.

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

◆ theValidImagePoly

ossimPolygon ossimDilationFilter::theValidImagePoly
protected

Definition at line 66 of file ossimDilationFilter.h.

Referenced by doDilation(), and getTile().

◆ theWindowSize

ossim_uint32 ossimDilationFilter::theWindowSize
protected

Used for recursion when recursive fill enabled

Definition at line 64 of file ossimDilationFilter.h.

Referenced by doDilation().


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