#include <itkWindowedSincInterpolateImageFunction.h>
Use the windowed sinc function to interpolate.
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.
\[ 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), \]
\[ K(t) = w(t) \textrm{sinc}(t) = w(t) \frac{\sin(\pi t)}{\pi t} \]
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.
There are a few improvements that an enthusiastic 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 \( 2 m d \) operations (where d is the dimensionality of the image). The second can be done better. Presently, each pixel \( I(i,j,k) \) is multiplied by the weights \( K(x-i), K(y-j), K(z-k) \) and added to the running total. This results in \( d (2m)^d \) multiplication operations. However, by keeping intermediate sums, it would be possible to do the operation in \( O ( (2m)^d ) \) 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.
Definition at line 260 of file itkWindowedSincInterpolateImageFunction.h.
Public Member Functions | |
virtual::itk::LightObject::Pointer | CreateAnother () const |
OutputType | EvaluateAtContinuousIndex (const ContinuousIndexType &index) const override |
const char * | GetNameOfClass () const override |
SizeType | GetRadius () const override |
void | SetInputImage (const ImageType *image) override |
![]() | |
OutputType | EvaluateAtContinuousIndex (const ContinuousIndexType &index) const override=0 |
OutputType | EvaluateAtIndex (const IndexType &index) const override |
OutputType | Evaluate (const PointType &point) const override |
![]() | |
void | ConvertContinuousIndexToNearestIndex (const ContinuousIndexType &cindex, IndexType &index) const |
void | ConvertPointToContinuousIndex (const PointType &point, ContinuousIndexType &cindex) const |
virtual const ContinuousIndexType & | GetEndContinuousIndex () const |
virtual const IndexType & | GetEndIndex () const |
const InputImageType * | GetInputImage () const |
virtual const ContinuousIndexType & | GetStartContinuousIndex () const |
virtual const IndexType & | GetStartIndex () const |
virtual bool | IsInsideBuffer (const IndexType &index) const |
virtual bool | IsInsideBuffer (const ContinuousIndexType &index) const |
virtual bool | IsInsideBuffer (const PointType &point) const |
void | ConvertPointToNearestIndex (const PointType &point, IndexType &index) const |
![]() | |
virtual OutputType | Evaluate (const InputType &input) const=0 |
![]() | |
unsigned long | AddObserver (const EventObject &event, Command *cmd) const |
unsigned long | AddObserver (const EventObject &event, std::function< void(const EventObject &)> function) const |
virtual void | DebugOff () const |
virtual void | DebugOn () const |
Command * | GetCommand (unsigned long tag) |
bool | GetDebug () const |
MetaDataDictionary & | GetMetaDataDictionary () |
const MetaDataDictionary & | GetMetaDataDictionary () const |
virtual ModifiedTimeType | GetMTime () const |
virtual const TimeStamp & | GetTimeStamp () const |
bool | HasObserver (const EventObject &event) const |
void | InvokeEvent (const EventObject &) |
void | InvokeEvent (const EventObject &) const |
virtual void | Modified () const |
void | Register () const override |
void | RemoveAllObservers () |
void | RemoveObserver (unsigned long tag) const |
void | SetDebug (bool debugFlag) const |
void | SetReferenceCount (int) override |
void | UnRegister () const noexcept override |
void | SetMetaDataDictionary (const MetaDataDictionary &rhs) |
void | SetMetaDataDictionary (MetaDataDictionary &&rrhs) |
virtual void | SetObjectName (std::string _arg) |
virtual const std::string & | GetObjectName () const |
![]() | |
Pointer | Clone () const |
virtual void | Delete () |
virtual int | GetReferenceCount () const |
void | Print (std::ostream &os, Indent indent=0) const |
Static Public Member Functions | |
static Pointer | New () |
![]() | |
static bool | GetGlobalWarningDisplay () |
static void | GlobalWarningDisplayOff () |
static void | GlobalWarningDisplayOn () |
static Pointer | New () |
static void | SetGlobalWarningDisplay (bool val) |
![]() | |
static void | BreakOnError () |
static Pointer | New () |
Static Public Attributes | |
static constexpr unsigned int | ImageDimension = Superclass::ImageDimension |
![]() | |
static constexpr unsigned int | ImageDimension |
![]() | |
static constexpr unsigned int | ImageDimension |
Protected Member Functions | |
void | PrintSelf (std::ostream &os, Indent indent) const override |
WindowedSincInterpolateImageFunction ()=default | |
~WindowedSincInterpolateImageFunction () override=default | |
![]() | |
InterpolateImageFunction ()=default | |
~InterpolateImageFunction () override=default | |
![]() | |
ImageFunction () | |
~ImageFunction () override=default | |
![]() | |
FunctionBase ()=default | |
~FunctionBase () override=default | |
![]() | |
Object () | |
bool | PrintObservers (std::ostream &os, Indent indent) const |
virtual void | SetTimeStamp (const TimeStamp &timeStamp) |
~Object () override | |
![]() | |
virtual LightObject::Pointer | InternalClone () const |
LightObject () | |
virtual void | PrintHeader (std::ostream &os, Indent indent) const |
virtual void | PrintTrailer (std::ostream &os, Indent indent) const |
virtual | ~LightObject () |
Private Types | |
using | IteratorType = ConstNeighborhoodIterator<ImageType, TBoundaryCondition> |
Static Private Member Functions | |
static double | Sinc (const double x) |
Private Attributes | |
unsigned int | m_OffsetTable [m_OffsetTableSize] {} |
unsigned int | m_WeightOffsetTable [m_OffsetTableSize][ImageDimension] {} |
TWindowFunction | m_WindowFunction {} |
Static Private Attributes | |
static constexpr unsigned int | m_OffsetTableSize = Math::UnsignedPower(m_WindowSize, ImageDimension) |
static constexpr unsigned int | m_WindowSize { 2 * VRadius } |
Additional Inherited Members | |
![]() | |
ContinuousIndexType | m_EndContinuousIndex |
IndexType | m_EndIndex |
InputImageConstPointer | m_Image |
ContinuousIndexType | m_StartContinuousIndex |
IndexType | m_StartIndex |
![]() | |
std::atomic< int > | m_ReferenceCount {} |
using itk::WindowedSincInterpolateImageFunction< TInputImage, VRadius, TWindowFunction, TBoundaryCondition, TCoordinate >::ConstPointer = SmartPointer<const Self> |
Definition at line 272 of file itkWindowedSincInterpolateImageFunction.h.
ContinuousIndex Type.
using itk::WindowedSincInterpolateImageFunction< TInputImage, VRadius, TWindowFunction, TBoundaryCondition, TCoordinate >::ImageType = TInputImage |
Image type definition
Definition at line 300 of file itkWindowedSincInterpolateImageFunction.h.
Index Type.
InputImageType type alias support
|
private |
Definition at line 332 of file itkWindowedSincInterpolateImageFunction.h.
OutputType type alias support
using itk::WindowedSincInterpolateImageFunction< TInputImage, VRadius, TWindowFunction, TBoundaryCondition, TCoordinate >::Pointer = SmartPointer<Self> |
Definition at line 271 of file itkWindowedSincInterpolateImageFunction.h.
using itk::InterpolateImageFunction< TInputImage, TCoordinate >::RealType |
RealType type alias support
Definition at line 85 of file itkInterpolateImageFunction.h.
using itk::WindowedSincInterpolateImageFunction< TInputImage, VRadius, TWindowFunction, TBoundaryCondition, TCoordinate >::Self = WindowedSincInterpolateImageFunction |
Standard class type aliases.
Definition at line 268 of file itkWindowedSincInterpolateImageFunction.h.
using itk::InterpolateImageFunction< TInputImage, TCoordinate >::SizeType |
Size type alias support
Definition at line 79 of file itkInterpolateImageFunction.h.
using itk::WindowedSincInterpolateImageFunction< TInputImage, VRadius, TWindowFunction, TBoundaryCondition, TCoordinate >::Superclass = InterpolateImageFunction<TInputImage, TCoordinate> |
Definition at line 269 of file itkWindowedSincInterpolateImageFunction.h.
|
protecteddefault |
Referenced by GetNameOfClass().
|
overrideprotecteddefault |
|
virtual |
Create an object from an instance, potentially deferring to a factory. This method allows you to create an instance of an object that is exactly the same type as the referring object. This is useful in cases where an object has been cast back to a base class.
Reimplemented from itk::Object.
|
override |
Evaluate the function at a ContinuousIndex position
Returns the interpolated image intensity at a specified point position. Bounds checking is based on the type of the TBoundaryCondition specified.
|
overridevirtual |
Reimplemented from itk::InterpolateImageFunction< TInputImage, double >.
References WindowedSincInterpolateImageFunction().
|
inlineoverridevirtual |
Get the radius required for interpolation.
This defines the number of surrounding pixels required to interpolate at a given point.
Implements itk::InterpolateImageFunction< TInputImage, double >.
Definition at line 318 of file itkWindowedSincInterpolateImageFunction.h.
|
static |
Method for creation through the object factory.
|
overrideprotectedvirtual |
Methods invoked by Print() to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.
Reimplemented from itk::InterpolateImageFunction< TInputImage, double >.
|
overridevirtual |
Set the input image.
Reimplemented from itk::ImageFunction< TInputImage, NumericTraits< TInputImage::PixelType >::RealType, double >.
|
inlinestaticprivate |
The sinc function
Definition at line 352 of file itkWindowedSincInterpolateImageFunction.h.
References itk::Math::pi.
|
staticconstexpr |
Dimension underlying input image.
Definition at line 290 of file itkWindowedSincInterpolateImageFunction.h.
|
private |
The offset array, used to keep a list of relevant offsets in the neighborhoodIterator
Definition at line 345 of file itkWindowedSincInterpolateImageFunction.h.
|
staticconstexprprivate |
Size of the offset table
Definition at line 341 of file itkWindowedSincInterpolateImageFunction.h.
|
private |
Index into the weights array for each offset
Definition at line 348 of file itkWindowedSincInterpolateImageFunction.h.
|
private |
The function object, used to compute window
Definition at line 338 of file itkWindowedSincInterpolateImageFunction.h.
|
staticconstexprprivate |
Definition at line 335 of file itkWindowedSincInterpolateImageFunction.h.