SourceXtractorPlusPlus  0.13
Please provide a description of the project.
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
SourceXtractor::MedianFilter< T > Class Template Reference

#include <MedianFilter.h>

Public Member Functions

 MedianFilter (int box_width, int box_height)
 
 MedianFilter (const std::array< int, 2 > &box)
 
auto operator() (const Image< T > &image, const Image< T > &variance, T threshold=0) const -> std::pair< std::shared_ptr< VectorImage< T >>, std::shared_ptr< VectorImage< T >>>
 

Private Member Functions

std::vector< T > getBox (const Image< T > &img, int x, int y) const
 

Static Private Member Functions

static T getMedian (std::vector< T > &data)
 
static int clip (int position, int box_size, int image_size)
 

Private Attributes

int m_box_width
 
int m_box_height
 

Detailed Description

template<typename T>
class SourceXtractor::MedianFilter< T >

Functor that applies a median filter over a pair of image/variance image

Template Parameters
TPixel type of the filtered image A median filter takes as parameters the width and height of the smoothing box. Each pixel is computed as the median of the values of the pixels contained within a box centered at its coordinates iff the median value differs from the actual value by more than a given threshold.

If the value of the pixel is replaced, the value of the variance at the same coordinates is replaced also by the median of the variances contained within the box.

There is no padding. At the edges whe box size is symmetrically clipped to the number of available pixels.

Definition at line 40 of file MedianFilter.h.

Constructor & Destructor Documentation

◆ MedianFilter() [1/2]

template<typename T >
SourceXtractor::MedianFilter< T >::MedianFilter ( int  box_width,
int  box_height 
)
inline

Constructor

Parameters
box_width
box_height

Definition at line 47 of file MedianFilter.h.

◆ MedianFilter() [2/2]

template<typename T >
SourceXtractor::MedianFilter< T >::MedianFilter ( const std::array< int, 2 > &  box)
inline

Constructor

Parameters
boxA two dimensional array where the first value corresponds to the width, and the second to the height.

Definition at line 55 of file MedianFilter.h.

Member Function Documentation

◆ clip()

template<typename T >
static int SourceXtractor::MedianFilter< T >::clip ( int  position,
int  box_size,
int  image_size 
)
inlinestaticprivate

Symmetrically clip the size of the smoothing box depending on the number of available pixels. This is a 1-D version that is applied to X and Y separately.

Parameters
positionCoordinate where the box will be centered
box_sizeSize of the smoothing box
image_sizeImage size
Returns
As many pixels as could be read safely from the image, up to box_size

Definition at line 126 of file MedianFilter.h.

Referenced by SourceXtractor::MedianFilter< T >::getBox().

◆ getBox()

template<typename T >
std::vector<T> SourceXtractor::MedianFilter< T >::getBox ( const Image< T > &  img,
int  x,
int  y 
) const
inlineprivate

Get the pixel values contained within a box centered at x,y

Definition at line 138 of file MedianFilter.h.

References std::back_inserter(), SourceXtractor::MedianFilter< T >::clip(), SourceXtractor::Image< T >::getHeight(), SourceXtractor::Image< T >::getValue(), SourceXtractor::Image< T >::getWidth(), std::inserter(), SourceXtractor::MedianFilter< T >::m_box_height, SourceXtractor::MedianFilter< T >::m_box_width, x, and y.

Referenced by SourceXtractor::MedianFilter< T >::operator()().

Here is the call graph for this function:

◆ getMedian()

template<typename T >
static T SourceXtractor::MedianFilter< T >::getMedian ( std::vector< T > &  data)
inlinestaticprivate

Convenience method to compute the median of a vector

Parameters
dataThe vector on which to compute the median. It will be modified.

Definition at line 106 of file MedianFilter.h.

References std::vector< T >::begin(), std::vector< T >::end(), std::vector< T >::size(), and std::sort().

Referenced by SourceXtractor::MedianFilter< T >::operator()().

Here is the call graph for this function:

◆ operator()()

template<typename T >
auto SourceXtractor::MedianFilter< T >::operator() ( const Image< T > &  image,
const Image< T > &  variance,
threshold = 0 
) const -> std::pair<std::shared_ptr<VectorImage<T>>, std::shared_ptr<VectorImage<T>>>
inline

Call operator

Parameters
imageImage to filter
varianceAssociated variance map
thresholdThe pixel is replaced only if the median and the actual value differ by at least this value. Defaults to 0 (always replaced).
Returns
A pair of new images containing the filtered image and the filtered variance map

Definition at line 70 of file MedianFilter.h.

References SourceXtractor::VectorImage< T >::create(), SourceXtractor::MedianFilter< T >::getBox(), SourceXtractor::Image< T >::getHeight(), SourceXtractor::MedianFilter< T >::getMedian(), SourceXtractor::Image< T >::getValue(), SourceXtractor::Image< T >::getWidth(), std::make_pair(), x, and y.

Here is the call graph for this function:

Member Data Documentation

◆ m_box_height

template<typename T >
int SourceXtractor::MedianFilter< T >::m_box_height
private

Definition at line 99 of file MedianFilter.h.

Referenced by SourceXtractor::MedianFilter< T >::getBox().

◆ m_box_width

template<typename T >
int SourceXtractor::MedianFilter< T >::m_box_width
private

Definition at line 99 of file MedianFilter.h.

Referenced by SourceXtractor::MedianFilter< T >::getBox().


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