SimpleITK
|
Decrease the image size by cropping the image to the selected region bounds. More...
#include <sitkExtractImageFilter.h>
Decrease the image size by cropping the image to the selected region bounds.
ExtractImageFilter changes the image boundary of an image by removing pixels outside the target region. The region is specified as a Size and Index. The Size must be specified, while the Index defaults to zeros.
ExtractImageFilter can collapses dimensions so that the input image may have more dimensions than the output image (i.e. 4-D input image to a 3-D output image). To specify what dimensions to collapse, the Size must be specified. For any dimension dim where the Size[dim] == 0, that dimension is collapsed. The index to collapse on is specified by Index[dim]. For example, we have a image 4D = a 4x4x4x4 image, and we want to get a 3D image, 3D = a 4x4x4 image, specified as [x,y,z,2] from 4D (i.e. the 3rd "time" slice from 4D). The Size = [4,4,4,0] and Index = [0,0,0,2].
The number of dimension in Size and Index must at least dimension of the input image. The number of non-zero dimensions in Size determines the output dimension.
Determining the direction of the collapsed output image from an larger dimensional input space is an ill defined problem in general. It is required that the application developer select the desired transformation strategy for collapsing direction cosines. The strategy defaults to the guess approach. Direction Collapsing Strategies: 1) DirectionCollapseToUnknown(); This is the default in ITK and the filter can not run when this is set. 1) DirectionCollapseToIdentity(); Output has identity direction no matter what 2) DirectionCollapseToSubmatrix(); Output direction is the sub-matrix if it is positive definite, else throw an exception.
This filter is implemented as a multithreaded filter. It provides a DynamicThreadedGenerateData() method for its implementation.
Definition at line 72 of file sitkExtractImageFilter.h.
Public Types | |
enum | DirectionCollapseToStrategyType { DIRECTIONCOLLAPSETOUNKOWN, DIRECTIONCOLLAPSETOIDENTITY, DIRECTIONCOLLAPSETOSUBMATRIX, DIRECTIONCOLLAPSETOGUESS } |
using | PixelIDTypeList = NonLabelPixelIDTypeList |
using | Self = ExtractImageFilter |
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) |
Image | Execute (Image &&image1) |
ExtractImageFilter () | |
DirectionCollapseToStrategyType | GetDirectionCollapseToStrategy () const |
std::vector< int > | GetIndex () const |
Get the starting index to extract. More... | |
std::string | GetName () const |
std::vector< unsigned int > | GetSize () const |
Get the size of the region to extract. More... | |
Self & | SetDirectionCollapseToStrategy (DirectionCollapseToStrategyType DirectionCollapseToStrategy) |
Set the strategy to be used to collapse physical space dimensions. More... | |
Self & | SetIndex (std::vector< int > Index) |
Set the starting index of the input image to extract. More... | |
Self & | SetSize (std::vector< unsigned int > Size) |
Set the size of the region to extract. More... | |
std::string | ToString () const |
virtual | ~ExtractImageFilter () |
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 TImageType > | |
Image | ExecuteInternal (const Image &image1) |
template<class TImageType > | |
Image | ExecuteInternal (const TImageType *image1, unsigned int outputDimension, std::integral_constant< unsigned int, 1 > meta) |
template<class TImageType , unsigned int OutputDimension> | |
Image | ExecuteInternal (const TImageType *image1, unsigned int outputDimension, std::integral_constant< unsigned int, OutputDimension > meta) |
Private Attributes | |
DirectionCollapseToStrategyType | m_DirectionCollapseToStrategy |
std::vector< int > | m_Index { std::vector<int>(SITK_MAX_DIMENSION, 0) } |
bool | m_InPlace { false } |
std::unique_ptr< detail::MemberFunctionFactory< MemberFunctionType > > | m_MemberFactory |
std::vector< unsigned int > | m_Size { std::vector<unsigned int>(SITK_MAX_DIMENSION, 1) } |
Friends | |
struct | detail::MemberFunctionAddressor< 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::ProcessObject * | GetActiveProcess () |
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 | |
NonCopyable & | operator= (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::EventObject & | GetITKEventObject (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) |
|
private |
Setup for member function dispatching
Definition at line 198 of file sitkExtractImageFilter.h.
Define the pixels types supported by this filter
Definition at line 85 of file sitkExtractImageFilter.h.
Definition at line 75 of file sitkExtractImageFilter.h.
Enumerator | |
---|---|
DIRECTIONCOLLAPSETOUNKOWN | |
DIRECTIONCOLLAPSETOIDENTITY | |
DIRECTIONCOLLAPSETOSUBMATRIX | |
DIRECTIONCOLLAPSETOGUESS |
Definition at line 128 of file sitkExtractImageFilter.h.
|
virtual |
Destructor
itk::simple::ExtractImageFilter::ExtractImageFilter | ( | ) |
Default Constructor that takes no arguments and initializes default parameters
Execute the filter on the input image
|
private |
|
private |
|
private |
|
inline |
Get the currently set strategy for collapsing directions of physical space.
Definition at line 170 of file sitkExtractImageFilter.h.
|
inline |
Get the starting index to extract.
Definition at line 123 of file sitkExtractImageFilter.h.
|
inlinevirtual |
Name of this class
Implements itk::simple::ProcessObject.
Definition at line 177 of file sitkExtractImageFilter.h.
|
inline |
Get the size of the region to extract.
Definition at line 104 of file sitkExtractImageFilter.h.
|
inline |
Set the strategy to be used to collapse physical space dimensions.
DIRECTIONCOLLAPSETOIDENTITY Set the strategy so that all collapsed images have an identity direction. Use this strategy when you know that retention of the physical space orientation of the collapsed image is not important.
DIRECTIONCOLLAPSETOGUESS Set the strategy so that all collapsed images where output direction is the sub-matrix if it is positive definite, else return identity. This is backwards compatible with ITKv3, but is highly discouraged because the results are difficult to anticipate under differing data scenarios.
DIRECTIONCOLLAPSETOSUBMATRIX Set the strategy so that all collapsed images where output direction is the sub-matrix if it is positive definite, else throw an exception. Use this strategy when it is known that properly identified physical space sub-volumes can be reliably extracted from a higher dimensional space. For example when the application programmer knows that a 4D image is 3D+time, and that the 3D sub-space is properly defined.
Definition at line 161 of file sitkExtractImageFilter.h.
|
inline |
Set the starting index of the input image to extract.
The index defaults to all zeros.
Definition at line 114 of file sitkExtractImageFilter.h.
|
inline |
Set the size of the region to extract.
The size of the region to extract should be specified. Dimensions which have a size of 0 are collapsed. The number of non-zero sized determines the output dimension.
Definition at line 95 of file sitkExtractImageFilter.h.
|
virtual |
Print ourselves out
Reimplemented from itk::simple::ProcessObject.
|
friend |
Definition at line 203 of file sitkExtractImageFilter.h.
|
private |
Definition at line 224 of file sitkExtractImageFilter.h.
|
private |
Definition at line 222 of file sitkExtractImageFilter.h.
|
private |
Definition at line 229 of file sitkExtractImageFilter.h.
|
private |
Definition at line 205 of file sitkExtractImageFilter.h.
|
private |
Definition at line 220 of file sitkExtractImageFilter.h.