/usr/include/ossim/imaging/ossimPixelFlipper.h is in libossim-dev 2.2.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | //*******************************************************************
// Copyright (C) 2002 ImageLinks Inc.
//
// License: MIT
//
// See LICENSE.txt file in the top level directory for more details.
//
// Author: David Burken
//
// Description:
//
// Class to scan pixels and flip target dn pixel value to new dn pixel value.
// This was written to fix partial null pixels.
//
//*************************************************************************
// $Id: ossimPixelFlipper.h 19728 2011-06-06 21:31:17Z dburken $
#ifndef ossimPixelFlipper_HEADER
#define ossimPixelFlipper_HEADER
#include <ossim/imaging/ossimImageSourceFilter.h>
#include <ossim/base/ossimPolygon.h>
#include <mutex>
/**
* 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 theReplacementMode data member documentation for more info.
*/
class OSSIM_DLL ossimPixelFlipper : public ossimImageSourceFilter
{
public:
static const char PF_TARGET_VALUE_KW[];
static const char PF_TARGET_RANGE_KW[];
static const char PF_REPLACEMENT_VALUE_KW[];
static const char PF_REPLACEMENT_MODE_KW[];
static const char PF_CLAMP_VALUE_KW[];
static const char PF_CLAMP_VALUE_LO_KW[];
static const char PF_CLAMP_VALUE_HI_KW[];
static const char PF_CLIP_MODE_KW[];
/**
* 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)
*/
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,
};
/**
* When either a lo and/or hi clamp value is set, the clamping mode will be enabled accordingly
* and override any target replacement defined
*/
enum ClampingMode
{
DISABLED = 0,
CLAMPING_LO = 1,
CLAMPING_HI = 2,
CLAMPING_LO_AND_HI = 3,
};
enum ClipMode
{
NONE = 0,
BOUNDING_RECT = 1,
VALID_VERTICES = 2
};
/** default constructor */
ossimPixelFlipper(ossimObject* owner=NULL);
/** @return "Pixel flipper" as an ossimString. */
virtual ossimString getShortName()const;
/** Initializes the state of the object from theInputConnection. */
virtual void initialize();
/**
* @param tile_rect Rectangle to fill tile with.
*
* @param resLevel Reduced resolution level to grab from.
*
* @return 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.
*/
virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& tile_rect,
ossim_uint32 resLevel=0);
virtual bool saveState(ossimKeywordlist& kwl,
const char* prefix=0)const;
/**
* Method to the load (recreate) the state of an object from a keyword
* list. Return true if ok or false on error.
*/
virtual bool loadState(const ossimKeywordlist& kwl,
const char* prefix=0);
virtual ossimScalarType getOutputScalarType() const;
virtual ossim_float64 getMaxPixelValue (ossim_uint32 band = 0 ) const;
virtual ossim_float64 getMinPixelValue (ossim_uint32 band = 0 ) const;
virtual std::ostream& print(std::ostream& out) const;
/**
* @param target_value This is the value to flip.
* @note If clamping is specified, it will take precedence over any target value (or range) test
*/
void setTargetValue(ossim_float64 target_value);
/**
* 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.
* @param This is the value to flip.
* @note If clamping is specified, it will take precedence over any target range test.
*/
void setTargetRange(ossim_float64 target_min, ossim_float64 target_max);
/**
* @param replacement_value This is the value to flip target to.
* @note If clamping is specified, it will take precedence over any target replacement.
*/
void setReplacementValue(ossim_float64 replacement_value);
/**
* @param clamp_value If 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.
*/
void setClampValue(ossim_float64 clamp_value, bool is_high_clamp_value=true);
void setClampValues(ossim_float64 clamp_value_lo, ossim_float64 clamp_value_hi);
/** @see enum ReplacementMode */
void setReplacementMode(ossimPixelFlipper::ReplacementMode mode);
/** 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. */
bool setReplacementMode(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.
*/
void setClipMode(const ossimString& modeString);
void setClipMode(ClipMode mode);
//ossim_float64 getTargetValue() const;
ossim_float64 getReplacementValue() const;
//ossim_float64 getClampValue() const;
ossimPixelFlipper::ReplacementMode getReplacementMode() const;
ossimString getReplacementModeString() const;
ossimString getClipModeString() const;
ClipMode getClipMode() const;
virtual ossimRefPtr<ossimProperty> getProperty(const ossimString& name)const;
virtual void setProperty(ossimRefPtr<ossimProperty> property);
virtual void getPropertyNames(std::vector<ossimString>& propertyNames)const;
//! This object can be used outside of an image chain for offline processing of existing tile.
template <class T> void flipPixels(T dummy, ossimImageData* inpuTile, ossim_uint32 resLevel);
protected:
/** destructor */
virtual ~ossimPixelFlipper();
template <class T> void clipTile(T dummy,
ossimImageData* inpuTile,
ossim_uint32 resLevel);
/**
* Verifies pixel is in range.
* @return Returns true if in range else false.
*/
bool inRange(ossim_float64 value) const;
void allocateClipTileBuffer(ossimRefPtr<ossimImageData> inputImage);
/** 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 */
ossim_float64 theTargetValueLo;
ossim_float64 theTargetValueHi;
/** 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) */
ossim_float64 theReplacementValue;
ReplacementMode theReplacementMode; //!< See documentation for ReplacementMode enum above
/** 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. */
ossim_float64 theClampValueLo;
ossim_float64 theClampValueHi;
ClampingMode theClampingMode;
/**
* 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
*/
ClipMode theClipMode;
/** For lock and unlock. */
mutable std::recursive_mutex theMutex;
mutable std::vector<ossimPolygon> theValidVertices;
mutable std::vector<ossimIrect> theBoundingRects;
ossimRefPtr<ossimImageData> theClipTileBuffer;
TYPE_DATA
};
#endif
|