23 static const char* WEIGHTS_KW =
"weights";
26 "ossimBandAverageFilter",
36 const std::vector<double>& weights)
71 if(!inputData.
valid())
141 "Unsupported scalar type in file %d at line %d",
197 for(bandIndex = 0; bandIndex < inputBands; ++bandIndex)
201 if(minPix < minValue)
221 for(bandIndex = 0; bandIndex < inputBands; ++bandIndex)
225 if(maxPix > maxValue)
275 inputBands[i] =
static_cast<T*
>(inputDataObject->
getBuf(i));
276 nullValues[i] = inputDataObject->
getNullPix(i);
288 for(i = 0; i < upperBound; ++i)
291 double sumWeights=0.0;
296 for(bandIndex = 0; bandIndex < numberOfBands; ++bandIndex)
300 if(*inputBands[bandIndex] != nullValues[bandIndex])
302 value +=
theWeights[bandIndex]*((double)*inputBands[bandIndex]);
306 ++inputBands[bandIndex];
311 if(sumWeights != 0.0)
318 value = outputNullPix;
321 *outputBuf =
static_cast<T
>(value);
334 weightString = weightString.
trim();
338 if(weightString !=
"")
341 std::vector<ossimString> weightList = weightString.
split(
" ");
360 const char* prefix)
const 367 ostream_iterator<double>(out,
" "));
370 weightString = weightString.
trim();
375 weightString.
c_str(),
OSSIMDLLEXPORT void ossimSetError(const char *className, ossim_int32 error, const char *fmtString=0,...)
16 bit unsigned integer (15 bits used)
virtual ossim_uint32 getWidth() const
virtual bool isSourceEnabled() const
virtual void initialize()
allocates its tile buffer
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Saves its weights to a keywordlist.
double getWeight(ossim_uint32 band) const
simple access method to get a weight
virtual ossim_uint32 getNumberOfBands() const
std::basic_stringstream< char > stringstream
Class for char mixed input and output memory streams.
virtual void setImageRectangle(const ossimIrect &rect)
ossimRefPtr< ossimImageData > theTile
This filter outputs a single band that is the weighted average of all the input bands retrieved from ...
Represents serializable keyword/value map.
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
const char * find(const char *key) const
void split(std::vector< ossimString > &result, const ossimString &separatorList, bool skipBlankFields=false) const
Splits this string into a vector of strings (fields) using the delimiter list specified.
virtual ossimDataObjectStatus getDataObjectStatus() const
virtual ossim_uint32 getHeight() const
16 bit unsigned integer (14 bits used)
static const ossimErrorCode OSSIM_ERROR
virtual ossimString getClassName() const
16 bit unsigned integer (13 bits used)
unsigned short ossim_uint16
virtual void initialize()
Initialize the data buffer.
virtual ~ossimBandAverageFilter()
virtual void initialize()
virtual double getMinPixelValue(ossim_uint32 band=0) const
Returns the min pixel of the band.
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
OSSIM_DLL double defaultMin(ossimScalarType scalarType)
static ossimImageDataFactory * instance()
virtual ossimDataObjectStatus validate() const
signed short ossim_sint16
ossimImageSource * theInputConnection
unsigned int ossim_uint32
virtual const ossim_float64 * getNullPix() const
32 bit normalized floating point
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
loads its weights to a keywordlist
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
virtual double getMinPixelValue(ossim_uint32 band=0) const
We will use the min of all bands as our min.
virtual ossimRefPtr< ossimImageData > create(ossimSource *owner, ossimScalarType scalar, ossim_uint32 bands=1) const
void setWeight(ossim_uint32 band, double weight)
Sinple access method to set the weight of a band, We make sure that it is a positive weight...
virtual ossimScalarType getScalarType() const
virtual void makeBlank()
Initializes data to null pixel values.
64 bit normalized floating point
16 bit unsigned integer (11 bits used)
OSSIM_DLL double defaultMax(ossimScalarType scalarType)
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &rect, ossim_uint32 resLevel=0)
Since this filter is going to operate in native pixel type we will use a tmeplate method to do this...
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
virtual double getMaxPixelValue(ossim_uint32 band=0) const
Returns the max pixel of the band.
virtual const void * getBuf() const
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string's contents...
virtual double getNullPixelValue(ossim_uint32 band=0) const
Since we are merging all bands we will use the null pix of the first input band as our null pix...
RTTI_DEF1(ossimBandAverageFilter, "ossimBandAverageFilter", ossimImageSourceFilter)
virtual ossim_uint32 getNumberOfOutputBands() const
The data object argument is deprecated and should not be used.
std::vector< double > theWeights
virtual double getMaxPixelValue(ossim_uint32 band=0) const
We will use the max of all bands as our max.
unsigned char ossim_uint8
virtual double getNullPixelValue(ossim_uint32 band=0) const
Each band has a null pixel associated with it.
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)
16 bit unsigned integer (12 bits used)
void averageInput(T dummyVariable, ossimRefPtr< ossimImageData > inputDataObject)