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

Class to scan pixels and flip target dn value to a replacement dn value. More...

#include <ossimPixelFlipper.h>

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

Public Types

enum  ReplacementMode {
  REPLACE_BAND_IF_TARGET = 0, REPLACE_BAND_IF_PARTIAL_TARGET = 1, REPLACE_ALL_BANDS_IF_PARTIAL_TARGET = 2, REPLACE_ONLY_FULL_TARGETS = 3,
  REPLACE_ALL_BANDS_IF_ANY_TARGET = 4
}
 Target Replacement Mode: More...
 
enum  ClampingMode { DISABLED = 0, CLAMPING_LO = 1, CLAMPING_HI = 2, CLAMPING_LO_AND_HI = 3 }
 When either a lo and/or hi clamp value is set, the clamping mode will be enabled accordingly and override any target replacement defined. More...
 
enum  ClipMode { NONE = 0, BOUNDING_RECT = 1, VALID_VERTICES = 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

 ossimPixelFlipper (ossimObject *owner=NULL)
 default constructor More...
 
virtual ossimString getShortName () const
 
virtual void initialize ()
 Initializes the state of the object from theInputConnection. More...
 
virtual ossimRefPtr< ossimImageDatagetTile (const ossimIrect &tile_rect, ossim_uint32 resLevel=0)
 
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...
 
virtual ossimScalarType getOutputScalarType () const
 This will be used to query the output pixel type of the tile source. More...
 
virtual ossim_float64 getMaxPixelValue (ossim_uint32 band=0) const
 Returns the max pixel of the band. More...
 
virtual ossim_float64 getMinPixelValue (ossim_uint32 band=0) const
 Returns the min pixel of the band. More...
 
virtual std::ostream & print (std::ostream &out) const
 Outputs theErrorStatus as an ossimErrorCode and an ossimString. More...
 
void setTargetValue (ossim_float64 target_value)
 
void setTargetRange (ossim_float64 target_min, ossim_float64 target_max)
 Instead of a single value for a target, this method allows for specifying a range of values to flip to the replacement. More...
 
void setReplacementValue (ossim_float64 replacement_value)
 
void setClampValue (ossim_float64 clamp_value, bool is_high_clamp_value=true)
 
void setClampValues (ossim_float64 clamp_value_lo, ossim_float64 clamp_value_hi)
 
void setReplacementMode (ossimPixelFlipper::ReplacementMode mode)
 
bool setReplacementMode (const ossimString &modeString)
 Accepts a string that must match the enumerator's label (can be lower case) and sets the replacement mode accordingly. More...
 
void setClipMode (const ossimString &modeString)
 Clipping here refers to bounding rect or valid polygon (spacial) clipping, where all pixels outside the valid area are mapped to the replacement value. More...
 
void setClipMode (ClipMode mode)
 
ossim_float64 getReplacementValue () const
 
ossimPixelFlipper::ReplacementMode getReplacementMode () const
 
ossimString getReplacementModeString () const
 
ossimString getClipModeString () const
 
ClipMode getClipMode () const
 
virtual ossimRefPtr< ossimPropertygetProperty (const ossimString &name) const
 
virtual void setProperty (ossimRefPtr< ossimProperty > property)
 
virtual void getPropertyNames (std::vector< ossimString > &propertyNames) const
 
- 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 ossim_uint32 getTileWidth () const
 Returns the default processing tile width. More...
 
virtual ossim_uint32 getTileHeight () const
 Returns the default processing tile height. More...
 
virtual double getNullPixelValue (ossim_uint32 band=0) const
 Each band has a null pixel associated with it. More...
 
virtual ossimIrect getBoundingRect (ossim_uint32 resLevel=0) const
 This will return the bounding rect of the source. More...
 
virtual void getBoundingRect (ossimIrect &rect, ossim_uint32 resLevel=0) const
 Gets the bounding rectangle of the source. More...
 
virtual void getValidImageVertices (std::vector< ossimIpt > &validVertices, ossimVertexOrdering ordering=OSSIM_CLOCKWISE_ORDER, ossim_uint32 resLevel=0) const
 ordering specifies how the vertices should be arranged. More...
 
virtual ossimRefPtr< ossimImageGeometrygetImageGeometry ()
 Returns the image geometry object associated with this tile source or NULL if not defined. More...
 
virtual void setImageGeometry (const ossimImageGeometry *geom)
 Default implementation sets geometry of the first input to the geometry specified. More...
 
virtual void saveImageGeometry () const
 Default method to call input's saveImageGeometry. More...
 
virtual void saveImageGeometry (const ossimFilename &geometry_file) const
 Default method to call input's saveImageGeometry. More...
 
virtual bool isIndexedData () const
 
- Public Member Functions inherited from ossimSource
 ossimSource (ossimObject *owner=0)
 
 ossimSource (ossimObject *owner, ossim_uint32 inputListSize, ossim_uint32 outputListSize, bool inputListIsFixedFlag=true, bool outputListIsFixedFlag=true)
 
virtual ~ossimSource ()
 
virtual bool isSourceEnabled () const
 
virtual void enableSource ()
 
virtual void disableSource ()
 
virtual bool getEnableFlag () const
 
virtual void setEnableFlag (bool flag)
 
virtual bool isInitialized () const
 
virtual void setInitializedFlag (bool flag)
 
- Public Member Functions inherited from ossimConnectableObject
 ossimConnectableObject (ossimObject *owner=0)
 Base constructor of this object. More...
 
 ossimConnectableObject (ossimObject *owner, ossim_int32 inputListSize, ossim_int32 outputListSize, bool inputListIsFixedFlag=true, bool outputListIsFixedFlag=true)
 
virtual ~ossimConnectableObject ()
 
void setId (const ossimId &id)
 All connectable objects will have id's. More...
 
const ossimIdgetId () const
 Will allow us to get this object's id. More...
 
const ossimObjectgetOwner () const
 Fetches the current owner, most likely a container but not limited to one. More...
 
virtual void changeOwner (ossimObject *owner)
 Permits changing the object's owner. More...
 
virtual void setDescription (const ossimString &description)
 
virtual ossimString getDescription () const
 
virtual bool isConnected (ossimConnectableObjectDirectionType direction=CONNECTABLE_DIRECTION_INPUT) const
 will check the direction specified to see if all slots are full. More...
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findConnectableObject(const ossimId &id))
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findObjectOfType(RTTItypeid typeId, ossimConnectableObjectDirectionType directionType, bool recurse=true))
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findObjectOfType(const ossimString &obj, ossimConnectableObjectDirectionType directionType, bool recurse=true))
 
 OSSIM_DEPRECATE_METHOD (virtual ossimConnectableObject *findInputObjectOfType(const ossimString &className))
 
virtual ossim_int32 findInputIndex (const ossimConnectableObject *object)
 Return a valid index of the input list if the passed in object is found else return -1. More...
 
virtual ossim_int32 findInputIndex (const ossimId &id)
 Return a valid index of the input list if the passed id is found else return -1. More...
 
virtual ossim_int32 findOutputIndex (const ossimConnectableObject *object)
 Return a valid index of the output list if the passed in object is found else return -1. More...
 
virtual ossim_int32 findOutputIndex (const ossimId &id)
 Return a valid index of the output list if the passed in object is found else return -1. More...
 
virtual ossim_int32 getMyInputIndexToConnectTo (ossimConnectableObject *object) const
 Should return the first available index to connect to. More...
 
virtual ossim_int32 getMyOutputIndexToConnectTo (ossimConnectableObject *object) const
 Should return the first available index to connect to. More...
 
virtual bool canConnectMyOutputTo (ossim_int32 myOutputIndex, const ossimConnectableObject *object) const
 default implementation is to allow anyone to connect to us. More...
 
virtual void disconnect (ossimConnectableObject *object=0)
 Will disconnect the object passed in. More...
 
virtual void disconnect (const ossimId &id)
 Will disconnect the object passed in. More...
 
virtual ossimRefPtr< ossimConnectableObjectdisconnectMyInput (ossim_int32 inputIndex, bool disconnectOutputFlag=true, bool createEventFlag=true)
 Will disconnect the object at the given input index and generate a connection event. More...
 
virtual void disconnectMyInput (ossimConnectableObject *input, bool disconnectOutputFlag=true, bool createEventFlag=true)
 Finds the index of the passed in input and calls disconnectMyInput(inputIndex, disconnectOutputFlag, createEventFlag);. More...
 
virtual void disconnectMyInputs (ConnectableObjectList &inputList, bool disconnectOutputFlag=true, bool createEventFlag=true)
 
virtual ossimRefPtr< ossimConnectableObjectdisconnectMyOutput (ossim_int32 outputIndex, bool disconnectInputFlag=true, bool createEventFlag=true)
 Will disconnect the object at the given output index and generate a connection event. More...
 
virtual void disconnectMyOutput (ossimConnectableObject *output, bool disconnectInputFlag=true, bool createEventFlag=true)
 Will disconnect the output object. More...
 
virtual void disconnectMyOutputs (ConnectableObjectList &outputList, bool disconnectOutputFlag=true, bool createEventFlag=true)
 
virtual void disconnectAllInputs ()
 Will disconnect all of the input objects. More...
 
virtual void disconnectAllOutputs ()
 Will disconnect all of the output objects. More...
 
virtual ossim_int32 connectMyInputTo (ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
 Will try to connect this objects input to the passed in object. More...
 
virtual ossim_int32 connectMyInputTo (ossim_int32 inputIndex, ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
 Will connect the specified input to the passed in object. More...
 
virtual bool connectMyInputTo (ConnectableObjectList &inputList, bool makeOutputConnection=true, bool createEventFlag=true)
 
virtual ossim_int32 connectMyOutputTo (ossimConnectableObject *outputObject, bool makeInputConnection=true, bool createEventFlag=true)
 Will try to connect this objects output to the passed in object. More...
 
virtual bool connectMyOutputTo (ConnectableObjectList &outputList, bool makeInputConnection=true, bool createEventFlag=true)
 
virtual bool connectInputList (ConnectableObjectList &inputList)
 Will disconnect itself from all inputs and reset to the passed in input list. More...
 
virtual bool connectOutputList (ConnectableObjectList &outputList)
 Will disconnect itself from all outputs and reset to the passed in output list. More...
 
virtual ossim_uint32 getNumberOfInputs () const
 Returns the number of input objects. More...
 
virtual ossim_uint32 getNumberOfOutputs () const
 Return the number of output objects. More...
 
ossimConnectableObjectgetInput (ossim_uint32 index=0)
 returns the object at the specified index. More...
 
const ossimConnectableObjectgetInput (ossim_uint32 index=0) const
 returns the object at the specified index. More...
 
ossimConnectableObjectgetOutput (ossim_uint32 index=0)
 returns the object at the specified index. More...
 
const ossimConnectableObjectgetOutput (ossim_uint32 index=0) const
 returns the object at the specified index. More...
 
virtual void setNumberOfInputs (ossim_int32 numberOfInputs)
 Will set the number of inputs. More...
 
virtual bool getInputListIsFixedFlag () const
 
virtual bool getOutputListIsFixedFlag () const
 
virtual void setNumberOfOutputs (ossim_int32 numberOfInputs)
 Will set the number of outputs. More...
 
const ConnectableObjectListgetInputList () const
 
const ConnectableObjectListgetOutputList () const
 
ConnectableObjectListgetInputList ()
 
ConnectableObjectListgetOutputList ()
 
 OSSIM_DEPRECATE_METHOD (virtual void findAllObjectsOfType(ConnectableObjectList &result, const RTTItypeid &typeInfo, bool recurse=true))
 
 OSSIM_DEPRECATE_METHOD (virtual void findAllObjectsOfType(ConnectableObjectList &result, const ossimString &className, bool recurse=true))
 
virtual void propagateEventToOutputs (ossimEvent &event)
 
virtual void propagateEventToInputs (ossimEvent &event)
 
virtual void setProperty (const ossimString &name, const ossimString &value)
 
virtual ossim_uint32 saveStateOfAllInputs (ossimKeywordlist &kwl, bool saveThisStateFlag=true, ossim_uint32 objectIndex=1, const char *prefix=0) const
 Save the state of all inputs to a keyword list. More...
 
virtual bool fillContainer (ossimConnectableContainer &container)
 Inserts this object and all of its children and inputs into the container provided. More...
 
bool moveInputUp (const ossimId &id)
 Moves the input connection matching id up one in the connection list. More...
 
bool moveInputDown (const ossimId &id)
 Moves the input connection matching id down one in the connection list. More...
 
bool moveInputToTop (const ossimId &id)
 Moves the input connection matching id to the top of the connection list. More...
 
bool moveInputToBottom (const ossimId &id)
 Moves the input connection matching id to the bottom of the connection list. More...
 
virtual void accept (ossimVisitor &visitor)
 We will add a visitor interface for all connectable objects. More...
 
- Public Member Functions inherited from ossimObject
 ossimObject ()
 
virtual ~ossimObject ()
 
virtual ossimObjectdup () const
 
virtual 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
 

Static Public Attributes

static const char PF_TARGET_VALUE_KW [] = "target_value"
 
static const char PF_TARGET_RANGE_KW [] = "target_range"
 
static const char PF_REPLACEMENT_VALUE_KW [] = "replacement_value"
 
static const char PF_REPLACEMENT_MODE_KW [] = "replacement_mode"
 
static const char PF_CLAMP_VALUE_KW [] = "clamp_value"
 
static const char PF_CLAMP_VALUE_LO_KW [] = "clamp_value_lo"
 
static const char PF_CLAMP_VALUE_HI_KW [] = "clamp_value_hi"
 
static const char PF_CLIP_MODE_KW [] = "border_clip_mode"
 

Protected Member Functions

virtual ~ossimPixelFlipper ()
 destructor More...
 
template<class T >
void flipPixels (T dummy, ossimImageData *inpuTile, ossim_uint32 resLevel)
 This object can be used outside of an image chain for offline processing of existing tile. More...
 
template<class T >
void clipTile (T dummy, ossimImageData *inpuTile, ossim_uint32 resLevel)
 
bool inRange (ossim_float64 value) const
 Verifies pixel is in range. More...
 
void allocateClipTileBuffer (ossimRefPtr< ossimImageData > inputImage)
 
- 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

ossim_float64 theTargetValueLo
 The value range to replace. More...
 
ossim_float64 theTargetValueHi
 
ossim_float64 theReplacementValue
 When target values are defined, this is the value the pixel will assume if the pixel falls within the target range (according to the rules for replacement mode) More...
 
ReplacementMode theReplacementMode
 See documentation for ReplacementMode enum above. More...
 
ossim_float64 theClampValueLo
 The range of desired pixel values. More...
 
ossim_float64 theClampValueHi
 
ClampingMode theClampingMode
 
ClipMode theClipMode
 Border Clip mode. More...
 
std::recursive_mutex theMutex
 For lock and unlock. More...
 
std::vector< ossimPolygontheValidVertices
 
std::vector< ossimIrecttheBoundingRects
 
ossimRefPtr< ossimImageDatatheClipTileBuffer
 
- 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

Class to scan pixels and flip target dn value to a replacement dn value.

This was written to fix problems with null pixels, i.e. an image has a digital number(dn) of 255 for null and it is desired to use a dn of 0 as a null. This can really be used to flip any pixel value to another.

Note
This filter currently works on the input tile directly and does not copy the data.
See also
theReplacementMode data member documentation for more info.

Definition at line 37 of file ossimPixelFlipper.h.

Member Enumeration Documentation

◆ ClampingMode

When either a lo and/or hi clamp value is set, the clamping mode will be enabled accordingly and override any target replacement defined.

Enumerator
DISABLED 
CLAMPING_LO 
CLAMPING_HI 
CLAMPING_LO_AND_HI 

Definition at line 94 of file ossimPixelFlipper.h.

◆ ClipMode

Enumerator
NONE 
BOUNDING_RECT 
VALID_VERTICES 

Definition at line 102 of file ossimPixelFlipper.h.

◆ ReplacementMode

Target Replacement Mode:

Examples given for 3-band pixel values as (R, G, B) with target = 0, and replacement = 1

If mode is REPLACE_BAND_IF_TARGET (default): Any pixel band with value of target will be replaced. (0, 0, 0) becomes (1, 1, 1) (0, 3, 2) becomes (1, 3, 2)

If mode is REPLACE_BAND_IF_PARTIAL_TARGET: A band with target value will be replaced only if at least one other band in the pixel does not have the target. (0, 0, 0) remains (0, 0, 0) (0, 3, 2) becomes (1, 3, 2)

If mode is REPLACE_ALL_BANDS_IF_PARTIAL_TARGET: All bands of the pixel will be replaced if any but not all bands in the pixel have the target value. (0, 0, 0) remains (0, 0, 0) (0, 3, 2) becomes (1, 1, 1)

If mode is REPLACE_ONLY_FULL_TARGETS: All bands in the pixel will be replaced only if they all have the target. (0, 0, 0) becomes (1, 1, 1) (0, 3, 2) remains (0, 3, 2)

If mode is REPLACE_ALL_BANDS_IF_ANY_TARGET: All bands in the pixel will be replaced if even one band has the target. (0, 0, 0) becomes (1, 1, 1) (0, 3, 2) remains (1, 1, 1)

Enumerator
REPLACE_BAND_IF_TARGET 
REPLACE_BAND_IF_PARTIAL_TARGET 
REPLACE_ALL_BANDS_IF_PARTIAL_TARGET 
REPLACE_ONLY_FULL_TARGETS 
REPLACE_ALL_BANDS_IF_ANY_TARGET 

Definition at line 81 of file ossimPixelFlipper.h.

Constructor & Destructor Documentation

◆ ossimPixelFlipper()

ossimPixelFlipper::ossimPixelFlipper ( ossimObject owner = NULL)

default constructor

Definition at line 43 of file ossimPixelFlipper.cpp.

44  : ossimImageSourceFilter(owner),
45  theTargetValueLo(0.0),
46  theTargetValueHi(0.0),
53 {
54  if (traceDebug())
55  {
57  << "ossimPixelFlipper::ossimPixelFlipper entered...\n";
58 #ifdef OSSIM_ID_ENABLED
60  << "OSSIM_ID: " << OSSIM_ID << "\n";
61 #endif
62  }
63 
64  setDescription(ossimString("Pixel Flipper"));
65  enableSource();
66 }
virtual void setDescription(const ossimString &description)
ossim_float64 theReplacementValue
When target values are defined, this is the value the pixel will assume if the pixel falls within the...
ClipMode theClipMode
Border Clip mode.
ReplacementMode theReplacementMode
See documentation for ReplacementMode enum above.
ossimImageSourceFilter(ossimObject *owner=NULL)
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
ossim_float64 theTargetValueLo
The value range to replace.
ossim_float64 theTargetValueHi
virtual void enableSource()
Definition: ossimSource.cpp:84
ClampingMode theClampingMode
ossim_float64 theClampValueHi
ossim_float64 theClampValueLo
The range of desired pixel values.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ ~ossimPixelFlipper()

ossimPixelFlipper::~ossimPixelFlipper ( )
protectedvirtual

destructor

Definition at line 68 of file ossimPixelFlipper.cpp.

69 {
70 }

Member Function Documentation

◆ allocateClipTileBuffer()

void ossimPixelFlipper::allocateClipTileBuffer ( ossimRefPtr< ossimImageData inputImage)
protected

Definition at line 543 of file ossimPixelFlipper.cpp.

References ossimImageData::dup(), ossimImageData::getImageRectangle(), ossimImageData::getNumberOfBands(), ossimRectilinearDataObject::getScalarType(), ossimImageData::setImageRectangle(), theClipTileBuffer, and ossimRefPtr< T >::valid().

Referenced by clipTile().

544 {
545  if (inputImage.valid())
546  {
547  bool needDupFlag = false;
548  if (theClipTileBuffer.valid())
549  {
550  if ((theClipTileBuffer->getScalarType() != inputImage->getScalarType()) ||
552  {
553  needDupFlag = true;
554  }
555  else
556  {
558  }
559  }
560  else
561  {
562  needDupFlag = true;
563  }
564  if (needDupFlag)
565  {
566  theClipTileBuffer = (ossimImageData *)inputImage->dup();
567  }
568  }
569 }
virtual ossim_uint32 getNumberOfBands() const
virtual void setImageRectangle(const ossimIrect &rect)
bool valid() const
Definition: ossimRefPtr.h:75
virtual ossimObject * dup() const
virtual ossimIrect getImageRectangle() const
virtual ossimScalarType getScalarType() const
ossimRefPtr< ossimImageData > theClipTileBuffer

◆ clipTile()

template<class T >
void ossimPixelFlipper::clipTile ( dummy,
ossimImageData inpuTile,
ossim_uint32  resLevel 
)
protected

Definition at line 425 of file ossimPixelFlipper.cpp.

References allocateClipTileBuffer(), BOUNDING_RECT, ossimIrect::clipToRect(), ossimIrect::completely_within(), ossimRefPtr< T >::get(), ossimImageData::getBuf(), ossimDataObject::getDataObjectStatus(), ossimImageData::getHeight(), ossimImageData::getImageRectangle(), ossimImageData::getWidth(), ossimIrect::intersects(), ossimPolygon::isPointWithin(), ossimIrect::ll(), ossimImageData::loadTile(), ossimIrect::lr(), ossimImageData::makeBlank(), NONE, OSSIM_EMPTY, OSSIM_FULL, ossimDataObject::setDataObjectStatus(), ossimImageData::setImageRectangle(), ossimImageData::setNull(), theBoundingRects, theClipMode, theClipTileBuffer, theValidVertices, ossimIrect::ul(), ossimIrect::ur(), ossimRefPtr< T >::valid(), VALID_VERTICES, ossimImageData::validate(), ossimIpt::x, x, ossimIpt::y, and y.

428 {
429  if (theClipMode == NONE)
430  {
431  theClipTileBuffer = 0;
432  return;
433  }
434  if (!inputTile)
435  return;
436  if (!inputTile->getBuf() ||
437  (inputTile->getDataObjectStatus() == OSSIM_EMPTY))
438  {
439  return;
440  }
441  allocateClipTileBuffer(inputTile);
442 
443  if (theClipTileBuffer.valid())
444  {
445  ossimIrect tileRect = inputTile->getImageRectangle();
446  // force to all nulls
449 
450  switch (theClipMode)
451  {
452  case NONE:
453  {
454  break;
455  }
456  case BOUNDING_RECT:
457  {
458  if (resLevel < theBoundingRects.size())
459  {
460  if (tileRect.completely_within(theBoundingRects[resLevel]) ||
461  theBoundingRects[resLevel].hasNans())
462  {
463  return;
464  }
465  else
466  {
467  if (tileRect.intersects(theBoundingRects[resLevel]))
468  {
469  ossimIrect clipRect = tileRect.clipToRect(theBoundingRects[resLevel]);
470 
472 
473  theClipTileBuffer->loadTile(inputTile);
474  inputTile->makeBlank();
475  inputTile->loadTile(theClipTileBuffer.get());
476  inputTile->validate();
477  }
478  else
479  {
480  inputTile->makeBlank();
481  }
482  }
483  }
484  break;
485  }
486  case VALID_VERTICES:
487  {
488  if (resLevel < theValidVertices.size())
489  {
490  const ossimPolygon &p = theValidVertices[resLevel];
491  bool ulWithin = p.isPointWithin(tileRect.ul());
492  bool urWithin = p.isPointWithin(tileRect.ur());
493  bool lrWithin = p.isPointWithin(tileRect.lr());
494  bool llWithin = p.isPointWithin(tileRect.ll());
495 
496  if (ulWithin &&
497  urWithin &&
498  lrWithin &&
499  llWithin)
500  {
501  return;
502  }
503  else if (!(ulWithin || // if none are in
504  urWithin ||
505  lrWithin ||
506  llWithin))
507  {
508  inputTile->makeBlank();
509  return;
510  }
511  else
512  {
513  ossimIpt ul = tileRect.ul();
514  ossimIpt origin;
515  ossim_uint32 x = 0;
516  ossim_uint32 y = 0;
517  ossim_uint32 w = inputTile->getWidth();
518  ossim_uint32 h = inputTile->getHeight();
519  ossim_uint32 offset = 0;
520  origin.y = ul.y;
521  for (y = 0; y < h; ++y)
522  {
523  origin.x = ul.x;
524  for (x = 0; x < w; ++x)
525  {
526  if (!p.isPointWithin(origin))
527  {
528  inputTile->setNull(offset);
529  }
530  ++offset;
531  ++origin.x;
532  }
533  ++origin.y;
534  }
535  }
536  }
537  break;
538  }
539  }
540  }
541 }
ossim_uint32 x
virtual void setImageRectangle(const ossimIrect &rect)
ClipMode theClipMode
Border Clip mode.
ossim_uint32 y
bool valid() const
Definition: ossimRefPtr.h:75
const ossimIpt & ul() const
Definition: ossimIrect.h:274
bool intersects(const ossimIrect &rect) const
Definition: ossimIrect.cpp:183
const ossimIpt & ll() const
Definition: ossimIrect.h:277
bool completely_within(const ossimIrect &rect) const
Definition: ossimIrect.cpp:425
virtual void loadTile(const void *src, const ossimIrect &src_rect, ossimInterleaveType il_type)
void allocateClipTileBuffer(ossimRefPtr< ossimImageData > inputImage)
unsigned int ossim_uint32
const ossimIpt & lr() const
Definition: ossimIrect.h:276
ossimIrect clipToRect(const ossimIrect &rect) const
Definition: ossimIrect.cpp:501
const ossimIpt & ur() const
Definition: ossimIrect.h:275
virtual void makeBlank()
Initializes data to null pixel values.
ossim_int32 y
Definition: ossimIpt.h:142
bool isPointWithin(const ossimDpt &point) const
virtual void setDataObjectStatus(ossimDataObjectStatus status) const
Full list found in ossimConstants.h.
ossim_int32 x
Definition: ossimIpt.h:141
ossimRefPtr< ossimImageData > theClipTileBuffer
std::vector< ossimIrect > theBoundingRects
std::vector< ossimPolygon > theValidVertices

◆ flipPixels()

template<class T >
void ossimPixelFlipper::flipPixels ( dummy,
ossimImageData inpuTile,
ossim_uint32  resLevel 
)
protected

This object can be used outside of an image chain for offline processing of existing tile.

Definition at line 158 of file ossimPixelFlipper.cpp.

References BOUNDING_RECT, ossimIrect::completely_within(), ossimImageData::getBuf(), ossimImageData::getImageRectangle(), ossimImageData::getNumberOfBands(), ossimIrect::intersects(), ossim::isnan(), ossimIrect::ll(), ossimIrect::lr(), REPLACE_ALL_BANDS_IF_ANY_TARGET, REPLACE_ALL_BANDS_IF_PARTIAL_TARGET, REPLACE_BAND_IF_PARTIAL_TARGET, REPLACE_BAND_IF_TARGET, REPLACE_ONLY_FULL_TARGETS, theBoundingRects, theClampingMode, theClampValueHi, theClampValueLo, theClipMode, theReplacementMode, theReplacementValue, theTargetValueHi, theTargetValueLo, theValidVertices, ossimIrect::ul(), ossimIrect::ur(), VALID_VERTICES, ossimImageData::validate(), ossimIpt::x, and ossimIpt::y.

Referenced by getTile().

161 {
162  if (!inputTile)
163  return;
164 
165  T targetLo = static_cast<T>(theTargetValueLo);
166  T targetHi = static_cast<T>(theTargetValueHi);
167  T replacement = static_cast<T>(theReplacementValue);
168  T clampLo = static_cast<T>(theClampValueLo);
169  T clampHi = static_cast<T>(theClampValueHi);
170 
171  // Get pointers to data for each band.
172  ossim_uint32 bands = inputTile->getNumberOfBands();
173  ossim_uint32 band;
174  T **buf = new T *[bands];
175  for (band = 0; band < bands; ++band)
176  buf[band] = static_cast<T *>(inputTile->getBuf(band));
177 
178  ossimIrect rect = inputTile->getImageRectangle();
179  ossimIpt ul = rect.ul();
180  ossimIpt lr = rect.lr();
181 
182  // Check the relation between tile rect and the area of interest (either bounding rect or
183  // valid vertices polygons). If completely outside, we can return with empty buffer.get If
184  // partially inside, we'll need to test individual pixels.
185  bool is_outside_aoi = false;
186  bool needsTesting = false;
187  if ((theClipMode == BOUNDING_RECT) && (resLevel < theBoundingRects.size()))
188  {
189  if (!rect.intersects(theBoundingRects[resLevel]))
190  is_outside_aoi = true;
191  else
192  needsTesting = !rect.completely_within(theBoundingRects[resLevel]);
193  }
194  else if ((theClipMode == VALID_VERTICES) && (resLevel < theValidVertices.size()))
195  {
196  bool ulFlag = theValidVertices[resLevel].isPointWithin(rect.ul());
197  bool urFlag = theValidVertices[resLevel].isPointWithin(rect.ur());
198  bool lrFlag = theValidVertices[resLevel].isPointWithin(rect.lr());
199  bool llFlag = theValidVertices[resLevel].isPointWithin(rect.ll());
200  if ((!ulFlag) && (!urFlag) && (!lrFlag) && (!llFlag))
201  is_outside_aoi = true;
202  else
203  needsTesting = !(ulFlag && urFlag && lrFlag && llFlag);
204  }
205  if (is_outside_aoi)
206  {
207  // none of the tile is inside so just return with empty tile:
208  delete[] buf;
209  return;
210  }
211 
212  ossim_uint32 i = 0; // index into band buffers;
213  ossimIpt pixel_loc;
214  bool can_replace, found_candidate;
215 
216  // Begin loop over each pixel in the tile. The individual bands are handled inside this loop:
217  for (pixel_loc.y = ul.y; pixel_loc.y <= lr.y; ++pixel_loc.y)
218  {
219  for (pixel_loc.x = ul.x; pixel_loc.x <= lr.x; ++pixel_loc.x)
220  {
221  // First consider if we need to test the pixel for border clipping:
222  if (needsTesting)
223  {
224  bool is_inside = true; // Assume it will pass the border test
225  if (theClipMode == BOUNDING_RECT)
226  is_inside = theBoundingRects[resLevel].pointWithin(pixel_loc);
227  else if (theClipMode == VALID_VERTICES)
228  is_inside = theValidVertices[resLevel].isPointWithin(pixel_loc);
229 
230  if (!is_inside)
231  {
232  // Remap this pixel to the replacement value (all bands)
233  for (band = 0; band < bands; ++band)
234  buf[band][i] = replacement;
235 
236  // Proceed to next pixel location:
237  ++i;
238  continue;
239  }
240  }
241 
242  // If clamping specified, the target replacement function is disabled:
243  if (theClampingMode)
244  {
245  switch (theReplacementMode)
246  {
249  for (band = 0; band < bands; ++band)
250  {
251  if (!ossim::isnan(theClampValueLo) && (buf[band][i] < clampLo))
252  buf[band][i] = clampLo;
253  else if (!ossim::isnan(theClampValueHi) && (buf[band][i] > clampHi))
254  buf[band][i] = clampHi;
255  }
256  break;
257 
260  // First band loop to establish if pixel qualifies for replacement (at least one
261  // band must be valid):
262  can_replace = false;
263  found_candidate = false;
264  for (band = 0; (band < bands) && !(can_replace && found_candidate); ++band)
265  {
266  if ((!ossim::isnan(theClampValueLo) && (buf[band][i] < clampLo)) ||
267  (!ossim::isnan(theClampValueHi) && (buf[band][i] > clampHi)))
268  found_candidate = true;
269  else
270  can_replace = true;
271  }
272  if (can_replace && found_candidate)
273  {
274  // This pixel has at least one band with normal value, so need to rescan bands
275  // to find pixels that need replacing (are within the target range):
276  for (band = 0; band < bands; ++band)
277  {
278  if (!ossim::isnan(theClampValueLo) && (buf[band][i] < clampLo))
279  buf[band][i] = clampLo;
280  else if (!ossim::isnan(theClampValueHi) && buf[band][i] > clampHi)
281  buf[band][i] = clampHi;
282  }
283  }
284  break;
285 
287  // First band loop to establish if pixel qualifies for replacement (all
288  // bands must be in target range):
289  can_replace = true;
290  for (band = 0; (band < bands) && can_replace; ++band)
291  {
292  if ((ossim::isnan(theClampValueLo) || (buf[band][i] >= clampLo)) &&
293  (ossim::isnan(theClampValueHi) || (buf[band][i] <= clampHi)))
294  can_replace = false;
295  }
296  if (can_replace)
297  {
298  // Map all pixels to replacement value:
299  for (band = 0; band < bands; ++band)
300  {
301  if (!ossim::isnan(theClampValueLo) && (buf[band][i] < clampLo))
302  buf[band][i] = clampLo;
303  else if (!ossim::isnan(theClampValueHi) && buf[band][i] > clampHi)
304  buf[band][i] = clampHi;
305  }
306  }
307  break;
308  } // close switch
309 
310  // Proceed to next pixel location:
311  ++i;
312  continue;
313  }
314 
315  // If we got here (the continue statement was not reached) then
316  // the pixel value now needs to be checked for possible target replacement:
317  switch (theReplacementMode)
318  {
320  for (band = 0; band < bands; ++band)
321  {
322  if ((buf[band][i] >= targetLo) && (buf[band][i] <= targetHi))
323  buf[band][i] = theReplacementValue;
324  }
325  break;
326 
328 
329  // First band loop to establish if pixel qualifies for replacement (at least one
330  // band must be valid):
331  can_replace = false;
332  found_candidate = false;
333  for (band = 0; (band < bands) && !(can_replace && found_candidate); ++band)
334  {
335  // check for target range replacement qualification:
336  if ((buf[band][i] < targetLo) || (buf[band][i] > targetHi))
337  can_replace = true; // Has valid band
338  else
339  found_candidate = true; // found band within target range
340  }
341  if (can_replace && found_candidate)
342  {
343  // This pixel has at least one band with normal value, so need to rescan bands
344  // to find pixels that need replacing (are within the target range):
345  for (band = 0; band < bands; ++band)
346  {
347  if ((buf[band][i] >= targetLo) && (buf[band][i] <= targetHi))
348  buf[band][i] = theReplacementValue;
349  }
350  }
351  break;
352 
354 
355  // First band loop to establish if pixel qualifies for replacement (at least one
356  // band must be valid):
357  can_replace = false;
358  found_candidate = false;
359  for (band = 0; (band < bands) && !(can_replace && found_candidate); ++band)
360  {
361  // check for target range replacement qualification:
362  if ((buf[band][i] < targetLo) || (buf[band][i] > targetHi))
363  can_replace = true;
364  else
365  found_candidate = true;
366  }
367  if (can_replace && found_candidate)
368  {
369  // This pixel has at least one band with normal value and one with target, so
370  // map all bands to target:
371  for (band = 0; band < bands; ++band)
372  buf[band][i] = theReplacementValue;
373  }
374  break;
375 
377 
378  // First band loop to establish if pixel qualifies for replacement (all
379  // bands must be in target range):
380  can_replace = true;
381  for (band = 0; (band < bands) && can_replace; ++band)
382  {
383  // check for target range replacement qualification:
384  if ((buf[band][i] < targetLo) || (buf[band][i] > targetHi))
385  can_replace = false;
386  }
387  if (can_replace)
388  {
389  // Map all pixels to replacement value:
390  for (band = 0; band < bands; ++band)
391  buf[band][i] = theReplacementValue;
392  }
393  break;
394 
396 
397  // First band loop to establish if pixel qualifies for replacement (all
398  // bands must be in target range):
399  can_replace = false;
400  for (band = 0; (band < bands) && !can_replace; ++band)
401  {
402  // check for target range replacement qualification:
403  if ((buf[band][i] >= targetLo) && (buf[band][i] <= targetHi))
404  can_replace = true;
405  }
406  if (can_replace)
407  {
408  // Map all pixels to replacement value:
409  for (band = 0; band < bands; ++band)
410  buf[band][i] = theReplacementValue;
411  }
412  break;
413  } // close switch
414 
415  // Reached end of processing for one pixel location. Increment the band buffers index:
416  ++i;
417  } // end of loop over pixel_loc.x
418  } // end of loop over pixel_loc.y
419 
420  delete[] buf;
421  inputTile->validate();
422 }
ossim_float64 theReplacementValue
When target values are defined, this is the value the pixel will assume if the pixel falls within the...
ClipMode theClipMode
Border Clip mode.
ReplacementMode theReplacementMode
See documentation for ReplacementMode enum above.
ossim_float64 theTargetValueLo
The value range to replace.
const ossimIpt & ul() const
Definition: ossimIrect.h:274
bool intersects(const ossimIrect &rect) const
Definition: ossimIrect.cpp:183
const ossimIpt & ll() const
Definition: ossimIrect.h:277
bool completely_within(const ossimIrect &rect) const
Definition: ossimIrect.cpp:425
ossim_float64 theTargetValueHi
unsigned int ossim_uint32
const ossimIpt & lr() const
Definition: ossimIrect.h:276
ClampingMode theClampingMode
ossim_float64 theClampValueHi
const ossimIpt & ur() const
Definition: ossimIrect.h:275
ossim_int32 y
Definition: ossimIpt.h:142
ossim_float64 theClampValueLo
The range of desired pixel values.
ossim_int32 x
Definition: ossimIpt.h:141
std::vector< ossimIrect > theBoundingRects
std::vector< ossimPolygon > theValidVertices
bool isnan(const float &v)
isnan Test for floating point Not A Number (NAN) value.
Definition: ossimCommon.h:91

◆ getClipMode()

ossimPixelFlipper::ClipMode ossimPixelFlipper::getClipMode ( ) const

Definition at line 967 of file ossimPixelFlipper.cpp.

References theClipMode.

968 {
969  return theClipMode;
970 }
ClipMode theClipMode
Border Clip mode.

◆ getClipModeString()

ossimString ossimPixelFlipper::getClipModeString ( ) const

Definition at line 956 of file ossimPixelFlipper.cpp.

References BOUNDING_RECT, theClipMode, and VALID_VERTICES.

Referenced by print(), and saveState().

957 {
958  if (theClipMode == BOUNDING_RECT)
959  return ossimString("bounding_rect");
960 
962  return ossimString("valid_vertices");
963 
964  return ossimString("none");
965 }
ClipMode theClipMode
Border Clip mode.

◆ getMaxPixelValue()

ossim_float64 ossimPixelFlipper::getMaxPixelValue ( ossim_uint32  band = 0) const
virtual

Returns the max pixel of the band.

Reimplemented from ossimImageSource.

Definition at line 660 of file ossimPixelFlipper.cpp.

References ossimImageSource::getMaxPixelValue(), ossimImageSource::getMinPixelValue(), MAX, MIN, and theClampValueHi.

661 {
664 
665  if ((theClampValueHi > MIN) && (theClampValueHi < MAX))
666  return theClampValueHi;
667 
668  return MAX;
669 }
#define MAX(x, y)
virtual double getMinPixelValue(ossim_uint32 band=0) const
Returns the min pixel of the band.
double ossim_float64
ossim_float64 theClampValueHi
#define MIN(x, y)
virtual double getMaxPixelValue(ossim_uint32 band=0) const
Returns the max pixel of the band.

◆ getMinPixelValue()

ossim_float64 ossimPixelFlipper::getMinPixelValue ( ossim_uint32  band = 0) const
virtual

Returns the min pixel of the band.

Reimplemented from ossimImageSource.

Definition at line 671 of file ossimPixelFlipper.cpp.

References ossimImageSource::getMaxPixelValue(), ossimImageSource::getMinPixelValue(), MAX, MIN, and theClampValueLo.

672 {
675 
676  if ((theClampValueLo > MIN) && (theClampValueLo < MAX))
677  return theClampValueLo;
678 
679  return MIN;
680 }
#define MAX(x, y)
virtual double getMinPixelValue(ossim_uint32 band=0) const
Returns the min pixel of the band.
double ossim_float64
#define MIN(x, y)
virtual double getMaxPixelValue(ossim_uint32 band=0) const
Returns the max pixel of the band.
ossim_float64 theClampValueLo
The range of desired pixel values.

◆ getOutputScalarType()

ossimScalarType ossimPixelFlipper::getOutputScalarType ( ) const
virtual

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 603 of file ossimPixelFlipper.cpp.

References ossimImageSource::getOutputScalarType(), OSSIM_SCALAR_UNKNOWN, OSSIM_USHORT11, OSSIM_USHORT12, OSSIM_USHORT13, OSSIM_USHORT14, OSSIM_USHORT15, OSSIM_USHORT16, theClampValueHi, and ossimImageSourceFilter::theInputConnection.

604 {
605  if (theInputConnection)
606  {
608  {
609  if (scalar == OSSIM_USHORT16 && theClampValueHi == 2047.0)
610  {
611  //---
612  // Special case:
613  // We have an unsigned 16 bit type but we want to call it
614  // USHORT11 ( (2^11- 1) = 2047 ).
615  //---
616  return OSSIM_USHORT11;
617  }
618  else if (scalar == OSSIM_USHORT16 && theClampValueHi == 4095.0)
619  {
620  //---
621  // Special case:
622  // We have an unsigned 16 bit type but we want to call it
623  // USHORT12 ( (2^12- 1) = 4095 ).
624  //---
625  return OSSIM_USHORT12;
626  }
627  else if (scalar == OSSIM_USHORT16 && theClampValueHi == 8191.0)
628  {
629  //---
630  // Special case:
631  // We have an unsigned 16 bit type but we want to call it
632  // USHORT13 ( (2^13- 1) = 8191 ).
633  //---
634  return OSSIM_USHORT13;
635  }
636  else if (scalar == OSSIM_USHORT16 && theClampValueHi == 16383.0)
637  {
638  //---
639  // Special case:
640  // We have an unsigned 16 bit type but we want to call it
641  // USHORT14 ( (2^14- 1) = 16383 ).
642  //---
643  return OSSIM_USHORT14;
644  }
645  else if (scalar == OSSIM_USHORT16 && theClampValueHi == 32767.0)
646  {
647  //---
648  // Special case:
649  // We have an unsigned 16 bit type but we want to call it
650  // USHORT15 ( (2^15- 1) = 32767 ).
651  //---
652  return OSSIM_USHORT15;
653  }
654  return scalar;
655  }
656  }
657  return OSSIM_SCALAR_UNKNOWN;
658 }
16 bit unsigned integer (15 bits used)
16 bit unsigned integer (14 bits used)
16 bit unsigned integer (13 bits used)
ossimImageSource * theInputConnection
ossim_float64 theClampValueHi
ossimScalarType
16 bit unsigned integer (11 bits used)
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
16 bit unsigned iteger
16 bit unsigned integer (12 bits used)

◆ getProperty()

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

Reimplemented from ossimImageSourceFilter.

Definition at line 986 of file ossimPixelFlipper.cpp.

References PF_TARGET_RANGE_KW, PF_TARGET_VALUE_KW, ossimProperty::setCacheRefreshBit(), theMutex, theTargetValueLo, and ossimString::toString().

988 {
989  // Lock for the length of this method.
990  std::lock_guard<std::recursive_mutex> scopeLock(theMutex);
991 
992  if (name == PF_TARGET_VALUE_KW)
993  {
994  ossimProperty *p =
995  new ossimNumericProperty(name,
997  p->setCacheRefreshBit();
998  return ossimRefPtr<ossimProperty>(p);
999  }
1000  if (name == PF_TARGET_RANGE_KW)
1001  {
1002  ossimProperty *p =
1003  new ossimNumericProperty(name,
1005  p->setCacheRefreshBit();
1006  return ossimRefPtr<ossimProperty>(p);
1007  }
1008  if (name == TARGET_UPPER_LIMIT_PROP_NAME)
1009  {
1010  ossimProperty *p =
1011  new ossimNumericProperty(name,
1013  p->setCacheRefreshBit();
1014  return ossimRefPtr<ossimProperty>(p);
1015  }
1016  else if (name == PF_REPLACEMENT_VALUE_KW)
1017  {
1018  ossimProperty *p =
1019  new ossimNumericProperty(name,
1021  p->setCacheRefreshBit();
1022  return ossimRefPtr<ossimProperty>(p);
1023  }
1024  else if (name == PF_CLAMP_VALUE_LO_KW)
1025  {
1026  ossimProperty *p =
1028  p->setCacheRefreshBit();
1029  return ossimRefPtr<ossimProperty>(p);
1030  }
1031  else if (name == PF_CLAMP_VALUE_HI_KW)
1032  {
1033  ossimProperty *p =
1035  p->setCacheRefreshBit();
1036  return ossimRefPtr<ossimProperty>(p);
1037  }
1038  else if (name == PF_REPLACEMENT_MODE_KW)
1039  {
1040  vector<ossimString> constraintList(5);
1041  constraintList[0] = "REPLACE_BAND_IF_TARGET";
1042  constraintList[1] = "REPLACE_BAND_IF_PARTIAL_TARGET";
1043  constraintList[2] = "REPLACE_ALL_BANDS_IF_PARTIAL_TARGET";
1044  constraintList[3] = "REPLACE_ONLY_FULL_TARGETS";
1045  constraintList[4] = "REPLACE_ALL_BANDS_IF_ANY_TARGET";
1046 
1047  ossimStringProperty *p =
1048  new ossimStringProperty(name,
1050  false,
1051  constraintList);
1052  p->setCacheRefreshBit();
1053  return ossimRefPtr<ossimProperty>(p);
1054  }
1055  else if (name == PF_CLIP_MODE_KW)
1056  {
1057  vector<ossimString> constraintList(3);
1058  constraintList[0] = "none";
1059  constraintList[1] = "bounding_rect";
1060  constraintList[2] = "valid_vertices";
1061 
1062  ossimStringProperty *p =
1063  new ossimStringProperty(name,
1065  false,
1066  constraintList);
1067  p->setCacheRefreshBit();
1068  return ossimRefPtr<ossimProperty>(p);
1069  }
1071 
1072  if (result.valid())
1073  {
1074  if (result->getName() == ossimKeywordNames::ENABLED_KW)
1075  {
1076  result->clearChangeType();
1077 
1078  // we will at least say its a radiometric change
1079  //
1080  result->setCacheRefreshBit();
1081  }
1082  }
1083 
1084  return result;
1085 }
ossim_float64 theReplacementValue
When target values are defined, this is the value the pixel will assume if the pixel falls within the...
bool valid() const
Definition: ossimRefPtr.h:75
std::recursive_mutex theMutex
For lock and unlock.
ossim_float64 theTargetValueLo
The value range to replace.
static const char PF_REPLACEMENT_MODE_KW[]
static ossimString toString(bool aValue)
Numeric to string methods.
static const char PF_TARGET_RANGE_KW[]
static const char PF_CLAMP_VALUE_LO_KW[]
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
ossim_float64 theTargetValueHi
void clearChangeType()
static const char PF_CLAMP_VALUE_HI_KW[]
ossimString getClipModeString() const
ossim_float64 theClampValueHi
static const char * ENABLED_KW
ossimString getReplacementModeString() const
ossim_float64 theClampValueLo
The range of desired pixel values.
static const char PF_REPLACEMENT_VALUE_KW[]
static const char PF_CLIP_MODE_KW[]
void setCacheRefreshBit()
static const char PF_TARGET_VALUE_KW[]
const ossimString & getName() const

◆ getPropertyNames()

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

Reimplemented from ossimImageSourceFilter.

Definition at line 1133 of file ossimPixelFlipper.cpp.

References PF_TARGET_VALUE_KW.

1135 {
1136  propertyNames.push_back(PF_TARGET_VALUE_KW);
1137  propertyNames.push_back(TARGET_LOWER_LIMIT_PROP_NAME);
1138  propertyNames.push_back(TARGET_UPPER_LIMIT_PROP_NAME);
1139  propertyNames.push_back(PF_REPLACEMENT_VALUE_KW);
1140  propertyNames.push_back(PF_REPLACEMENT_MODE_KW);
1141  propertyNames.push_back(PF_CLAMP_VALUE_LO_KW);
1142  propertyNames.push_back(PF_CLAMP_VALUE_HI_KW);
1143  propertyNames.push_back(PF_CLIP_MODE_KW);
1144 
1146 }
static const char PF_REPLACEMENT_MODE_KW[]
static const char PF_CLAMP_VALUE_LO_KW[]
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
static const char PF_CLAMP_VALUE_HI_KW[]
static const char PF_REPLACEMENT_VALUE_KW[]
static const char PF_CLIP_MODE_KW[]
static const char PF_TARGET_VALUE_KW[]

◆ getReplacementMode()

ossimPixelFlipper::ReplacementMode ossimPixelFlipper::getReplacementMode ( ) const

Definition at line 930 of file ossimPixelFlipper.cpp.

References theReplacementMode.

931 {
932  return theReplacementMode;
933 }
ReplacementMode theReplacementMode
See documentation for ReplacementMode enum above.

◆ getReplacementModeString()

ossimString ossimPixelFlipper::getReplacementModeString ( ) const

Definition at line 935 of file ossimPixelFlipper.cpp.

References REPLACE_ALL_BANDS_IF_ANY_TARGET, REPLACE_ALL_BANDS_IF_PARTIAL_TARGET, REPLACE_BAND_IF_PARTIAL_TARGET, REPLACE_BAND_IF_TARGET, REPLACE_ONLY_FULL_TARGETS, and theReplacementMode.

Referenced by print(), and saveState().

936 {
937  switch (theReplacementMode)
938  {
940  return ossimString("REPLACE_BAND_IF_TARGET");
942  return ossimString("REPLACE_BAND_IF_PARTIAL_TARGET");
944  return ossimString("REPLACE_ALL_BANDS_IF_PARTIAL_TARGET");
946  return ossimString("REPLACE_ONLY_FULL_TARGETS");
948  return ossimString("REPLACE_ALL_BANDS_IF_ANY_TARGET");
949  default:
950  break;
951  }
952 
953  return ossimString("UNKNOWN_MODE");
954 }
ReplacementMode theReplacementMode
See documentation for ReplacementMode enum above.

◆ getReplacementValue()

ossim_float64 ossimPixelFlipper::getReplacementValue ( ) const

Definition at line 925 of file ossimPixelFlipper.cpp.

References theReplacementValue.

926 {
927  return theReplacementValue;
928 }
ossim_float64 theReplacementValue
When target values are defined, this is the value the pixel will assume if the pixel falls within the...

◆ getShortName()

ossimString ossimPixelFlipper::getShortName ( ) const
virtual
Returns
"Pixel flipper" as an ossimString.

Reimplemented from ossimObject.

Definition at line 1148 of file ossimPixelFlipper.cpp.

1149 {
1150  return ossimString("Pixel flipper");
1151 }

◆ getTile()

ossimRefPtr< ossimImageData > ossimPixelFlipper::getTile ( const ossimIrect tile_rect,
ossim_uint32  resLevel = 0 
)
virtual
Parameters
tile_rectRectangle to fill tile with.
resLevelReduced resolution level to grab from.
Returns
ossimRefPtr<ossimImageData> This is tile that was filled with tile_rect.
Note
Callers should check the ossimRefPtr::valid method. The internal pointer of the ossimRefPtr<ossimImageData> can be null if the tile_rect did not intersect the input connection's bounding rectangle.

Reimplemented from ossimImageSource.

Definition at line 72 of file ossimPixelFlipper.cpp.

References flipPixels(), ossimRefPtr< T >::get(), ossimImageData::getBuf(), ossimRectilinearDataObject::getScalarType(), ossimImageSource::getTile(), ossimSource::isSourceEnabled(), OSSIM_FLOAT32, OSSIM_FLOAT64, OSSIM_NORMALIZED_DOUBLE, OSSIM_NORMALIZED_FLOAT, OSSIM_SCALAR_UNKNOWN, OSSIM_SINT32, OSSIM_SSHORT16, OSSIM_UCHAR, OSSIM_UINT16, OSSIM_UINT32, OSSIM_USHORT11, OSSIM_USHORT12, OSSIM_USHORT13, OSSIM_USHORT14, OSSIM_USHORT15, ossimNotify(), ossimNotifyLevel_WARN, ossimImageSourceFilter::theInputConnection, theMutex, ossimRefPtr< T >::valid(), and ossimImageData::validate().

Referenced by ossimBitMaskWriter::generateMask().

74 {
75 
76  if (!theInputConnection)
77  {
78  return 0;
79  }
80 
81  // Fetch tile from pointer from the input source.
82  ossimRefPtr<ossimImageData> inputTile =
83  theInputConnection->getTile(tile_rect, resLevel);
84 
85  if (!inputTile.valid() || !isSourceEnabled())
86  return inputTile;
87 
88  if (!inputTile->getBuf())
89  return inputTile;
90 
91  // Lock for the length of this method.
92  std::lock_guard<std::recursive_mutex> scopeLock(theMutex);
93 
94  // Call the appropriate load method.
95  switch (inputTile->getScalarType())
96  {
97 
98  case OSSIM_UCHAR:
99  {
100  flipPixels(ossim_uint8(0), inputTile.get(), resLevel);
101  break;
102  }
103 
104  case OSSIM_UINT16:
105  case OSSIM_USHORT11:
106  case OSSIM_USHORT12:
107  case OSSIM_USHORT13:
108  case OSSIM_USHORT14:
109  case OSSIM_USHORT15:
110  {
111  flipPixels(ossim_uint16(0), inputTile.get(), resLevel);
112  break;
113  }
114 
115  case OSSIM_SSHORT16:
116  {
117  flipPixels(ossim_sint16(0), inputTile.get(), resLevel);
118  break;
119  }
120  case OSSIM_UINT32:
121  {
122  flipPixels(ossim_uint32(0), inputTile.get(), resLevel);
123  break;
124  }
125  case OSSIM_SINT32:
126  {
127  flipPixels(ossim_sint32(0), inputTile.get(), resLevel);
128  break;
129  }
130  case OSSIM_FLOAT32:
132  {
133  flipPixels(ossim_float32(0), inputTile.get(), resLevel);
134  break;
135  }
136 
138  case OSSIM_FLOAT64:
139  {
140  flipPixels(ossim_float64(0), inputTile.get(), resLevel);
141  break;
142  }
143 
145  default:
146  {
148  << "ossimPixelFlipper::getTile Unsupported scalar type!" << endl;
149  break;
150  }
151  }
152 
153  inputTile->validate();
154  return inputTile;
155 }
16 bit unsigned integer (15 bits used)
virtual bool isSourceEnabled() const
Definition: ossimSource.cpp:79
64 bit floating point
16 bit unsigned integer
bool valid() const
Definition: ossimRefPtr.h:75
float ossim_float32
std::recursive_mutex theMutex
For lock and unlock.
16 bit unsigned integer (14 bits used)
16 bit unsigned integer (13 bits used)
32 bit floating point
unsigned short ossim_uint16
32 bit unsigned integer
double ossim_float64
void flipPixels(T dummy, ossimImageData *inpuTile, ossim_uint32 resLevel)
This object can be used outside of an image chain for offline processing of existing tile...
virtual ossimDataObjectStatus validate() const
signed short ossim_sint16
32 bit signed integer
ossimImageSource * theInputConnection
unsigned int ossim_uint32
32 bit normalized floating point
signed int ossim_sint32
virtual ossimScalarType getScalarType() const
64 bit normalized floating point
16 bit unsigned integer (11 bits used)
virtual const void * getBuf() const
16 bit signed integer
unsigned char ossim_uint8
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
8 bit unsigned iteger
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)
16 bit unsigned integer (12 bits used)

◆ initialize()

void ossimPixelFlipper::initialize ( )
virtual

Initializes the state of the object from theInputConnection.

Reimplemented from ossimImageSourceFilter.

Definition at line 571 of file ossimPixelFlipper.cpp.

References ossimImageSource::getBoundingRect(), ossimImageSource::getNumberOfDecimationLevels(), ossimImageSource::getValidImageVertices(), ossimImageSourceFilter::initialize(), OSSIM_CLOCKWISE_ORDER, theBoundingRects, theMutex, and theValidVertices.

Referenced by ossimBitMaskWriter::generateMask().

572 {
573  std::lock_guard<std::recursive_mutex> scopeLock(theMutex);
575  theValidVertices.clear();
576  theBoundingRects.clear();
577 
579  ossim_uint32 idx = 0;
580 
581  if (rlevels)
582  {
583  if (theValidVertices.size() != rlevels)
584  {
585  theValidVertices.resize(rlevels);
586  }
587  if (theBoundingRects.size() != rlevels)
588  {
589  theBoundingRects.resize(rlevels);
590  }
591  for (idx = 0; idx < rlevels; ++idx)
592  {
593  std::vector<ossimIpt> validVertices;
594  getValidImageVertices(validVertices,
596  idx);
597  theValidVertices[idx] = ossimPolygon(validVertices);
598  theBoundingRects[idx] = getBoundingRect(idx);
599  }
600  }
601 }
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
This will return the bounding rect of the source.
std::recursive_mutex theMutex
For lock and unlock.
virtual ossim_uint32 getNumberOfDecimationLevels() const
Will return the number of resolution levels.
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
std::vector< ossimIrect > theBoundingRects
std::vector< ossimPolygon > theValidVertices

◆ inRange()

bool ossimPixelFlipper::inRange ( ossim_float64  value) const
protected

Verifies pixel is in range.

Returns
Returns true if in range else false.

Definition at line 1153 of file ossimPixelFlipper.cpp.

References ossimImageSource::getMaxPixelValue(), ossimImageSource::getMinPixelValue(), ossimImageSource::getNullPixelValue(), ossimNotify(), ossimNotifyLevel_WARN, and ossimImageSourceFilter::theInputConnection.

Referenced by setClampValue(), and setReplacementValue().

1154 {
1155  if (!theInputConnection)
1156  {
1157  //---
1158  // Not initialized yet... We're going to return true so that things
1159  // like loadState work with the assumption that the caller know's
1160  // the correct range. This check is really intended for an uncheck
1161  // range on the gui side.
1162  //---
1163  return true;
1164  }
1165 
1169 
1170  if ((value == NULL_PIX) || ((value >= MIN_PIX) && (value <= MAX_PIX)))
1171  {
1172  return true;
1173  }
1174 
1176  << "\nossimPixelFlipper::inRange WARNING:"
1177  << "\nvalue \"" << value
1178  << "\" is out of range!"
1179  << "\nInput source null = " << NULL_PIX
1180  << "\nInput source min = " << MIN_PIX
1181  << "\nInput source max = " << MAX_PIX
1182  << endl;
1183 
1184  return false;
1185 }
virtual double getMinPixelValue(ossim_uint32 band=0) const
Returns the min pixel of the band.
double ossim_float64
ossimImageSource * theInputConnection
virtual double getMaxPixelValue(ossim_uint32 band=0) const
Returns the max pixel of the band.
virtual double getNullPixelValue(ossim_uint32 band=0) const
Each band has a null pixel associated with it.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ loadState()

bool ossimPixelFlipper::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 682 of file ossimPixelFlipper.cpp.

References ossimString::after(), ossimString::before(), ossimKeywordlist::find(), ossimImageSourceFilter::loadState(), PF_CLAMP_VALUE_HI_KW, PF_CLAMP_VALUE_KW, PF_CLAMP_VALUE_LO_KW, PF_CLIP_MODE_KW, PF_REPLACEMENT_MODE_KW, PF_REPLACEMENT_VALUE_KW, PF_TARGET_RANGE_KW, PF_TARGET_VALUE_KW, setClampValue(), setClipMode(), setReplacementMode(), setReplacementValue(), setTargetRange(), setTargetValue(), status, and ossimString::toFloat64().

Referenced by ossimBitMaskWriter::loadState().

684 {
685  const char *lookupReturn;
686 
687  lookupReturn = kwl.find(prefix, PF_TARGET_VALUE_KW);
688  if (lookupReturn)
689  {
690  setTargetValue(atof(lookupReturn));
691  }
692 
693  lookupReturn = kwl.find(prefix, PF_TARGET_RANGE_KW);
694  if (lookupReturn)
695  {
696  ossimString min_max_string(lookupReturn);
697  ossimString separator(" ");
698  ossim_float64 min_target = min_max_string.before(separator).toFloat64();
699  ossim_float64 max_target = min_max_string.after(separator).toFloat64();
700  setTargetRange(min_target, max_target);
701  }
702 
703  lookupReturn = kwl.find(prefix, PF_REPLACEMENT_VALUE_KW);
704  if (lookupReturn)
705  {
706  setReplacementValue(atof(lookupReturn));
707  }
708 
709  lookupReturn = kwl.find(prefix, PF_REPLACEMENT_MODE_KW);
710  if (lookupReturn)
711  {
712  ossimString modeString = lookupReturn;
713  setReplacementMode(modeString);
714  }
715 
716  lookupReturn = kwl.find(prefix, PF_CLAMP_VALUE_KW);
717  if (lookupReturn)
718  {
719  setClampValue(atof(lookupReturn), true);
720  }
721 
722  lookupReturn = kwl.find(prefix, PF_CLAMP_VALUE_LO_KW);
723  if (lookupReturn)
724  {
725  setClampValue(atof(lookupReturn), false);
726  }
727 
728  lookupReturn = kwl.find(prefix, PF_CLAMP_VALUE_HI_KW);
729  if (lookupReturn)
730  {
731  setClampValue(atof(lookupReturn), true);
732  }
733 
734  lookupReturn = kwl.find(prefix, PF_CLIP_MODE_KW);
735  if (lookupReturn)
736  {
737  ossimString modeString = lookupReturn;
738  setClipMode(modeString);
739  }
740 
741  bool status = ossimImageSourceFilter::loadState(kwl, prefix);
742 
743  if (traceDebug())
744  {
746  }
747 
748  return status;
749 }
void setClipMode(const ossimString &modeString)
Clipping here refers to bounding rect or valid polygon (spacial) clipping, where all pixels outside t...
const char * find(const char *key) const
static const char PF_REPLACEMENT_MODE_KW[]
static const char PF_CLAMP_VALUE_KW[]
static const char PF_TARGET_RANGE_KW[]
void setClampValue(ossim_float64 clamp_value, bool is_high_clamp_value=true)
static const char PF_CLAMP_VALUE_LO_KW[]
void setReplacementMode(ossimPixelFlipper::ReplacementMode mode)
double ossim_float64
static const char PF_CLAMP_VALUE_HI_KW[]
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
return status
void setTargetRange(ossim_float64 target_min, ossim_float64 target_max)
Instead of a single value for a target, this method allows for specifying a range of values to flip t...
void setReplacementValue(ossim_float64 replacement_value)
void setTargetValue(ossim_float64 target_value)
virtual std::ostream & print(std::ostream &out) const
Outputs theErrorStatus as an ossimErrorCode and an ossimString.
static const char PF_REPLACEMENT_VALUE_KW[]
static const char PF_CLIP_MODE_KW[]
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
static const char PF_TARGET_VALUE_KW[]

◆ print()

std::ostream & ossimPixelFlipper::print ( std::ostream &  out) const
virtual

Outputs theErrorStatus as an ossimErrorCode and an ossimString.

Returns
std::ostream&
Note
Derived classes should only have to implement a virtual print, not an operator<< funtion as it's implemented here.

Reimplemented from ossimSource.

Definition at line 972 of file ossimPixelFlipper.cpp.

References ossimString::c_str(), getClipModeString(), getReplacementModeString(), theClampValueHi, theClampValueLo, theReplacementValue, theTargetValueHi, and theTargetValueLo.

973 {
974  out << "ossimPixelFlipper::print:"
975  << "\ntarget value Lo: " << theTargetValueLo
976  << "\ntarget value Hi: " << theTargetValueHi
977  << "\nreplacement value: " << theReplacementValue
978  << "\nclamp value Lo: " << theClampValueLo
979  << "\nclamp value Hi: " << theClampValueHi
980  << "\nreplacement mode: " << getReplacementModeString().c_str()
981  << "\nclip_mode: " << getClipModeString().c_str()
982  << endl;
983  return out;
984 }
ossim_float64 theReplacementValue
When target values are defined, this is the value the pixel will assume if the pixel falls within the...
ossim_float64 theTargetValueLo
The value range to replace.
ossim_float64 theTargetValueHi
ossimString getClipModeString() const
ossim_float64 theClampValueHi
ossimString getReplacementModeString() const
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
ossim_float64 theClampValueLo
The range of desired pixel values.

◆ saveState()

bool ossimPixelFlipper::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 751 of file ossimPixelFlipper.cpp.

References ossimKeywordlist::add(), getClipModeString(), getReplacementModeString(), PF_CLAMP_VALUE_HI_KW, PF_CLAMP_VALUE_LO_KW, PF_CLIP_MODE_KW, PF_REPLACEMENT_MODE_KW, PF_REPLACEMENT_VALUE_KW, PF_TARGET_RANGE_KW, PF_TARGET_VALUE_KW, ossimImageSourceFilter::saveState(), theClampingMode, theClampValueHi, theClampValueLo, theReplacementValue, theTargetValueHi, theTargetValueLo, and ossimString::toString().

753 {
754  // Call the base class saveState.
756 
758  {
761  kwl.add(prefix, PF_TARGET_RANGE_KW, s);
762  }
763  else
764  {
766  }
768  kwl.add(prefix, PF_REPLACEMENT_MODE_KW, getReplacementModeString().c_str());
769 
770  if (theClampingMode)
771  {
774  }
775  kwl.add(prefix, PF_CLIP_MODE_KW, getClipModeString().c_str());
776 
777  return true;
778 }
ossim_float64 theReplacementValue
When target values are defined, this is the value the pixel will assume if the pixel falls within the...
ossim_float64 theTargetValueLo
The value range to replace.
static const char PF_REPLACEMENT_MODE_KW[]
static ossimString toString(bool aValue)
Numeric to string methods.
static const char PF_TARGET_RANGE_KW[]
static const char PF_CLAMP_VALUE_LO_KW[]
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
ossim_float64 theTargetValueHi
static const char PF_CLAMP_VALUE_HI_KW[]
ossimString getClipModeString() const
ClampingMode theClampingMode
ossim_float64 theClampValueHi
ossimString getReplacementModeString() const
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
ossim_float64 theClampValueLo
The range of desired pixel values.
static const char PF_REPLACEMENT_VALUE_KW[]
static const char PF_CLIP_MODE_KW[]
static const char PF_TARGET_VALUE_KW[]

◆ setClampValue()

void ossimPixelFlipper::setClampValue ( ossim_float64  clamp_value,
bool  is_high_clamp_value = true 
)
Parameters
clamp_valueIf set all pixel values above this range will (or below if clamp_max_value = false) be clamped to clamp_value. Must be less than max pixel (or greater than the min pixel) value of the input and cannot be null.
Note
If any clamp limit is defined, it will take precedence over any target value (or range) replacement. The replacement mode is referenced when deciding whether a pixel should be clamped or left alone.

Definition at line 817 of file ossimPixelFlipper.cpp.

References CLAMPING_HI, CLAMPING_LO, inRange(), theClampingMode, theClampValueHi, theClampValueLo, and theMutex.

Referenced by loadState(), and setClampValues().

818 {
819  std::lock_guard<std::recursive_mutex> scopeLock(theMutex);
820 
821  if (inRange(clamp_value))
822  {
823  // Stupid MS compiler complains if we do an |= on enum type. (OLK 1/11)
824  int temp_int = (int)theClampingMode;
825  if (clamp_max_value)
826  {
827  theClampValueHi = clamp_value;
828  temp_int |= (int)CLAMPING_HI;
829  }
830  else
831  {
832  theClampValueLo = clamp_value;
833  temp_int |= (int)CLAMPING_LO;
834  }
835  theClampingMode = (ClampingMode)temp_int;
836  }
837 }
std::recursive_mutex theMutex
For lock and unlock.
ClampingMode
When either a lo and/or hi clamp value is set, the clamping mode will be enabled accordingly and over...
ClampingMode theClampingMode
ossim_float64 theClampValueHi
ossim_float64 theClampValueLo
The range of desired pixel values.
bool inRange(ossim_float64 value) const
Verifies pixel is in range.

◆ setClampValues()

void ossimPixelFlipper::setClampValues ( ossim_float64  clamp_value_lo,
ossim_float64  clamp_value_hi 
)

Definition at line 839 of file ossimPixelFlipper.cpp.

References DISABLED, setClampValue(), and theClampingMode.

840 {
841  theClampingMode = DISABLED; // reset and let next calls set accordingly
842  setClampValue(clamp_value_lo, false);
843  setClampValue(clamp_value_hi, true);
844 }
void setClampValue(ossim_float64 clamp_value, bool is_high_clamp_value=true)
ClampingMode theClampingMode

◆ setClipMode() [1/2]

void ossimPixelFlipper::setClipMode ( const ossimString modeString)

Clipping here refers to bounding rect or valid polygon (spacial) clipping, where all pixels outside the valid area are mapped to the replacement value.

Definition at line 895 of file ossimPixelFlipper.cpp.

References BOUNDING_RECT, ossimString::downcase(), NONE, ossimNotify(), ossimNotifyLevel_WARN, and VALID_VERTICES.

Referenced by loadState().

896 {
897  ossimString mode = modeString;
898  mode.downcase();
899  if (mode == "none")
900  {
901  setClipMode(NONE);
902  }
903  else if (mode == "bounding_rect")
904  {
906  }
907  else if (mode == "valid_vertices")
908  {
910  }
911  else
912  {
914  << "ossimPixelFlipper::setClipMode warning:\n"
915  << "Invalid mode: " << modeString
916  << endl;
917  }
918 }
void setClipMode(const ossimString &modeString)
Clipping here refers to bounding rect or valid polygon (spacial) clipping, where all pixels outside t...
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ setClipMode() [2/2]

void ossimPixelFlipper::setClipMode ( ossimPixelFlipper::ClipMode  mode)

Definition at line 889 of file ossimPixelFlipper.cpp.

References theClipMode, and theMutex.

890 {
891  std::lock_guard<std::recursive_mutex> scopeLock(theMutex);
892  theClipMode = mode;
893 }
ClipMode theClipMode
Border Clip mode.
std::recursive_mutex theMutex
For lock and unlock.

◆ setProperty()

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

Reimplemented from ossimImageSourceFilter.

Definition at line 1087 of file ossimPixelFlipper.cpp.

References PF_TARGET_VALUE_KW, setTargetValue(), and ossimString::toDouble().

1088 {
1089  if (!property)
1090  return;
1091 
1092  ossimString os = property->valueToString();
1093 
1094  ossimString name = property->getName();
1095  if (name == PF_TARGET_VALUE_KW)
1096  {
1097  setTargetValue(os.toDouble());
1098  }
1099  if (name == TARGET_LOWER_LIMIT_PROP_NAME)
1100  {
1102  }
1103  if (name == TARGET_UPPER_LIMIT_PROP_NAME)
1104  {
1106  }
1107  else if (name == PF_REPLACEMENT_VALUE_KW)
1108  {
1110  }
1111  else if (name == PF_REPLACEMENT_MODE_KW)
1112  {
1113  setReplacementMode(os);
1114  }
1115  else if (name == PF_CLAMP_VALUE_LO_KW)
1116  {
1117  setClampValue(os.toDouble(), false);
1118  }
1119  else if (name == PF_CLAMP_VALUE_HI_KW)
1120  {
1121  setClampValue(os.toDouble(), true);
1122  }
1123  else if (name == PF_CLIP_MODE_KW)
1124  {
1125  setClipMode(os);
1126  }
1127  else
1128  {
1130  }
1131 }
virtual void setProperty(ossimRefPtr< ossimProperty > property)
void setClipMode(const ossimString &modeString)
Clipping here refers to bounding rect or valid polygon (spacial) clipping, where all pixels outside t...
ossim_float64 theTargetValueLo
The value range to replace.
static const char PF_REPLACEMENT_MODE_KW[]
void setClampValue(ossim_float64 clamp_value, bool is_high_clamp_value=true)
static const char PF_CLAMP_VALUE_LO_KW[]
void setReplacementMode(ossimPixelFlipper::ReplacementMode mode)
ossim_float64 theTargetValueHi
static const char PF_CLAMP_VALUE_HI_KW[]
double toDouble() const
void setTargetRange(ossim_float64 target_min, ossim_float64 target_max)
Instead of a single value for a target, this method allows for specifying a range of values to flip t...
void setReplacementValue(ossim_float64 replacement_value)
void setTargetValue(ossim_float64 target_value)
static const char PF_REPLACEMENT_VALUE_KW[]
static const char PF_CLIP_MODE_KW[]
static const char PF_TARGET_VALUE_KW[]

◆ setReplacementMode() [1/2]

void ossimPixelFlipper::setReplacementMode ( ossimPixelFlipper::ReplacementMode  mode)
See also
enum ReplacementMode

Definition at line 846 of file ossimPixelFlipper.cpp.

References theMutex, and theReplacementMode.

Referenced by ossimBitMaskWriter::initializeFlipper(), and loadState().

847 {
848  std::lock_guard<std::recursive_mutex> scopeLock(theMutex);
849  theReplacementMode = mode;
850 }
ReplacementMode theReplacementMode
See documentation for ReplacementMode enum above.
std::recursive_mutex theMutex
For lock and unlock.

◆ setReplacementMode() [2/2]

bool ossimPixelFlipper::setReplacementMode ( const ossimString modeString)

Accepts a string that must match the enumerator's label (can be lower case) and sets the replacement mode accordingly.

If the string is not understood, the mode remains unchanged and FALSE is returned.

Definition at line 852 of file ossimPixelFlipper.cpp.

References ossimNotify(), ossimNotifyLevel_WARN, REPLACE_ALL_BANDS_IF_ANY_TARGET, REPLACE_ALL_BANDS_IF_PARTIAL_TARGET, REPLACE_BAND_IF_PARTIAL_TARGET, REPLACE_BAND_IF_TARGET, REPLACE_ONLY_FULL_TARGETS, theMutex, theReplacementMode, and ossimString::upcase().

853 {
854  std::lock_guard<std::recursive_mutex> scopeLock(theMutex);
855 
856  ossimString mode = modeString;
857  mode.upcase();
858  if (mode == "REPLACE_BAND_IF_TARGET")
859  {
861  }
862  else if (mode == "REPLACE_BAND_IF_PARTIAL_TARGET")
863  {
865  }
866  else if (mode == "REPLACE_ALL_BANDS_IF_PARTIAL_TARGET")
867  {
869  }
870  else if (mode == "REPLACE_ONLY_FULL_TARGETS")
871  {
873  }
874  else if (mode == "REPLACE_ALL_BANDS_IF_ANY_TARGET")
875  {
877  }
878  else
879  {
881  << "ossimPixelFlipper::setReplacementMode warning:\n"
882  << "Invalid mode: " << modeString
883  << endl;
884  return false;
885  }
886  return true;
887 }
static ossimString upcase(const ossimString &aString)
Definition: ossimString.cpp:34
ReplacementMode theReplacementMode
See documentation for ReplacementMode enum above.
std::recursive_mutex theMutex
For lock and unlock.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ setReplacementValue()

void ossimPixelFlipper::setReplacementValue ( ossim_float64  replacement_value)
Parameters
replacement_valueThis is the value to flip target to.
Note
If clamping is specified, it will take precedence over any target replacement.

Definition at line 806 of file ossimPixelFlipper.cpp.

References inRange(), theMutex, and theReplacementValue.

Referenced by ossimBitMaskWriter::initializeFlipper(), and loadState().

807 {
808  std::lock_guard<std::recursive_mutex> scopeLock(theMutex);
809 
810  // Range check to ensure within null, min and max of output radiometry.
811  if (inRange(replacement_value))
812  {
813  theReplacementValue = replacement_value;
814  }
815 }
ossim_float64 theReplacementValue
When target values are defined, this is the value the pixel will assume if the pixel falls within the...
std::recursive_mutex theMutex
For lock and unlock.
bool inRange(ossim_float64 value) const
Verifies pixel is in range.

◆ setTargetRange()

void ossimPixelFlipper::setTargetRange ( ossim_float64  target_min,
ossim_float64  target_max 
)

Instead of a single value for a target, this method allows for specifying a range of values to flip to the replacement.

The replacement mode is still referenced.

Parameters
Thisis the value to flip.
Note
If clamping is specified, it will take precedence over any target range test.

Definition at line 793 of file ossimPixelFlipper.cpp.

References theMutex, theTargetValueHi, and theTargetValueLo.

Referenced by loadState(), and ossimBitMaskWriter::setBogusPixelRange().

794 {
795  //---
796  // Since this is the value to replace we will allow for any value as it
797  // won't affect the output null, min and max ranges. This will fix a
798  // tiled nitf with max of 2047(11bit) with edge tile fill values of 2048.
799  //---
800  std::lock_guard<std::recursive_mutex> scopeLock(theMutex);
801 
802  theTargetValueLo = target_min;
803  theTargetValueHi = target_max;
804 }
std::recursive_mutex theMutex
For lock and unlock.
ossim_float64 theTargetValueLo
The value range to replace.
ossim_float64 theTargetValueHi

◆ setTargetValue()

void ossimPixelFlipper::setTargetValue ( ossim_float64  target_value)
Parameters
target_valueThis is the value to flip.
Note
If clamping is specified, it will take precedence over any target value (or range) test

Definition at line 780 of file ossimPixelFlipper.cpp.

References theMutex, theTargetValueHi, and theTargetValueLo.

Referenced by ossimBitMaskWriter::initializeFlipper(), loadState(), ossimBitMaskWriter::setBogusPixel(), and setProperty().

781 {
782  //---
783  // Since this is the value to replace we will allow for any value as it
784  // won't affect the output null, min and max ranges. This will fix a
785  // tiled nitf with max of 2047(11bit) with edge tile fill values of 2048.
786  //---
787  std::lock_guard<std::recursive_mutex> scopeLock(theMutex);
788 
789  theTargetValueLo = target_value;
790  theTargetValueHi = target_value;
791 }
std::recursive_mutex theMutex
For lock and unlock.
ossim_float64 theTargetValueLo
The value range to replace.
ossim_float64 theTargetValueHi

Member Data Documentation

◆ PF_CLAMP_VALUE_HI_KW

const char ossimPixelFlipper::PF_CLAMP_VALUE_HI_KW = "clamp_value_hi"
static

Definition at line 46 of file ossimPixelFlipper.h.

Referenced by loadState(), and saveState().

◆ PF_CLAMP_VALUE_KW

const char ossimPixelFlipper::PF_CLAMP_VALUE_KW = "clamp_value"
static

Definition at line 44 of file ossimPixelFlipper.h.

Referenced by loadState().

◆ PF_CLAMP_VALUE_LO_KW

const char ossimPixelFlipper::PF_CLAMP_VALUE_LO_KW = "clamp_value_lo"
static

Definition at line 45 of file ossimPixelFlipper.h.

Referenced by loadState(), and saveState().

◆ PF_CLIP_MODE_KW

const char ossimPixelFlipper::PF_CLIP_MODE_KW = "border_clip_mode"
static

Definition at line 47 of file ossimPixelFlipper.h.

Referenced by loadState(), and saveState().

◆ PF_REPLACEMENT_MODE_KW

const char ossimPixelFlipper::PF_REPLACEMENT_MODE_KW = "replacement_mode"
static

Definition at line 43 of file ossimPixelFlipper.h.

Referenced by loadState(), and saveState().

◆ PF_REPLACEMENT_VALUE_KW

const char ossimPixelFlipper::PF_REPLACEMENT_VALUE_KW = "replacement_value"
static

Definition at line 42 of file ossimPixelFlipper.h.

Referenced by loadState(), and saveState().

◆ PF_TARGET_RANGE_KW

const char ossimPixelFlipper::PF_TARGET_RANGE_KW = "target_range"
static

Definition at line 41 of file ossimPixelFlipper.h.

Referenced by getProperty(), loadState(), and saveState().

◆ PF_TARGET_VALUE_KW

const char ossimPixelFlipper::PF_TARGET_VALUE_KW = "target_value"
static

Definition at line 40 of file ossimPixelFlipper.h.

Referenced by getProperty(), getPropertyNames(), loadState(), saveState(), and setProperty().

◆ theBoundingRects

std::vector<ossimIrect> ossimPixelFlipper::theBoundingRects
mutableprotected

Definition at line 267 of file ossimPixelFlipper.h.

Referenced by clipTile(), flipPixels(), and initialize().

◆ theClampingMode

ClampingMode ossimPixelFlipper::theClampingMode
protected

Definition at line 244 of file ossimPixelFlipper.h.

Referenced by flipPixels(), saveState(), setClampValue(), and setClampValues().

◆ theClampValueHi

ossim_float64 ossimPixelFlipper::theClampValueHi
protected

◆ theClampValueLo

ossim_float64 ossimPixelFlipper::theClampValueLo
protected

The range of desired pixel values.

Any pixels outside this range are set to the corresponding clamp value. Note that theReplacementValue is not referenced when clamping.

Definition at line 242 of file ossimPixelFlipper.h.

Referenced by flipPixels(), getMinPixelValue(), print(), saveState(), and setClampValue().

◆ theClipMode

ClipMode ossimPixelFlipper::theClipMode
protected

Border Clip mode.

This will flip to nulls any pixel value outside the specified mode.

Valid modes are:

none bounding_rect valid_vertices

if the mode is "none" then nothing is done. if the mode is "bounding_rect" then the bounding rect for the requested rlevel is used and every pixel outside that

Definition at line 261 of file ossimPixelFlipper.h.

Referenced by clipTile(), flipPixels(), getClipMode(), getClipModeString(), and setClipMode().

◆ theClipTileBuffer

ossimRefPtr<ossimImageData> ossimPixelFlipper::theClipTileBuffer
protected

Definition at line 269 of file ossimPixelFlipper.h.

Referenced by allocateClipTileBuffer(), and clipTile().

◆ theMutex

std::recursive_mutex ossimPixelFlipper::theMutex
mutableprotected

◆ theReplacementMode

ReplacementMode ossimPixelFlipper::theReplacementMode
protected

See documentation for ReplacementMode enum above.

Definition at line 238 of file ossimPixelFlipper.h.

Referenced by flipPixels(), getReplacementMode(), getReplacementModeString(), and setReplacementMode().

◆ theReplacementValue

ossim_float64 ossimPixelFlipper::theReplacementValue
protected

When target values are defined, this is the value the pixel will assume if the pixel falls within the target range (according to the rules for replacement mode)

Definition at line 237 of file ossimPixelFlipper.h.

Referenced by flipPixels(), getReplacementValue(), print(), saveState(), and setReplacementValue().

◆ theTargetValueHi

ossim_float64 ossimPixelFlipper::theTargetValueHi
protected

Definition at line 233 of file ossimPixelFlipper.h.

Referenced by flipPixels(), print(), saveState(), setTargetRange(), and setTargetValue().

◆ theTargetValueLo

ossim_float64 ossimPixelFlipper::theTargetValueLo
protected

The value range to replace.

For a single value replacement, both Lo and Hi are equal. Any pixel within this range will be remapped to the replacement value

Definition at line 232 of file ossimPixelFlipper.h.

Referenced by flipPixels(), getProperty(), print(), saveState(), setTargetRange(), and setTargetValue().

◆ theValidVertices

std::vector<ossimPolygon> ossimPixelFlipper::theValidVertices
mutableprotected

Definition at line 266 of file ossimPixelFlipper.h.

Referenced by clipTile(), flipPixels(), and initialize().


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