Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
BIAS::Median< InputStorageType, OutputStorageType > Class Template Reference

Implements a 2D median filter for images. More...

#include <Filter/Median.hh>

+ Inheritance diagram for BIAS::Median< InputStorageType, OutputStorageType >:
+ Collaboration diagram for BIAS::Median< InputStorageType, OutputStorageType >:

Public Types

enum  TBorderHandling { TBH_full, TBH_same, TBH_valid }
 enum for border calculation, same meanings as in matlab: More...
 

Public Member Functions

void AddDebugLevel (const long int lv)
 
void AddDebugLevel (const std::string &name)
 
virtual FilterNToN
< InputStorageType,
OutputStorageType > * 
Clone () const
 
void CopyNonROIFromSource (const Image< InputStorageType > &src, Image< OutputStorageType > &dst) const
 run over all pixel which do not belong to the roi and set them to the value in the source image regardless of the roi of the source. More...
 
bool DebugLevelIsSet (const long int lv) const
 
bool DebugLevelIsSet (const std::string &name) const
 
virtual int Filter (const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
 virtual function for interface definition More...
 
int Filter3x3x3Color (std::vector< Image< InputStorageType > > &srcs, Image< OutputStorageType > &dst)
 
int Filter3x3x3Grey (std::vector< Image< InputStorageType > > &srcs, Image< OutputStorageType > &dst)
 
int FilterColorImg (const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
 
int FilterColorImgVec (const Image< InputStorageType > &src, Image< OutputStorageType > &dst, unsigned int px, unsigned int py, const Image< unsigned char > *ignorePixels=NULL)
 
int FilterColorImgVec (const Image< InputStorageType > &src, Image< OutputStorageType > &dst, const Image< unsigned char > *ignorePixels=NULL)
 
virtual int FilterFloat (const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
 
int FilterIgnore3x3 (const Image< InputStorageType > &src, Image< OutputStorageType > &dst, const float &threshold) const
 filters using only values above threshold as input More...
 
int FilterIgnoreZero5x5 (const Image< InputStorageType > &src, Image< OutputStorageType > &dst) const
 
virtual int FilterInt (const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
 
int FilterOnlyBelowIgnoreBelow3x3 (const Image< InputStorageType > &src, Image< OutputStorageType > &dst, const float &threshold, const unsigned &min_support=1) const
 Specialized median filter for images with invalid values. More...
 
int FilterOnlyZeroIgnoreZero3x3 (const Image< InputStorageType > &src, Image< OutputStorageType > &dst, const float &Threshold=0.0f) const
 fill spurious gaps in depth maps compute 3x3 median at zero points, thereby ignoring zero values More...
 
int FilterOnlyZeroIgnoreZero5x5 (const Image< InputStorageType > &src, Image< OutputStorageType > &dst, const float &Threshold=0.0f) const
 fill spurious gaps in depth maps compute 5x5 median at zero points, thereby ignoring zero values More...
 
int FilterParallel (Image< InputStorageType > &source, Image< OutputStorageType > &dest, unsigned int numberOfThreads)
 
int FilterRemoveSaltAndPepper (const Image< InputStorageType > &src, Image< OutputStorageType > &dst, const float &Threshold=3.0f) const
 removes "salt and pepper" by replacing outliers (Threshold) with median of neighbourhood. More...
 
int GetBorderHandling () const
 
void GetBorders (int &border_x, int &border_y) const
 
int GetDebugLevel () const
 
std::ostream & GetDebugStream () const
 
void GetDebugStream (std::ostream &os) const
 
 Median ()
 
 Median (const Median< InputStorageType, OutputStorageType > &other)
 
long int Name2DebugLevel (const std::string &name) const
 looks up a debuglevel in the internal map, returns 0 if not found More...
 
long int NewDebugLevel (const std::string &name)
 creates a new debuglevel More...
 
void PrintDebugLevel (std::ostream &os=std::cout) const
 
void RemoveDebugLevel (const long int lv)
 
void RemoveDebugLevel (const std::string &name)
 
void SetBorderHandling (const int bh)
 
void SetDebugLevel (const long int lv)
 
void SetDebugLevel (const std::string &name)
 
void SetDebugStream (const std::ostream &os)
 
void SetMinValue (float min)
 
void SetNonROIToValue (Image< OutputStorageType > &dst, const std::vector< OutputStorageType > &t) const
 run over all pixel which do not belong to the roi and set them to some value (typically black) More...
 
void SetSize (int newsize, int secondsize=-1)
 
void ShowDebugLevel (std::ostream &os=std::cout) const
 prints all internally known debuglevels More...
 
virtual ~Median ()
 

Static Public Member Functions

static long int GetGlobalDebugLevel ()
 
static void SetGlobalDebugLevel (long int lev)
 

Protected Member Functions

long ConsumeNextFreeDebuglevel_ ()
 returns the next available debuglevel More...
 
virtual void GetBordersValid_ (int &border_x, int &border_y) const
 

Protected Attributes

int _FilterBorderHandling
 
long int _liDebugLevel
 
long int _liNextDebugLevel
 new concept, debuglevel are managed here in the debug class More...
 
int _MedianSize
 half win size of median, 1 means 3x3 More...
 
float _MinValue
 
int _secondSize
 Use this variable for non-quadratic filter sizes e.g. 3x1. More...
 
std::map< std::string, long int > _String2Debuglevel
 

Static Protected Attributes

static std::ostream _zDebugStream
 
static long int GlobalDebugLevel = 0
 

Detailed Description

template<class InputStorageType, class OutputStorageType>
class BIAS::Median< InputStorageType, OutputStorageType >

Implements a 2D median filter for images.

Examples:
ExampleMedian.cpp, ExampleMedian3x3x3.cpp, and ExampleRemoveSaltAndPepper.cpp.

Definition at line 39 of file Median.hh.

Member Enumeration Documentation

template<class InputStorageType, class OutputStorageType>
enum BIAS::FilterBase::TBorderHandling
inherited

enum for border calculation, same meanings as in matlab:

  • TBH_valid: returns only the pixels whose values can be computed without using zero padding of the input image. The resulting output image is smaller than the input image. The ROI of the output image is set accordingly.
  • TBH_same: returns the set of pixels that can be computed by applying the filter to all pixels that are actually part of the input image. Border pixels are computed using zero padding, but the center pixel of the computational kernel is applied only to pixels in the image. This results in an output image that is the same size as the input image.
  • TBH_full: returns the full convolution. This means conv2 returns all pixels for which any of the pixels in the computational molecule overlap pixels in the image, even when the center pixel is outside the input image. The resulting output image is larger than the input image. This is not implemented at the moment.
Enumerator
TBH_full 
TBH_same 
TBH_valid 

Definition at line 98 of file FilterBase.hh.

Constructor & Destructor Documentation

template<class InputStorageType , class OutputStorageType >
Median::Median ( )
template<class InputStorageType, class OutputStorageType>
Median::Median ( const Median< InputStorageType, OutputStorageType > &  other)
template<class InputStorageType , class OutputStorageType >
Median::~Median ( )
virtual

Definition at line 53 of file Median.cpp.

Member Function Documentation

void BIAS::Debug::AddDebugLevel ( const long int  lv)
inlineinherited
void BIAS::Debug::AddDebugLevel ( const std::string &  name)
inlineinherited

Definition at line 362 of file Debug.hh.

template<class InputStorageType, class OutputStorageType>
virtual FilterNToN<InputStorageType, OutputStorageType>* BIAS::Median< InputStorageType, OutputStorageType >::Clone ( ) const
inlinevirtual

Implements BIAS::FilterNToN< InputStorageType, OutputStorageType >.

Definition at line 63 of file Median.hh.

long BIAS::Debug::ConsumeNextFreeDebuglevel_ ( )
inlineprotectedinherited

returns the next available debuglevel

Author
woelk 09/2006

Definition at line 521 of file Debug.hh.

template<class InputStorageType, class OutputStorageType>
void FilterBase::CopyNonROIFromSource ( const Image< InputStorageType > &  src,
Image< OutputStorageType > &  dst 
) const
inherited

run over all pixel which do not belong to the roi and set them to the value in the source image regardless of the roi of the source.

Both images must have same size.

Author
koeser 12/2008

Definition at line 135 of file FilterBase.cpp.

References BIAS::ImageBase::GetChannelCount(), BIAS::ROI::GetCorners(), BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageDataArray(), BIAS::ImageBase::GetROI(), BIAS::ImageBase::GetWidth(), and BIAS::ROI_Corners.

bool BIAS::Debug::DebugLevelIsSet ( const long int  lv) const
inlineinherited
bool BIAS::Debug::DebugLevelIsSet ( const std::string &  name) const
inlineinherited

Definition at line 350 of file Debug.hh.

template<class InputStorageType, class OutputStorageType>
int Median::Filter ( const Image< InputStorageType > &  src,
Image< OutputStorageType > &  dst 
)
virtual
template<class InputStorageType, class OutputStorageType>
int Median::Filter3x3x3Color ( std::vector< Image< InputStorageType > > &  srcs,
Image< OutputStorageType > &  dst 
)
template<class InputStorageType, class OutputStorageType>
int Median::Filter3x3x3Grey ( std::vector< Image< InputStorageType > > &  srcs,
Image< OutputStorageType > &  dst 
)
template<class InputStorageType, class OutputStorageType>
int Median::FilterColorImg ( const Image< InputStorageType > &  src,
Image< OutputStorageType > &  dst 
)
template<class InputStorageType, class OutputStorageType>
int Median::FilterColorImgVec ( const Image< InputStorageType > &  src,
Image< OutputStorageType > &  dst,
unsigned int  px,
unsigned int  py,
const Image< unsigned char > *  ignorePixels = NULL 
)
template<class InputStorageType, class OutputStorageType>
int Median::FilterColorImgVec ( const Image< InputStorageType > &  src,
Image< OutputStorageType > &  dst,
const Image< unsigned char > *  ignorePixels = NULL 
)
template<class InputStorageType, class OutputStorageType>
int Median::FilterFloat ( const Image< InputStorageType > &  src,
Image< OutputStorageType > &  dst 
)
virtual
template<class InputStorageType, class OutputStorageType>
int Median::FilterIgnore3x3 ( const Image< InputStorageType > &  src,
Image< OutputStorageType > &  dst,
const float &  threshold 
) const
template<class InputStorageType, class OutputStorageType>
int Median::FilterIgnoreZero5x5 ( const Image< InputStorageType > &  src,
Image< OutputStorageType > &  dst 
) const
template<class InputStorageType, class OutputStorageType>
int Median::FilterInt ( const Image< InputStorageType > &  src,
Image< OutputStorageType > &  dst 
)
virtual
template<class InputStorageType, class OutputStorageType>
int Median::FilterOnlyBelowIgnoreBelow3x3 ( const Image< InputStorageType > &  src,
Image< OutputStorageType > &  dst,
const float &  threshold,
const unsigned &  min_support = 1 
) const

Specialized median filter for images with invalid values.

Only positions containing an invalid value (i.e. a value < threshold) are touched by the filter. They are set to the median of all neighboring pixels, which are not invalid themselves, iff a minimium number of min_support_pixels are found. Otherwise the invalid value is preserved.

Author
woelk 06/2008 (c) www.vision-n.de

Definition at line 664 of file Median.cpp.

References BIAS::ImageBase::GetChannelCount(), BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageDataArray(), BIAS::ImageBase::GetWidth(), BIAS::Image< StorageType >::Init(), and BIAS::ImageBase::SamePixelAndChannelCount().

template<class InputStorageType, class OutputStorageType>
int Median::FilterOnlyZeroIgnoreZero3x3 ( const Image< InputStorageType > &  src,
Image< OutputStorageType > &  dst,
const float &  Threshold = 0.0f 
) const

fill spurious gaps in depth maps compute 3x3 median at zero points, thereby ignoring zero values

Parameters
Thresholdall values<=threshold are rewritten, all values>threshold are used for median sorting

Definition at line 559 of file Median.cpp.

References BIAS::ImageBase::GetChannelCount(), BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageDataArray(), BIAS::ImageBase::GetPixelCount(), BIAS::ImageBase::GetWidth(), BIAS::Image< StorageType >::Init(), BIAS::ImageBase::IsEmpty(), BIAS::Image< StorageType >::Release(), and BIAS::ImageBase::SamePixelAndChannelCount().

template<class InputStorageType, class OutputStorageType>
int Median::FilterOnlyZeroIgnoreZero5x5 ( const Image< InputStorageType > &  src,
Image< OutputStorageType > &  dst,
const float &  Threshold = 0.0f 
) const

fill spurious gaps in depth maps compute 5x5 median at zero points, thereby ignoring zero values

Parameters
Thresholdall values<=threshold are rewritten, all values>threshold are used for median sorting

Definition at line 366 of file Median.cpp.

References BIAS::ImageBase::GetChannelCount(), BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageDataArray(), BIAS::ImageBase::GetPixelCount(), BIAS::ImageBase::GetWidth(), BIAS::Image< StorageType >::Init(), BIAS::ImageBase::IsEmpty(), BIAS::Image< StorageType >::Release(), and BIAS::ImageBase::SamePixelAndChannelCount().

template<class InputStorageType, class OutputStorageType>
int Median::FilterParallel ( Image< InputStorageType > &  source,
Image< OutputStorageType > &  dest,
unsigned int  numberOfThreads 
)
template<class InputStorageType, class OutputStorageType>
int Median::FilterRemoveSaltAndPepper ( const Image< InputStorageType > &  src,
Image< OutputStorageType > &  dst,
const float &  Threshold = 3.0f 
) const
template<class InputStorageType, class OutputStorageType>
int BIAS::FilterBase< InputStorageType, OutputStorageType >::GetBorderHandling ( ) const
inlineinherited

Definition at line 129 of file FilterBase.hh.

template<class InputStorageType , class OutputStorageType >
void FilterBase::GetBorders ( int &  border_x,
int &  border_y 
) const
inherited
template<class InputStorageType , class OutputStorageType >
void Median::GetBordersValid_ ( int &  border_x,
int &  border_y 
) const
protectedvirtual
int BIAS::Debug::GetDebugLevel ( ) const
inlineinherited
std::ostream& BIAS::Debug::GetDebugStream ( ) const
inlineinherited

Definition at line 405 of file Debug.hh.

void BIAS::Debug::GetDebugStream ( std::ostream &  os) const
inlineinherited

Definition at line 414 of file Debug.hh.

static long int BIAS::Debug::GetGlobalDebugLevel ( )
inlinestaticinherited

Definition at line 431 of file Debug.hh.

long int BIAS::Debug::Name2DebugLevel ( const std::string &  name) const
inlineinherited

looks up a debuglevel in the internal map, returns 0 if not found

Author
woelk 09/2006

Definition at line 454 of file Debug.hh.

long int BIAS::Debug::NewDebugLevel ( const std::string &  name)
inlineinherited
void BIAS::Debug::PrintDebugLevel ( std::ostream &  os = std::cout) const
inlineinherited

Definition at line 383 of file Debug.hh.

void BIAS::Debug::RemoveDebugLevel ( const long int  lv)
inlineinherited

Definition at line 369 of file Debug.hh.

void BIAS::Debug::RemoveDebugLevel ( const std::string &  name)
inlineinherited

Definition at line 376 of file Debug.hh.

template<class InputStorageType, class OutputStorageType>
void BIAS::FilterBase< InputStorageType, OutputStorageType >::SetBorderHandling ( const int  bh)
inlineinherited
void BIAS::Debug::SetDebugLevel ( const long int  lv)
inlineinherited
void BIAS::Debug::SetDebugLevel ( const std::string &  name)
inlineinherited

Definition at line 325 of file Debug.hh.

void BIAS::Debug::SetDebugStream ( const std::ostream &  os)
inlineinherited

Definition at line 398 of file Debug.hh.

static void BIAS::Debug::SetGlobalDebugLevel ( long int  lev)
inlinestaticinherited

Definition at line 424 of file Debug.hh.

template<class InputStorageType, class OutputStorageType>
void BIAS::Median< InputStorageType, OutputStorageType >::SetMinValue ( float  min)
inline

Definition at line 151 of file Median.hh.

template<class InputStorageType , class OutputStorageType>
void FilterBase::SetNonROIToValue ( Image< OutputStorageType > &  dst,
const std::vector< OutputStorageType > &  t 
) const
inherited

run over all pixel which do not belong to the roi and set them to some value (typically black)

Author
koeser 12/2008

Definition at line 84 of file FilterBase.cpp.

References BIAS::ImageBase::GetChannelCount(), BIAS::ROI::GetCorners(), BIAS::ImageBase::GetHeight(), BIAS::Image< StorageType >::GetImageDataArray(), BIAS::ImageBase::GetROI(), BIAS::ImageBase::GetWidth(), and BIAS::ROI_Corners.

template<class InputStorageType, class OutputStorageType>
void BIAS::Median< InputStorageType, OutputStorageType >::SetSize ( int  newsize,
int  secondsize = -1 
)
inline
void BIAS::Debug::ShowDebugLevel ( std::ostream &  os = std::cout) const
inlineinherited

prints all internally known debuglevels

Author
woelk 09/2006

Definition at line 496 of file Debug.hh.

Member Data Documentation

template<class InputStorageType, class OutputStorageType>
int BIAS::FilterBase< InputStorageType, OutputStorageType >::_FilterBorderHandling
protectedinherited
long int BIAS::Debug::_liDebugLevel
protectedinherited

Definition at line 510 of file Debug.hh.

Referenced by BIAS::Debug::operator=(), and BIAS::ImageBase::operator=().

long int BIAS::Debug::_liNextDebugLevel
protectedinherited

new concept, debuglevel are managed here in the debug class

Definition at line 516 of file Debug.hh.

Referenced by BIAS::Debug::operator=().

template<class InputStorageType, class OutputStorageType>
int BIAS::Median< InputStorageType, OutputStorageType >::_MedianSize
protected

half win size of median, 1 means 3x3

Definition at line 159 of file Median.hh.

Referenced by BIAS::Median< InputStorageType, OutputStorageType >::Median().

template<class InputStorageType, class OutputStorageType>
float BIAS::Median< InputStorageType, OutputStorageType >::_MinValue
protected
template<class InputStorageType, class OutputStorageType>
int BIAS::Median< InputStorageType, OutputStorageType >::_secondSize
protected

Use this variable for non-quadratic filter sizes e.g. 3x1.

Definition at line 162 of file Median.hh.

Referenced by BIAS::Median< InputStorageType, OutputStorageType >::Median().

std::map<std::string, long int> BIAS::Debug::_String2Debuglevel
protectedinherited

Definition at line 517 of file Debug.hh.

Referenced by BIAS::Debug::operator=().

std::ostream BIAS::Debug::_zDebugStream
staticprotectedinherited

Definition at line 511 of file Debug.hh.

Referenced by BIAS::Debug::operator=().

long int BIAS::Debug::GlobalDebugLevel = 0
staticprotectedinherited

Definition at line 513 of file Debug.hh.


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