SimpleITK  
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
itk::simple::ResampleImageFilter Class Reference

Resample an image via a coordinate transform. More...

#include <sitkResampleImageFilter.h>

+ Inheritance diagram for itk::simple::ResampleImageFilter:
+ Collaboration diagram for itk::simple::ResampleImageFilter:

Detailed Description

Resample an image via a coordinate transform.

ResampleImageFilter resamples an existing image through some coordinate transform, interpolating via some image function. The class is templated over the types of the input and output images.

Note that the choice of interpolator function can be important. This function is set via SetInterpolator() . The default is LinearInterpolateImageFunction <InputImageType, TInterpolatorPrecisionType>, which is reasonable for ordinary medical images. However, some synthetic images have pixels drawn from a finite prescribed set. An example would be a mask indicating the segmentation of a brain into a small number of tissue types. For such an image, one does not want to interpolate between different pixel values, and so NearestNeighborInterpolateImageFunction < InputImageType, TCoordRep > would be a better choice.

If an sample is taken from outside the image domain, the default behavior is to use a default pixel value. If different behavior is desired, an extrapolator function can be set with SetExtrapolator() .

Output information (spacing, size and direction) for the output image should be set. This information has the normal defaults of unit spacing, zero origin and identity direction. Optionally, the output information can be obtained from a reference image. If the reference image is provided and UseReferenceImage is On, then the spacing, origin and direction of the reference image will be used.

Since this filter produces an image which is a different size than its input, it needs to override several of the methods defined in ProcessObject in order to properly manage the pipeline execution model. In particular, this filter overrides ProcessObject::GenerateInputRequestedRegion() and ProcessObject::GenerateOutputInformation() .

This filter is implemented as a multithreaded filter. It provides a DynamicThreadedGenerateData() method for its implementation.

Warning
For multithreading, the TransformPoint method of the user-designated coordinate transform must be threadsafe.
See also
itk::ResampleImageFilter for the Doxygen on the original ITK class.

Definition at line 52 of file sitkResampleImageFilter.h.

Public Types

using PixelIDTypeList = BasicPixelIDTypeList
 
using Self = ResampleImageFilter
 
- Public Types inherited from itk::simple::ImageFilter
using Self = ImageFilter
 
- Public Types inherited from itk::simple::ProcessObject
using Self = ProcessObject
 

Public Member Functions

Image Execute (const Image &image1)
 
double GetDefaultPixelValue () const
 
InterpolatorEnum GetInterpolator () const
 
std::string GetName () const
 
std::vector< double > GetOutputDirection () const
 
std::vector< double > GetOutputOrigin () const
 
PixelIDValueEnum GetOutputPixelType () const
 Get the ouput pixel type. More...
 
std::vector< double > GetOutputSpacing () const
 
std::vector< uint32_t > GetSize () const
 
Transform GetTransform () const
 
bool GetUseNearestNeighborExtrapolator () const
 
 ResampleImageFilter ()
 
SelfSetDefaultPixelValue (double DefaultPixelValue)
 
SelfSetInterpolator (InterpolatorEnum Interpolator)
 
SelfSetOutputDirection (std::vector< double > OutputDirection)
 
SelfSetOutputOrigin (std::vector< double > OutputOrigin)
 
SelfSetOutputPixelType (PixelIDValueEnum OutputPixelType)
 Set the output pixel type, if sitkUnknown then the input type is used. More...
 
SelfSetOutputSpacing (std::vector< double > OutputSpacing)
 
void SetReferenceImage (const Image &refImage)
 
SelfSetSize (std::vector< uint32_t > Size)
 
SelfSetTransform (Transform Transform)
 
SelfSetUseNearestNeighborExtrapolator (bool UseNearestNeighborExtrapolator)
 Enables the nearest neighbor extrapolator as opposed to the constant pixel value. More...
 
std::string ToString () const
 
SelfUseNearestNeighborExtrapolatorOff ()
 
SelfUseNearestNeighborExtrapolatorOn ()
 
virtual ~ResampleImageFilter ()
 
- Public Member Functions inherited from itk::simple::ImageFilter
 ImageFilter ()
 
virtual ~ImageFilter ()=0
 
- Public Member Functions inherited from itk::simple::ProcessObject
virtual void Abort ()
 
virtual int AddCommand (itk::simple::EventEnum event, const std::function< void()> &func)
 Directly add a callback to observe an event. More...
 
virtual int AddCommand (itk::simple::EventEnum event, itk::simple::Command &cmd)
 Add a Command Object to observer the event. More...
 
virtual float GetProgress () const
 An Active Measurement of the progress of execution. More...
 
virtual bool HasCommand (itk::simple::EventEnum event) const
 Query of this object has any registered commands for event. More...
 
 ProcessObject ()
 
virtual void RemoveAllCommands ()
 Remove all registered commands. More...
 
virtual ~ProcessObject ()
 
virtual void DebugOn ()
 
virtual void DebugOff ()
 
virtual bool GetDebug () const
 
virtual void SetDebug (bool debugFlag)
 
virtual void SetNumberOfThreads (unsigned int n)
 
virtual unsigned int GetNumberOfThreads () const
 
virtual void SetNumberOfWorkUnits (unsigned int n)
 
virtual unsigned int GetNumberOfWorkUnits () const
 

Private Types

using MemberFunctionType = Image(Self::*)(const Image &image1)
 

Private Member Functions

template<class TImageType1 , class TImageType2 >
Image DualExecuteInternal (const Image &image1)
 
template<class TImageType1 , class TImageType2 >
Image DualExecuteInternalVector (const Image &image1)
 

Private Attributes

double m_DefaultPixelValue {0.0}
 
std::unique_ptr< detail::DualMemberFunctionFactory< MemberFunctionType > > m_DualMemberFactory
 
InterpolatorEnum m_Interpolator {itk::simple::sitkLinear}
 
std::vector< double > m_OutputDirection {std::vector<double>()}
 
std::vector< double > m_OutputOrigin {std::vector<double>(3, 0.0)}
 
PixelIDValueEnum m_OutputPixelType {itk::simple::sitkUnknown}
 
std::vector< double > m_OutputSpacing {std::vector<double>(3, 1.0)}
 
std::vector< uint32_t > m_Size {std::vector<uint32_t>(3, 0)}
 
Transform m_Transform {itk::simple::Transform()}
 
bool m_UseNearestNeighborExtrapolator {false}
 

Friends

struct detail::DualExecuteInternalAddressor< MemberFunctionType >
 
struct detail::DualExecuteInternalVectorAddressor< MemberFunctionType >
 

Additional Inherited Members

- Static Public Member Functions inherited from itk::simple::ProcessObject
static bool GetGlobalDefaultDebug ()
 
static void GlobalDefaultDebugOff ()
 
static void GlobalDefaultDebugOn ()
 
static void SetGlobalDefaultDebug (bool debugFlag)
 
static void GlobalWarningDisplayOn ()
 
static void GlobalWarningDisplayOff ()
 
static void SetGlobalWarningDisplay (bool flag)
 
static bool GetGlobalWarningDisplay ()
 
static double GetGlobalDefaultCoordinateTolerance ()
 Access the global tolerance to determine congruent spaces. More...
 
static void SetGlobalDefaultCoordinateTolerance (double)
 Access the global tolerance to determine congruent spaces. More...
 
static double GetGlobalDefaultDirectionTolerance ()
 Access the global tolerance to determine congruent spaces. More...
 
static void SetGlobalDefaultDirectionTolerance (double)
 Access the global tolerance to determine congruent spaces. More...
 
static bool SetGlobalDefaultThreader (const std::string &threader)
 Set/Get the default threader used for process objects. More...
 
static std::string GetGlobalDefaultThreader ()
 Set/Get the default threader used for process objects. More...
 
static void SetGlobalDefaultNumberOfThreads (unsigned int n)
 
static unsigned int GetGlobalDefaultNumberOfThreads ()
 Set/Get the default threader used for process objects. More...
 
- Protected Member Functions inherited from itk::simple::ImageFilter
void CheckImageMatchingDimension (const Image &image1, const Image &image2, const std::string &image2Name)
 
void CheckImageMatchingPixelType (const Image &image1, const Image &image2, const std::string &image2Name)
 
void CheckImageMatchingSize (const Image &image1, const Image &image2, const std::string &image2Name)
 
- Protected Member Functions inherited from itk::simple::ProcessObject
virtual unsigned long AddITKObserver (const itk::EventObject &, itk::Command *)
 
virtual itk::ProcessObjectGetActiveProcess ()
 
virtual void OnActiveProcessDelete ()
 
virtual void onCommandDelete (const itk::simple::Command *cmd) noexcept
 
virtual void PreUpdate (itk::ProcessObject *p)
 
virtual void RemoveITKObserver (EventCommand &e)
 
- Protected Member Functions inherited from itk::simple::NonCopyable
 NonCopyable ()=default
 
 NonCopyable (const NonCopyable &)=delete
 
NonCopyableoperator= (const NonCopyable &)=delete
 
- Static Protected Member Functions inherited from itk::simple::ImageFilter
template<class TImageType >
static void FixNonZeroIndex (TImageType *img)
 
- Static Protected Member Functions inherited from itk::simple::ProcessObject
template<class TImageType >
static TImageType::ConstPointer CastImageToITK (const Image &img)
 
template<class TPixelType , unsigned int VImageDimension, unsigned int VLength, template< typename, unsigned int > class TVector>
static Image CastITKToImage (itk::Image< TVector< TPixelType, VLength >, VImageDimension > *img)
 
template<unsigned int VImageDimension, unsigned int VLength, template< unsigned int > class TVector>
static Image CastITKToImage (itk::Image< TVector< VLength >, VImageDimension > *img)
 
template<class TImageType >
static Image CastITKToImage (TImageType *img)
 
static const itk::EventObjectGetITKEventObject (EventEnum e)
 
template<typename T >
static std::ostream & ToStringHelper (std::ostream &os, const T &v)
 
static std::ostream & ToStringHelper (std::ostream &os, const char &v)
 
static std::ostream & ToStringHelper (std::ostream &os, const signed char &v)
 
static std::ostream & ToStringHelper (std::ostream &os, const unsigned char &v)
 

Member Typedef Documentation

◆ MemberFunctionType

using itk::simple::ResampleImageFilter::MemberFunctionType = Image (Self::*)( const Image& image1 )
private

Setup for member function dispatching

Definition at line 177 of file sitkResampleImageFilter.h.

◆ PixelIDTypeList

Define the pixels types supported by this filter

Definition at line 64 of file sitkResampleImageFilter.h.

◆ Self

Definition at line 54 of file sitkResampleImageFilter.h.

Constructor & Destructor Documentation

◆ ~ResampleImageFilter()

virtual itk::simple::ResampleImageFilter::~ResampleImageFilter ( )
virtual

Destructor

◆ ResampleImageFilter()

itk::simple::ResampleImageFilter::ResampleImageFilter ( )

Default Constructor that takes no arguments and initializes default parameters

Member Function Documentation

◆ DualExecuteInternal()

template<class TImageType1 , class TImageType2 >
Image itk::simple::ResampleImageFilter::DualExecuteInternal ( const Image image1)
private

◆ DualExecuteInternalVector()

template<class TImageType1 , class TImageType2 >
Image itk::simple::ResampleImageFilter::DualExecuteInternalVector ( const Image image1)
private

◆ Execute()

Image itk::simple::ResampleImageFilter::Execute ( const Image image1)

Execute the filter on the input image

◆ GetDefaultPixelValue()

double itk::simple::ResampleImageFilter::GetDefaultPixelValue ( ) const
inline

Get/Set the pixel value when a transformed pixel is outside of the image. The default default pixel value is 0.

Definition at line 134 of file sitkResampleImageFilter.h.

◆ GetInterpolator()

InterpolatorEnum itk::simple::ResampleImageFilter::GetInterpolator ( ) const
inline

Get/Set the interpolator function. The default is LinearInterpolateImageFunction <InputImageType, TInterpolatorPrecisionType>. Some other options are NearestNeighborInterpolateImageFunction (useful for binary masks and other images with a small number of possible pixel values), and BSplineInterpolateImageFunction (which provides a higher order of interpolation).

Definition at line 94 of file sitkResampleImageFilter.h.

◆ GetName()

std::string itk::simple::ResampleImageFilter::GetName ( ) const
inlinevirtual

Name of this class

Implements itk::simple::ProcessObject.

Definition at line 160 of file sitkResampleImageFilter.h.

◆ GetOutputDirection()

std::vector<double> itk::simple::ResampleImageFilter::GetOutputDirection ( ) const
inline

Set the output direction cosine matrix.

Definition at line 124 of file sitkResampleImageFilter.h.

◆ GetOutputOrigin()

std::vector<double> itk::simple::ResampleImageFilter::GetOutputOrigin ( ) const
inline

Get the output image origin.

Definition at line 104 of file sitkResampleImageFilter.h.

◆ GetOutputPixelType()

PixelIDValueEnum itk::simple::ResampleImageFilter::GetOutputPixelType ( ) const
inline

Get the ouput pixel type.

Definition at line 144 of file sitkResampleImageFilter.h.

◆ GetOutputSpacing()

std::vector<double> itk::simple::ResampleImageFilter::GetOutputSpacing ( ) const
inline

Get the output image spacing.

Definition at line 114 of file sitkResampleImageFilter.h.

◆ GetSize()

std::vector<uint32_t> itk::simple::ResampleImageFilter::GetSize ( ) const
inline

Get/Set the size of the output image.

Definition at line 76 of file sitkResampleImageFilter.h.

◆ GetTransform()

Transform itk::simple::ResampleImageFilter::GetTransform ( ) const
inline

Definition at line 84 of file sitkResampleImageFilter.h.

◆ GetUseNearestNeighborExtrapolator()

bool itk::simple::ResampleImageFilter::GetUseNearestNeighborExtrapolator ( ) const
inline

Definition at line 157 of file sitkResampleImageFilter.h.

◆ SetDefaultPixelValue()

Self& itk::simple::ResampleImageFilter::SetDefaultPixelValue ( double  DefaultPixelValue)
inline

Get/Set the pixel value when a transformed pixel is outside of the image. The default default pixel value is 0.

Definition at line 129 of file sitkResampleImageFilter.h.

◆ SetInterpolator()

Self& itk::simple::ResampleImageFilter::SetInterpolator ( InterpolatorEnum  Interpolator)
inline

Get/Set the interpolator function. The default is LinearInterpolateImageFunction <InputImageType, TInterpolatorPrecisionType>. Some other options are NearestNeighborInterpolateImageFunction (useful for binary masks and other images with a small number of possible pixel values), and BSplineInterpolateImageFunction (which provides a higher order of interpolation).

Definition at line 89 of file sitkResampleImageFilter.h.

◆ SetOutputDirection()

Self& itk::simple::ResampleImageFilter::SetOutputDirection ( std::vector< double >  OutputDirection)
inline

Set the output direction cosine matrix.

Definition at line 119 of file sitkResampleImageFilter.h.

◆ SetOutputOrigin()

Self& itk::simple::ResampleImageFilter::SetOutputOrigin ( std::vector< double >  OutputOrigin)
inline

Set the output image origin.

Definition at line 99 of file sitkResampleImageFilter.h.

◆ SetOutputPixelType()

Self& itk::simple::ResampleImageFilter::SetOutputPixelType ( PixelIDValueEnum  OutputPixelType)
inline

Set the output pixel type, if sitkUnknown then the input type is used.

Definition at line 139 of file sitkResampleImageFilter.h.

◆ SetOutputSpacing()

Self& itk::simple::ResampleImageFilter::SetOutputSpacing ( std::vector< double >  OutputSpacing)
inline

Set the output image spacing.

Definition at line 109 of file sitkResampleImageFilter.h.

◆ SetReferenceImage()

void itk::simple::ResampleImageFilter::SetReferenceImage ( const Image refImage)

This methods sets the output size, origin, spacing and direction to that of the provided image

◆ SetSize()

Self& itk::simple::ResampleImageFilter::SetSize ( std::vector< uint32_t >  Size)
inline

Get/Set the size of the output image.

Definition at line 71 of file sitkResampleImageFilter.h.

◆ SetTransform()

Self& itk::simple::ResampleImageFilter::SetTransform ( Transform  Transform)
inline

Definition at line 80 of file sitkResampleImageFilter.h.

◆ SetUseNearestNeighborExtrapolator()

Self& itk::simple::ResampleImageFilter::SetUseNearestNeighborExtrapolator ( bool  UseNearestNeighborExtrapolator)
inline

Enables the nearest neighbor extrapolator as opposed to the constant pixel value.

Definition at line 149 of file sitkResampleImageFilter.h.

◆ ToString()

std::string itk::simple::ResampleImageFilter::ToString ( ) const
virtual

Print ourselves out

Reimplemented from itk::simple::ProcessObject.

◆ UseNearestNeighborExtrapolatorOff()

Self& itk::simple::ResampleImageFilter::UseNearestNeighborExtrapolatorOff ( )
inline

Definition at line 153 of file sitkResampleImageFilter.h.

◆ UseNearestNeighborExtrapolatorOn()

Self& itk::simple::ResampleImageFilter::UseNearestNeighborExtrapolatorOn ( )
inline

Set the value of UseNearestNeighborExtrapolator to true or false respectfully.

Definition at line 152 of file sitkResampleImageFilter.h.

Friends And Related Function Documentation

◆ detail::DualExecuteInternalAddressor< MemberFunctionType >

Definition at line 179 of file sitkResampleImageFilter.h.

◆ detail::DualExecuteInternalVectorAddressor< MemberFunctionType >

Definition at line 181 of file sitkResampleImageFilter.h.

Member Data Documentation

◆ m_DefaultPixelValue

double itk::simple::ResampleImageFilter::m_DefaultPixelValue {0.0}
private

Definition at line 205 of file sitkResampleImageFilter.h.

◆ m_DualMemberFactory

std::unique_ptr<detail::DualMemberFunctionFactory<MemberFunctionType> > itk::simple::ResampleImageFilter::m_DualMemberFactory
private

Definition at line 184 of file sitkResampleImageFilter.h.

◆ m_Interpolator

InterpolatorEnum itk::simple::ResampleImageFilter::m_Interpolator {itk::simple::sitkLinear}
private

Definition at line 194 of file sitkResampleImageFilter.h.

◆ m_OutputDirection

std::vector<double> itk::simple::ResampleImageFilter::m_OutputDirection {std::vector<double>()}
private

Definition at line 203 of file sitkResampleImageFilter.h.

◆ m_OutputOrigin

std::vector<double> itk::simple::ResampleImageFilter::m_OutputOrigin {std::vector<double>(3, 0.0)}
private

Definition at line 197 of file sitkResampleImageFilter.h.

◆ m_OutputPixelType

PixelIDValueEnum itk::simple::ResampleImageFilter::m_OutputPixelType {itk::simple::sitkUnknown}
private

Definition at line 207 of file sitkResampleImageFilter.h.

◆ m_OutputSpacing

std::vector<double> itk::simple::ResampleImageFilter::m_OutputSpacing {std::vector<double>(3, 1.0)}
private

Definition at line 200 of file sitkResampleImageFilter.h.

◆ m_Size

std::vector<uint32_t> itk::simple::ResampleImageFilter::m_Size {std::vector<uint32_t>(3, 0)}
private

Definition at line 189 of file sitkResampleImageFilter.h.

◆ m_Transform

Transform itk::simple::ResampleImageFilter::m_Transform {itk::simple::Transform()}
private

Definition at line 191 of file sitkResampleImageFilter.h.

◆ m_UseNearestNeighborExtrapolator

bool itk::simple::ResampleImageFilter::m_UseNearestNeighborExtrapolator {false}
private

Definition at line 209 of file sitkResampleImageFilter.h.


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