/usr/include/ITK-4.9/itkAnisotropicDiffusionFunction.h is in libinsighttoolkit4-dev 4.9.0-4ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | /*=========================================================================
*
* Copyright Insight Software Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef itkAnisotropicDiffusionFunction_h
#define itkAnisotropicDiffusionFunction_h
#include "itkFiniteDifferenceFunction.h"
namespace itk
{
/**
* \class AnisotropicDiffusionFunction
* This class is a virtual base for anisotropic diffusion function objects. It
* is a component object in the finite difference solver hierarchy (see
* itkFiniteDifferenceImageFilter for an overview).
* AnisotropicDiffusionFunction objects are used by
* AnisotropicDiffusionImageFilter objects to perform non-linear diffusion on
* itk::Images.
*
* \par Overview of anisotropic diffusion
*
* Anisotropic diffusion methods are formulated to reduce noise (or unwanted
* detail) in images while preserving specific image features. For many
* applications, there is an assumption that light-dark transitions
* (edges) are interesting. Standard isotropic diffusion methods move and blur
* light-dark boundaries. Anisotropic diffusion methods are formulated to
* specifically preserve edges.
*
* Anisotropic diffusion methods can be thought of as tools for calculating
* multi-scale descriptions of images. Embed an image \f$U(\mathbf{x})\f$ in a
* higher dimensional function of derived images, \f$U(\mathbf{x}, t)\f$. This
* higher dimensional function represents the solution of the heat diffusion
* equation,
*
* \par
* \f[\frac{d U(\mathbf{x})}{d t} = \nabla \cdot c \nabla U(\mathbf{x})\f]
*
* \par
* with constant \f$c\f$ and initial condition
* \f$U(\mathbf{x}, 0) = U_0(\mathbf{x})\f$, the original image.
*
* \par
* Extending to the case where \f$c\f$ is not a constant, but a function of
* \f$\mathbf{x}\f$, gives
*
* \par
* \f[\frac{d U(\mathbf{x})}{d t} = C(\mathbf{x})\Delta U(\mathbf{x})
* + \nabla C(\mathbf{x}) \nabla U(\mathbf{x})\f]
*
* \par
* Our choice of \f$C\f$ now varies the strength of diffusion anisotropically.
* Typically, \f$C\f$ is chosen as some function of image features to
* selectively preserve or remove those features. For example, edges tend to
* be preserved over smoother regions where \f$C\f$ is inversely scaled
* according to gradient magnitude as in
*
* \par
* \f[C(\mathbf{x}) = e^{-(\frac{\parallel \nabla U(\mathbf{x}) \parallel}{K})^2}\f].
*
* \par
* Several variations on the scheme presented above are implemented in Itk as
* subclasses of this equation. The equations are solved using an iterative,
* finite forward difference technique (see the FiniteDifferenceImageFilter
* class).
*
* \par How to use this class
* This class must be subclassed to provide the CalculateUpdate() methods of
* FiniteDifferenceFunction and the function
* CalculateAverageGradientMagnitudeSquared(), which is called before each
* iteration to recalibrate the conductance term.
*
* \par Parameters
* The parameters defined in this class apply to the basic anisotropic
* diffusion equation described in AnisotropicDiffusionFunction. Variations
* on the basic equation will be more or less sensitive to these parameters.
* For example, functions that perform higher-order derivative calculations
* may require smaller time-steps than those that only do first-derivative
* calculations. Wherever possibe, reasonable parameters settings are
* suggested in the documentation of a specific equation implementation.
*
* \par TimeStep
* In the anisotropic diffusion filter hierarchy, the time step is set
* explicitly by the user. The time step referred to here corresponds exactly
* to \f$ \Delta t \f$ in the finite difference update equation described in
* FiniteDifferenceImageFilter (see itkFiniteDifferenceImageFilter for more
* information). Appropriate time steps for solving this type of p.d.e. depend
* on the dimensionality of the image and the order of the equation.
* Stable values for most 2D and 3D functions are
* 0.125 and 0.0625, respectively, when the pixel spacing is unity or is turned off.
* In general, you should keep the time step below
* \f$(PixelSpacing)/2^{N+1}\f$, where \f$N\f$ is the number of image
* dimensions. A filter will automatically attempt to constrain its time step
* to a stable value and generate a run-time warning if the time step is set
* too high.
*
* \par Conductance Parameter
* The conductance parameter controls the sensitivity of the conductance term
* in the basic anisotropic diffusion equation. It affects the conductance term
* in different ways depending on the particular variation on the basic
* equation. As a general rule, the lower the value, the more strongly the
* diffusion equation preserves image features (such as high gradients or
* curvature). A high value for conductance will cause the filter to diffuse
* image features more readily. Typical values range from 0.5 to 2.0 for data
* like the Visible Human color data, but the correct value for your
* application is wholly dependent on the results you want from a specific data
* set and the number or iterations you perform.
*
* \par References
* Pietro Perona and Jitendra Malik, ``Scale-space and edge detection using
* anisotropic diffusion,'' IEEE Transactions on Pattern Analysis Machine
* Intelligence, vol. 12, pp. 629-639, 1990.
*
* \sa VectorAnisotropicDiffusionFunction
* \sa ScalarAnisotropicDiffusionFunction
* \sa GradientAnisotropicDiffusionFunction
* \sa CurvatureAnisotropicDiffusionFunction
* \sa VectorGradientAnisotropicDiffusionFunction
* \ingroup FiniteDifferenceFunctions
* \ingroup ImageEnhancement
* \todo Automatically generate the time step value from image dimensionality
* and order of the equations
* \ingroup ITKAnisotropicSmoothing
*/
template< typename TImage >
class AnisotropicDiffusionFunction:
public FiniteDifferenceFunction< TImage >
{
public:
/** Standard class typedefs. */
typedef AnisotropicDiffusionFunction Self;
typedef FiniteDifferenceFunction< TImage > Superclass;
typedef SmartPointer< Self > Pointer;
typedef SmartPointer< const Self > ConstPointer;
/** Run-time type information (and related methods) */
itkTypeMacro(AnisotropicDiffusionFunction, FiniteDifferenceFunction);
/** Inherit some parameters from the superclass type */
typedef typename Superclass::ImageType ImageType;
typedef typename Superclass::PixelType PixelType;
typedef typename Superclass::PixelRealType PixelrealType;
typedef typename Superclass::RadiusType RadiusType;
typedef typename Superclass::NeighborhoodType NeighborhoodType;
typedef typename Superclass::TimeStepType TimeStepType;
typedef typename Superclass::FloatOffsetType FloatOffsetType;
/** Inherit some parameters from the superclass type */
itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
/** This method is called before each iteration. It calculates a scalar
value that is the average of the gradient magnitude squared at each pixel
in the output image (intermediate solution). The average gradient magnitude
value is typically used in the anisotropic diffusion equations to
calibrate the conductance term. */
virtual void CalculateAverageGradientMagnitudeSquared(ImageType *) = 0;
/** Set/Get the time step. For this class of anisotropic diffusion filters,
the time-step is supplied by the user and remains fixed for all
updates. */
void SetTimeStep(const TimeStepType & t)
{
m_TimeStep = t;
}
const TimeStepType & GetTimeStep() const
{
return m_TimeStep;
}
/** Set/Get the conductance parameter. The conductance parameter. */
void SetConductanceParameter(const double & c)
{
m_ConductanceParameter = c;
}
const double & GetConductanceParameter() const
{
return m_ConductanceParameter;
}
/** Set/Get the average gradient magnitude squared. */
const double & GetAverageGradientMagnitudeSquared() const
{
return m_AverageGradientMagnitudeSquared;
}
void SetAverageGradientMagnitudeSquared(const double & c)
{
m_AverageGradientMagnitudeSquared = c;
}
/** Returns the time step supplied by the user. We don't need to use the
* global data supplied since we are returning a fixed value. */
virtual TimeStepType ComputeGlobalTimeStep( void *itkNotUsed(GlobalData) ) const ITK_OVERRIDE
{
return this->GetTimeStep();
}
/** The anisotropic diffusion classes don't use this particular parameter
* so it's safe to return a null value. */
virtual void * GetGlobalDataPointer() const ITK_OVERRIDE
{
return ITK_NULLPTR;
}
/** Does nothing. No global data is used in this class of equations. */
virtual void ReleaseGlobalDataPointer( void *itkNotUsed(GlobalData) ) const ITK_OVERRIDE
{
/* do nothing */
}
protected:
AnisotropicDiffusionFunction()
{
m_AverageGradientMagnitudeSquared = 0.0;
m_ConductanceParameter = 1.0; // default value
m_TimeStep = 0.125f; // default value
}
~AnisotropicDiffusionFunction() {}
void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE
{
Superclass::PrintSelf(os, indent);
os << indent << "TimeStep: " << m_TimeStep << std::endl;
os << indent << "ConductanceParameter: " << m_ConductanceParameter
<< std::endl;
}
private:
AnisotropicDiffusionFunction(const Self &) ITK_DELETE_FUNCTION;
void operator=(const Self &) ITK_DELETE_FUNCTION;
double m_AverageGradientMagnitudeSquared;
double m_ConductanceParameter;
TimeStepType m_TimeStep;
};
} // end namespace itk
#endif
|