iRoCS Toolbox  1.1.0
AnisotropicDiffusionFilter.hh
Go to the documentation of this file.
1 /**************************************************************************
2  *
3  * Copyright (C) 2015 Thorsten Falk
4  *
5  * Image Analysis Lab, University of Freiburg, Germany
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  *
21  **************************************************************************/
22 
23 /*======================================================================*/
28 /*======================================================================*/
29 
30 #ifndef ATBANISOTROPICDIFFUSIONFILTER_HH
31 #define ATBANISOTROPICDIFFUSIONFILTER_HH
32 
33 #ifdef HAVE_CONFIG_H
34 #include <config.hh>
35 #endif
36 
37 #include "GaussianFilter.hh"
39 #include "ATBLinAlg.hh"
40 
41 namespace atb
42 {
43 
44 /*======================================================================*/
51 /*======================================================================*/
52  template<typename DataT, int Dim>
53  class AnisotropicDiffusionFilter : public Filter<DataT,Dim,DataT>
54  {
55 
56  public:
57 
58  typedef DataT ResultT;
59 
60 /*======================================================================*/
68 /*======================================================================*/
71  DataT const &boundaryValue = traits<DataT>::zero);
72 
73 /*======================================================================*/
92 /*======================================================================*/
94  double kappa, double sigmaUm = -1.0,
95  double tau = 0.0625, double zAnisotropyCorrection = 0.0,
96  int nIterations = 20, int hessianUpdateStepWidth = 4,
98  DataT const &boundaryValue = traits<DataT>::zero);
99 
100 /*======================================================================*/
104 /*======================================================================*/
105  virtual ~AnisotropicDiffusionFilter();
106 
107 /*======================================================================*/
113 /*======================================================================*/
114  double kappa() const;
115 
116 /*======================================================================*/
122 /*======================================================================*/
123  void setKappa(double kappa);
124 
125 /*======================================================================*/
132 /*======================================================================*/
133  double sigmaUm() const;
134 
135 /*======================================================================*/
142 /*======================================================================*/
143  void setSigmaUm(double sigmaUm);
144 
145 /*======================================================================*/
151 /*======================================================================*/
152  double tau() const;
153 
154 /*======================================================================*/
160 /*======================================================================*/
161  void setTau(double tau);
162 
163 /*======================================================================*/
169 /*======================================================================*/
170  double zAnisotropyCorrection() const;
171 
172 /*======================================================================*/
178 /*======================================================================*/
180 
181 /*======================================================================*/
187 /*======================================================================*/
188  int nIterations() const;
189 
190 /*======================================================================*/
196 /*======================================================================*/
197  void setNIterations(int nIterations);
198 
199 /*======================================================================*/
205 /*======================================================================*/
206  int hessianUpdateStepWidth() const;
207 
208 /*======================================================================*/
215 /*======================================================================*/
217 
218 /*======================================================================*/
231 /*======================================================================*/
232  virtual void apply(
233  blitz::Array<DataT,Dim> const &data,
234  blitz::TinyVector<double,Dim> const &elementSizeUm,
235  blitz::Array<ResultT,Dim> &filtered,
236  iRoCS::ProgressReporter *pr = NULL) const;
237 
238  // Explicitly force the name mangler to also consider the base class
239  // implementation
241 
242 /*======================================================================*/
268 /*======================================================================*/
269  static void apply(
270  blitz::Array<DataT,Dim> const &data,
271  blitz::TinyVector<double,Dim> const &elementSizeUm,
272  blitz::Array<ResultT,Dim> &filtered, double kappa,
273  double sigmaUm = -1.0, double tau = 0.0625,
274  double zAnisotropyCorrection = 0.0, int nIterations = 20,
276  DataT const &boundaryValue = traits<DataT>::zero,
277  iRoCS::ProgressReporter *pr = NULL);
278 
279 /*======================================================================*/
304 /*======================================================================*/
305  static void apply(
306  Array<DataT,Dim> const &data, Array<ResultT,Dim> &filtered,
307  double kappa, double sigmaUm = -1.0, double tau = 0.0625,
308  double zAnisotropyCorrection = 0.0, int nIterations = 20,
310  DataT const &boundaryValue = traits<DataT>::zero,
311  iRoCS::ProgressReporter *pr = NULL);
312 
313  private:
314 
315  double _kappa, _sigmaUm, _tau, _zAnisotropyCorrection;
316  int _nIterations, _hessianUpdateStepWidth;
317 
318  };
319 
320 }
321 
322 #include "AnisotropicDiffusionFilter.icc"
323 
324 #endif
int nIterations() const
Get the number of filtering iterations.
void setHessianUpdateStepWidth(int hessianUpdateStepWidth)
Set the iteration stride for hessian recomputation.
double tau() const
Get the solver time step.
virtual void apply(blitz::Array< DataT, Dim > const &data, blitz::TinyVector< double, Dim > const &elementSizeUm, blitz::Array< ResultT, Dim > &filtered, iRoCS::ProgressReporter *pr=NULL) const
Apply the filter to the given Array.
The Filter class is the base class for all filter implementations.
Definition: Filter.hh:55
The Implementation of the convolution of the input data with a Gaussian.
The Array class is an extension to the blitz++ Array class providing additional parameters element si...
Definition: Array.hh:85
AnisotropicDiffusionFilter(BoundaryTreatmentType bt=ValueBT, DataT const &boundaryValue=traits< DataT >::zero)
Default Constructor.
void setTau(double tau)
Set the solver time step (In case of convergence problems reduce it)
BoundaryTreatmentType
BoundaryTreatment.hh "libArrayToolbox/BoundaryTreatment.hh".
The traits class provides means to query specific information about different data types...
Definition: TypeTraits.hh:73
The Implementation of the filter computing the hessian of the input data using central differences...
void setKappa(double kappa)
Set the edge weight kappa.
double sigmaUm() const
Get the standard deviations of the Gaussian pre-smoothing filter in micrometers for all dimensions...
void setSigmaUm(double sigmaUm)
Set the standard deviation of the Gaussian pre-smoothing filter in micrometers for all dimensions...
int hessianUpdateStepWidth() const
Get the iteration stride for hessian recomputation.
virtual ~AnisotropicDiffusionFilter()
Destructor.
void setZAnisotropyCorrection(double zAnisotropyCorrection)
Set the anisotropy correction constant applied in z direction.
void setNIterations(int nIterations)
Set the number of filtering iterations.
Treat positions beyond the Array domain as having a constant value.
double zAnisotropyCorrection() const
Get the anisotropy correction constant applied in z direction.
double kappa() const
Get the edge weight kappa.
The AnisotropicDiffusionFilter class implements the Filter interface and provides an anisotropic diff...