iRoCS Toolbox  1.1.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes
atb::DericheFilter< DataT, Dim > Class Template Reference

The DericheFilter class implements the Deriche filter, which approximates a Gaussian filter using a recursive formulation. More...

#include "libArrayToolbox/DericheFilter.hh"

Inheritance diagram for atb::DericheFilter< DataT, Dim >:
Collaboration diagram for atb::DericheFilter< DataT, Dim >:

Public Types

typedef DataT ResultT
 

Public Member Functions

 DericheFilter (BoundaryTreatmentType btType=ValueBT, DataT const &boundaryValue=traits< DataT >::zero)
 Constructor. More...
 
 DericheFilter (blitz::TinyVector< double, Dim > const &sigmaUm, BoundaryTreatmentType btType=ValueBT, DataT const &boundaryValue=traits< DataT >::zero)
 Constructor. More...
 
virtual ~DericheFilter ()
 Destructor. More...
 
virtual void apply (Array< DataT, Dim > const &data, Array< DataT, Dim > &result, iRoCS::ProgressReporter *pr=NULL) const
 Apply the filter to the given Array. More...
 
void apply (blitz::Array< DataT, Dim > const &data, blitz::TinyVector< double, Dim > const &elementSizeUm, blitz::Array< DataT, Dim > &filtered, iRoCS::ProgressReporter *pr=NULL) const
 Application of the Deriche filter onto the data Array using the standard deviations passed to the filter object. More...
 
virtual void applyAlongDim (Array< DataT, Dim > const &data, Array< DataT, Dim > &result, int dim, iRoCS::ProgressReporter *pr=NULL) const
 Apply the filter along the specified dimension. More...
 
void applyAlongDim (blitz::Array< DataT, Dim > const &data, blitz::TinyVector< double, Dim > const &elementSizeUm, blitz::Array< DataT, Dim > &filtered, int dim, iRoCS::ProgressReporter *pr=NULL) const
 Application of the Deriche filter onto the data Array along the specified dimension. More...
 
BoundaryTreatment< DataT, Dim > const & boundaryTreatment () const
 Get a read-only reference to the boundary treatment object associated with this filter. More...
 
void setBoundaryTreatment (BoundaryTreatmentType bt, DataT const &boundaryValue=traits< DataT >::zero)
 Change the boundary treatment type to the type specified. More...
 
void setBoundaryTreatment (BoundaryTreatment< DataT, Dim > const &bt)
 Change the boundary treatment type to the type specified. More...
 
void setSigmaUm (blitz::TinyVector< double, Dim > const &sigmaUm)
 Set the standard deviations of the Deriche filter. More...
 
void setSigmaUmInDim (int dim, double sigmaUm)
 Set the standard deviation of the Deriche filter along the given dimension. More...
 
blitz::TinyVector< double, Dim > const & sigmaUm () const
 Get the standard deviations of the Deriche filter. More...
 
double sigmaUmInDim (int dim) const
 Get the standard deviation of the Deriche filter along the given dimension. More...
 

Static Public Member Functions

static void DericheFilter (blitz::Array< DataT, Dim > const &data, blitz::TinyVector< double, Dim > const &elementSizeUm, blitz::Array< DataT, Dim > &filtered, blitz::TinyVector< double, Dim > const &sigmaUm, BoundaryTreatmentType btType=ValueBT, DataT const &boundaryValue=traits< DataT >::zero, iRoCS::ProgressReporter *pr=NULL)
 Application of the Deriche filter onto the data Array using the standard deviations passed. More...
 
static void DericheFilter (Array< DataT, Dim > const &data, Array< DataT, Dim > &filtered, blitz::TinyVector< double, Dim > const &sigmaUm, BoundaryTreatmentType btType=ValueBT, DataT const &boundaryValue=traits< DataT >::zero, iRoCS::ProgressReporter *pr=NULL)
 Application of the Deriche filter onto the data Array using the standard deviations passed. More...
 

Protected Attributes

BoundaryTreatment< DataT, Dim > * p_bt
 The boundary treatment object to use for out-of-Array access. More...
 

Detailed Description

template<typename DataT, int Dim>
class atb::DericheFilter< DataT, Dim >

The DericheFilter class implements the Deriche filter, which approximates a Gaussian filter using a recursive formulation.

The filter runs in $O(n)$, where $n$ is the number of Array elements compared to $O(n \times m)$ for a full Gaussian convolution, where $m$ is the kernel size. Beware of the fact, that the approximation is not good enough to give rotation invariant filter responses.

Let $\alpha := \frac{5}{2\sqrt{\pi}\sigma}$ and $I$ be a line of an Array to be filtered, then the recursive filter is defined by $\tilde I_i = f_i + g_i$ where

\[ f_i := \frac{\left( 1 - e^{\alpha} \right)^2}{1 + 2\alpha e^{-\alpha} - e^{-2\alpha}} \left( I_i + e^{-\alpha} \left( \alpha - 1 \right) I_{i-1} \right) + 2e^{-\alpha} f_{i-1} - e^{-2\alpha} f_{i-2} \]

and

\[ g_i := \frac{\left( 1 - e^{\alpha} \right)^2}{1 + 2\alpha e^{-\alpha} - e^{-2\alpha}} \left( e^{-\alpha} \left( \alpha + 1 \right) I_{i+1} - e^{-2\alpha} I_{i+2} \right) + 2e^{-\alpha} g_{i+1} - e^{-2\alpha} g_{i+2} \]

Definition at line 74 of file DericheFilter.hh.

Member Typedef Documentation

◆ ResultT

template<typename DataT , int Dim>
typedef DataT atb::DericheFilter< DataT, Dim >::ResultT

Definition at line 79 of file DericheFilter.hh.

Constructor & Destructor Documentation

◆ DericheFilter() [1/4]

template<typename DataT , int Dim>
atb::DericheFilter< DataT, Dim >::DericheFilter ( BoundaryTreatmentType  btType = ValueBT,
DataT const &  boundaryValue = traits< DataT >::zero 
)

Constructor.

Parameters
btTypeDefines the border treatment of this filter. The following border treatments are available: ValueBT, RepeatBT, MirrorBT, CyclicBT, CropBT
boundaryValueThe value to use for out-of-Array positions if the btType is ValueBT

◆ DericheFilter() [2/4]

template<typename DataT , int Dim>
atb::DericheFilter< DataT, Dim >::DericheFilter ( blitz::TinyVector< double, Dim > const &  sigmaUm,
BoundaryTreatmentType  btType = ValueBT,
DataT const &  boundaryValue = traits< DataT >::zero 
)

Constructor.

Parameters
sigmaUmThe standard deviations in micrometers. If you pass values $\leq 0$ the filter will not be applied in the corresponding dimensions.
btTypeDefines the border treatment of this filter. The following border treatments are available: ValueBT, RepeatBT, MirrorBT, CyclicBT, CropBT
boundaryValueThe value to use for out-of-Array positions if the btType is ValueBT

◆ ~DericheFilter()

template<typename DataT , int Dim>
virtual atb::DericheFilter< DataT, Dim >::~DericheFilter ( )
virtual

Destructor.

◆ DericheFilter() [3/4]

template<typename DataT , int Dim>
static void atb::DericheFilter< DataT, Dim >::DericheFilter ( blitz::Array< DataT, Dim > const &  data,
blitz::TinyVector< double, Dim > const &  elementSizeUm,
blitz::Array< DataT, Dim > &  filtered,
blitz::TinyVector< double, Dim > const &  sigmaUm,
BoundaryTreatmentType  btType = ValueBT,
DataT const &  boundaryValue = traits< DataT >::zero,
iRoCS::ProgressReporter pr = NULL 
)
static

Application of the Deriche filter onto the data Array using the standard deviations passed.

Parameters
dataThe data Array to convolve
elementSizeUmThe voxel extents in micrometers
filteredThe convolution result
sigmaUmThe standard deviations per dimension in micrometers
btTypeThe boundary treatment to apply
boundaryValueWhen using ValueBT this value is used for outside data access

◆ DericheFilter() [4/4]

template<typename DataT , int Dim>
static void atb::DericheFilter< DataT, Dim >::DericheFilter ( Array< DataT, Dim > const &  data,
Array< DataT, Dim > &  filtered,
blitz::TinyVector< double, Dim > const &  sigmaUm,
BoundaryTreatmentType  btType = ValueBT,
DataT const &  boundaryValue = traits< DataT >::zero,
iRoCS::ProgressReporter pr = NULL 
)
static

Application of the Deriche filter onto the data Array using the standard deviations passed.

Parameters
dataThe data Array to convolve
filteredThe convolution result
sigmaUmThe standard deviations per dimension in micrometers
btTypeThe boundary treatment to apply
boundaryValueWhen using ValueBT this value is used for outside data access

Member Function Documentation

◆ sigmaUmInDim()

template<typename DataT , int Dim>
double atb::DericheFilter< DataT, Dim >::sigmaUmInDim ( int  dim) const

Get the standard deviation of the Deriche filter along the given dimension.

Parameters
dimThe dimension to get the filter standard deviation for
Returns
The standard deviation of the filter in micrometers

◆ setSigmaUmInDim()

template<typename DataT , int Dim>
void atb::DericheFilter< DataT, Dim >::setSigmaUmInDim ( int  dim,
double  sigmaUm 
)

Set the standard deviation of the Deriche filter along the given dimension.

Parameters
dimThe dimension to set the filter standard deviation for
sigmaUmThe new standard deviation along dimension dim. If you pass a value $\leq 0$ the filter will not be applied in that dimension.

◆ sigmaUm()

template<typename DataT , int Dim>
blitz::TinyVector<double,Dim> const& atb::DericheFilter< DataT, Dim >::sigmaUm ( ) const

Get the standard deviations of the Deriche filter.

Returns
The standard deviations of the filter in micrometers

◆ setSigmaUm()

template<typename DataT , int Dim>
void atb::DericheFilter< DataT, Dim >::setSigmaUm ( blitz::TinyVector< double, Dim > const &  sigmaUm)

Set the standard deviations of the Deriche filter.

Parameters
sigmaUmThe new standard deviations in micrometers. If you pass values $\leq 0$ the filter will not be applied in the corresponding dimensions.

◆ applyAlongDim() [1/2]

template<typename DataT , int Dim>
void atb::DericheFilter< DataT, Dim >::applyAlongDim ( blitz::Array< DataT, Dim > const &  data,
blitz::TinyVector< double, Dim > const &  elementSizeUm,
blitz::Array< DataT, Dim > &  filtered,
int  dim,
iRoCS::ProgressReporter pr = NULL 
) const
virtual

Application of the Deriche filter onto the data Array along the specified dimension.

Parameters
dataThe data Array to convolve
elementSizeUmThe voxel extents in micrometers
filteredThe filter result
dimThe dimension along which to apply the filter

Implements atb::SeparableFilter< DataT, Dim, DataT >.

◆ apply() [1/2]

template<typename DataT , int Dim>
void atb::DericheFilter< DataT, Dim >::apply ( blitz::Array< DataT, Dim > const &  data,
blitz::TinyVector< double, Dim > const &  elementSizeUm,
blitz::Array< DataT, Dim > &  filtered,
iRoCS::ProgressReporter pr = NULL 
) const
virtual

Application of the Deriche filter onto the data Array using the standard deviations passed to the filter object.

Parameters
dataThe data Array to convolve
elementSizeUmThe voxel extents in micrometers
filteredThe convolution result

Implements atb::Filter< DataT, Dim, DataT >.

◆ applyAlongDim() [2/2]

virtual void atb::SeparableFilter< DataT, Dim, DataT >::applyAlongDim ( Array< DataT, Dim > const &  data,
Array< DataT , Dim > &  result,
int  dim,
iRoCS::ProgressReporter pr = NULL 
) const
virtualinherited

Apply the filter along the specified dimension.

Parameters
dataThe data Array to filter
resultThe filter result
dimThe dimension along which to apply the filter
Exceptions
RuntimeErrorIf an error occurs during the filter operation an exception of this kind is thrown

◆ boundaryTreatment()

BoundaryTreatment<DataT,Dim> const& atb::Filter< DataT, Dim, DataT >::boundaryTreatment ( ) const
inherited

Get a read-only reference to the boundary treatment object associated with this filter.

Returns
A reference to the associated BoundaryTreatment object

◆ setBoundaryTreatment() [1/2]

void atb::Filter< DataT, Dim, DataT >::setBoundaryTreatment ( BoundaryTreatmentType  bt,
DataT const &  boundaryValue = traits<DataT>::zero 
)
inherited

Change the boundary treatment type to the type specified.

Parameters
btThe boundary treatment this filter uses
boundaryValueIf bt is ValueBT, this value will be used for out-of-Array access

◆ setBoundaryTreatment() [2/2]

void atb::Filter< DataT, Dim, DataT >::setBoundaryTreatment ( BoundaryTreatment< DataT, Dim > const &  bt)
inherited

Change the boundary treatment type to the type specified.

Parameters
btThe boundary treatment this filter uses

◆ apply() [2/2]

virtual void atb::Filter< DataT, Dim, DataT >::apply ( Array< DataT, Dim > const &  data,
Array< DataT , Dim > &  result,
iRoCS::ProgressReporter pr = NULL 
) const
virtualinherited

Apply the filter to the given Array.

Parameters
dataThe Array to apply the filter to
resultThe filtering result
prIf given progress will be reported to this ProgressReporter
Exceptions
RuntimeErrorIf an error occurs during the filter operation an exception of this kind is thrown

Field Documentation

◆ p_bt

BoundaryTreatment<DataT,Dim>* atb::Filter< DataT, Dim, DataT >::p_bt
protectedinherited

The boundary treatment object to use for out-of-Array access.

This is set during Filter object creation and can be changed by calling the setBoundaryTreatment() method. It gets destroyed, when the filter is deleted. If you delete the BoundaryTreatment object in a subclass, you must set this pointer to the NULL pointer.

Definition at line 159 of file Filter.hh.


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