25 "ossimMeanMedianFilter",
29 static const ossimString WINDOW_SIZE_KW =
"window_size";
30 static const ossimString FILTER_TYPE_KW =
"filter_type";
31 static const ossimString AUTO_GROW_KW =
"auto_grow_rectangle_flag";
36 theFilterType(OSSIM_MEDIAN),
38 theEnableFillNullFlag(false),
39 theAutoGrowRectFlag(false)
59 rect.
ul().
y - halfSize,
60 rect.
lr().
x + halfSize,
61 rect.
lr().
y + halfSize);
65 if(!inputData.valid() || !inputData->getBuf())
282 <<
"ossimMeanMedianFilter::applyFilter WARNING:\n" 283 <<
"Unhandled scalar type!" << endl;
309 for(bandIdx = 0; bandIdx < numberOfBands; ++bandIdx)
311 T* inputBuf = (T*)inputData->
getBuf(bandIdx);
314 if(inputBuf&&outputBuf)
316 for(
y = 0;
y < oh; ++
y)
318 for(
x = 0;
x < ow; ++
x)
325 values[kernelIdx] = *(inputBuf+kernelX + kernelY*iw);
331 if(values.size() > 0)
333 double sum = std::accumulate(values.begin(),
336 double average = sum/(double)values.size();
337 (*outputBuf) = (T)average;
343 inputBuf+=(halfWindow<<1);
350 for(bandIdx = 0; bandIdx < numberOfBands; ++bandIdx)
352 T* inputBuf = (T*)inputData->
getBuf(bandIdx);
355 if(inputBuf&&outputBuf)
357 for(
y = 0;
y < oh; ++
y)
359 for(
x = 0;
x < ow; ++
x)
366 T tempValue = *(inputBuf+kernelX + kernelY*iw);
370 values.push_back((
double)tempValue);
376 if(values.size() > 0)
378 double accumulate = std::accumulate(values.begin(),
381 double average = accumulate/(double)values.size();
382 if(*(inputBuf+halfWindow + halfWindow*iw) == np)
386 (*outputBuf) = (T)average;
395 (*outputBuf) = (T)average;
406 inputBuf+=(halfWindow<<1);
429 std::vector<double> values;
439 for(bandIdx = 0; bandIdx < numberOfBands; ++bandIdx)
441 T* inputBuf = (T*)inputData->
getBuf(bandIdx);
443 if (!inputBuf || !outputBuf)
448 const T NP = (T)inputData->
getNullPix(bandIdx);
450 for(
y = 0;
y < oh; ++
y)
452 for(
x = 0;
x < ow; ++
x)
455 const T CP = *(inputBuf+halfWindow + halfWindow*iw);
463 T tempValue = *(inputBuf+kernelX + kernelY*iw);
467 values.push_back((
double)tempValue);
472 if(values.size() > 0)
474 double accumulate = std::accumulate(values.begin(),
477 double average = accumulate/(double)values.size();
478 (*outputBuf) = (T)average;
498 inputBuf+=(halfWindow<<1);
528 for(bandIdx = 0; bandIdx < numberOfBands; ++bandIdx)
530 T* inputBuf = (T*)inputData->
getBuf(bandIdx);
533 if(inputBuf&&outputBuf)
535 for(
y = 0;
y < oh; ++
y)
537 for(
x = 0;
x < ow; ++
x)
544 values[kernelIdx] = *(inputBuf+kernelX + kernelY*iw);
549 std::sort(values.begin(),
552 if(values.size() > 0)
554 (*outputBuf) = values[values.size()>>1];
560 inputBuf+=(halfWindow<<1);
567 for(bandIdx = 0; bandIdx < numberOfBands; ++bandIdx)
569 T* inputBuf = (T*)inputData->
getBuf(bandIdx);
572 if(inputBuf&&outputBuf)
574 for(
y = 0;
y < oh; ++
y)
576 for(
x = 0;
x < ow; ++
x)
583 T tempValue = *(inputBuf+kernelX + kernelY*iw);
587 values.push_back(tempValue);
592 std::sort(values.begin(),
595 if(values.size() > 0)
597 if(*(inputBuf+halfWindow + halfWindow*iw) == np)
601 (*outputBuf) = values[values.size()>>1];
610 (*outputBuf) = values[values.size()>>1];
621 inputBuf+=(halfWindow<<1);
644 std::vector<T> values;
654 for(bandIdx = 0; bandIdx < numberOfBands; ++bandIdx)
656 T* inputBuf = (T*)inputData->
getBuf(bandIdx);
658 if (!inputBuf || !outputBuf)
663 const T NP = (T)inputData->
getNullPix(bandIdx);
665 for(
y = 0;
y < oh; ++
y)
667 for(
x = 0;
x < ow; ++
x)
670 const T CP = *(inputBuf+halfWindow + halfWindow*iw);
678 T tempValue = *(inputBuf+kernelX + kernelY*iw);
682 values.push_back(tempValue);
687 std::sort(values.begin(),
690 if(values.size() > 0)
692 (*outputBuf) = values[values.size()>>1];
711 inputBuf+=(halfWindow<<1);
722 if(!property.
valid())
729 if (name == WINDOW_SIZE_KW)
733 else if (name == FILTER_TYPE_KW)
738 else if (name == AUTO_GROW_KW)
741 property->valueToString(value);
752 if (name == WINDOW_SIZE_KW)
763 else if (name == FILTER_TYPE_KW)
765 std::vector<ossimString> constraintList;
776 else if (name == AUTO_GROW_KW)
787 std::vector<ossimString>& propertyNames)
const 789 propertyNames.push_back(WINDOW_SIZE_KW);
790 propertyNames.push_back(FILTER_TYPE_KW);
791 propertyNames.push_back(AUTO_GROW_KW);
797 const char* prefix)
const 800 WINDOW_SIZE_KW.
c_str(),
804 FILTER_TYPE_KW.
c_str(),
808 AUTO_GROW_KW.
c_str(),
818 const char* lookup = NULL;
820 lookup = kwl.
find(prefix, WINDOW_SIZE_KW.
c_str());
826 lookup = kwl.
find(prefix, FILTER_TYPE_KW.
c_str());
833 lookup = kwl.
find(prefix, AUTO_GROW_KW.
c_str());
852 std::vector<ossimString> list;
886 std::vector<ossimString> list;
892 std::vector<ossimString>& list)
const 16 bit unsigned integer (15 bits used)
virtual ossim_uint32 getWidth() const
virtual bool isSourceEnabled() const
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
This will return the bounding rect of the source.
virtual void setDescription(const ossimString &description)
virtual void setProperty(ossimRefPtr< ossimProperty > property)
virtual ossim_uint32 getNumberOfBands() const
virtual void setImageRectangle(const ossimIrect &rect)
Represents serializable keyword/value map.
const char * find(const char *key) const
static ossimString toString(bool aValue)
Numeric to string methods.
const ossimIpt & ul() const
virtual ossimDataObjectStatus getDataObjectStatus() const
virtual ossim_uint32 getHeight() const
16 bit unsigned integer (14 bits used)
ossim_uint32 toUInt32() const
16 bit unsigned integer (13 bits used)
unsigned short ossim_uint16
virtual ossimObject * dup() const
virtual void initialize()
void set_ul(const ossimIpt &pt)
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
virtual void loadTile(const void *src, const ossimIrect &src_rect, ossimInterleaveType il_type)
virtual ossimDataObjectStatus validate() const
signed short ossim_sint16
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
virtual void setImageRectangleAndBands(const ossimIrect &rect, ossim_uint32 numberOfBands)
bool toBool() const
String to numeric methods.
unsigned int ossim_uint32
virtual const ossim_float64 * getNullPix() const
32 bit normalized floating point
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
const ossimIpt & lr() const
static ossimString downcase(const ossimString &aString)
virtual ossimScalarType getScalarType() const
64 bit normalized floating point
16 bit unsigned integer (11 bits used)
void set_lr(const ossimIpt &pt)
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
virtual const void * getBuf() const
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string's contents...
virtual void setDataObjectStatus(ossimDataObjectStatus status) const
Full list found in ossimConstants.h.
ossimDataObjectStatus
Definitions for data object status.
unsigned char ossim_uint8
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
void setCacheRefreshBit()
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)
16 bit unsigned integer (12 bits used)