/usr/include/OTB-5.8/otbWindowedSincInterpolateImageFunctionBase.h is in libotb-dev 5.8.0+dfsg-3.
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 | /*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef otbWindowedSincInterpolateImageFunctionBase_h
#define otbWindowedSincInterpolateImageFunctionBase_h
#include "otbGenericInterpolateImageFunction.h"
#include "itkSize.h"
#include "otbMath.h"
#include "vnl/vnl_math.h"
namespace otb
{
/**
* \class WindowedSincInterpolateImageFunctionBase
* \brief Use the windowed sinc function to interpolate
*
* \par THEORY
*
* This function is intended to provide an interpolation function that
* has minimum aliasing artifacts, in contrast to linear interpolation.
* According to sampling theory, the infinite-support sinc filter,
* whose Fourier transform is the box filter, is optimal for resampling
* a function. In practice, the infinite support sinc filter is
* approximated using a limited support 'windowed' sinc filter.
* Most of those functions are inspired of the itk::WindowedSincInterpolateImageFunction source code.
*
* \par
* This function is based on the following publication:
*
* \par
* Erik H. W. Meijering, Wiro J. Niessen, Josien P. W. Pluim,
* Max A. Viergever: Quantitative Comparison of Sinc-Approximating
* Kernels for Medical Image Interpolation. MICCAI 1999, pp. 210-217
*
* \par
* In this work, several 'windows' are estimated. In two dimensions, the
* interpolation at a position (x, y) is given by the following
* expression:
*
* \par
* \f[
* I(x, y) =
* \sum_{i = \lfloor x \rfloor + 1 - m}^{\lfloor x \rfloor + m}
* \sum_{j = \lfloor y \rfloor + 1 - m}^{\lfloor y \rfloor + m}
* I_{i, j} K(x-i) K(y-j),
* \f]
*
* \par
* where m is the 'radius' of the window, (3, 4 are reasonable numbers),
* and K(t) is the kernel function, composed of the sinc function and
* one of several possible window functions:
*
* \par
* \f[
* K(t) = w(t) \textrm{sinc}(t) = w(t) \frac{\sin(\pi t)}{\pi t}
* \f]
*
* \par
* Several window functions are provided here in the itk::Function
* namespace. The conclusions of the referenced paper suggest to use the
* Welch, Cosine, Kaiser, and Lanczos windows for m = 4, 5. These are based
* on error in rotating medical images w.r.t. the linear interpolation
* method. In some cases the results achieve a 20-fold improvement in
* accuracy.
*
* \par USING THIS FILTER
*
* Use this filter the way you would use any ImageInterpolationFunction,
* so for instance, you can plug it into the ResampleImageFilter class.
* In order to initialize the filter you must choose several template
* parameters.
*
* \par
* The first (TInputImage) is the image type, that's standard.
*
* \par
* The second (TWindowFunction) is the window function object, which you
* can choose from about five different functions defined in this
* header. The default is the Hamming window, which is commonly used
* but not optimal according to the cited paper.
*
* \par
* The third (TBoundaryCondition) is the boundary condition class used
* to determine the values of pixels that fall off the image boundary.
* This class has the same meaning here as in the NeighborhoodItetator
* classes.
*
* \par
* The fourth (TCoordRep) is again standard for interpolating functions,
* and should be float or double.
*
* \par CAVEATS
*
* There are a few improvements that an enthusiasting ITK developer
* could make to this filter. One issue is with the way that the kernel
* is applied. The computational expense comes from two sources:
* computing the kernel weights K(t) and multiplying the pixels in the
* window by the kernel weights. The first is done more or less
* efficiently in \f$ 2 m d \f$ operations (where d is the
* dimensionality of the image). The second can be done
* better. Presently, each pixel \f$ I(i, j, k) \f$ is multiplied by the
* weights \f$ K(x-i), K(y-j), K(z-k) \f$ and added to the running
* total. This results in \f$ d (2m)^d \f$ multiplication
* operations. However, by keeping intermediate sums, it would be
* possible to do the operation in \f$ O ( (2m)^d ) \f$
* operations. This would require some creative coding. In addition, in
* the case when one of the coordinates is integer, the computation
* could be reduced by an order of magnitude.
*
* \sa GenericInterpolatorImageFunctionBase
* \sa LinearInterpolateImageFunctionBase ResampleImageFilter
* \sa Function::HammingWindowFunction
* \sa Function::CosineWindowFunction
* \sa Function::WelchWindowFunction
* \sa Function::LanczosWindowFunction
* \sa Function::BlackmanWindowFunction
* \ingroup ImageFunctionBases ImageInterpolators
*
* \ingroup OTBInterpolation
*/
template<class TInputImage, class TWindowFunction, class TBoundaryCondition =
itk::ZeroFluxNeumannBoundaryCondition<TInputImage>, class TCoordRep = double>
class ITK_EXPORT WindowedSincInterpolateImageFunctionBase :
public GenericInterpolateImageFunction<TInputImage,
TWindowFunction,
TBoundaryCondition,
TCoordRep>
{
public:
/** Standard class typedefs. */
typedef WindowedSincInterpolateImageFunctionBase Self;
typedef GenericInterpolateImageFunction<TInputImage, TWindowFunction, TBoundaryCondition, TCoordRep> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Run-time type information (and related methods). */
itkTypeMacro(WindowedSincInterpolateImageFunctionBase, GenericInterpolateImageFunction);
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Input and output images typedef definition. */
typedef typename Superclass::InputImageType InputImageType;
typedef typename Superclass::OutputType OutputType;
/** Dimension underlying input image. */
itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
/** Superclass typedef inheritance. */
typedef typename Superclass::IndexType IndexType;
typedef typename Superclass::SizeType SizeType;
typedef typename Superclass::RealType RealType;
typedef typename Superclass::IteratorType IteratorType;
typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
//typedef typename TWindowFunction FunctionType;
typedef typename Superclass::FunctionType FunctionType;
typedef typename std::vector<double> VectorType;
/** Compute a resampled profil according to the window size.*/
// virtual void ComputeResampledWindowedSincProfil();
protected:
WindowedSincInterpolateImageFunctionBase();
~WindowedSincInterpolateImageFunctionBase() ITK_OVERRIDE;
void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE;
private:
WindowedSincInterpolateImageFunctionBase(const Self &); //purposely not implemented
void operator =(const Self&); //purposely not implemented
};
} // end namespace itk
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbWindowedSincInterpolateImageFunctionBase.txx"
#endif
#endif
|