Medical Imaging Interaction Toolkit  2024.06.00
Medical Imaging Interaction Toolkit
mitk::ImageSource Class Reference

Superclass of all classes generating Images (instances of class Image) as output. More...

#include <mitkImageSource.h>

Inheritance diagram for mitk::ImageSource:
Collaboration diagram for mitk::ImageSource:

Classes

struct  ThreadStruct
 Internal structure used for passing image data into the threading library. More...
 

Public Types

typedef ImageSource Self
 
typedef BaseDataSource Superclass
 
typedef itk::SmartPointer< SelfPointer
 
typedef itk::SmartPointer< const SelfConstPointer
 
typedef mitk::Image OutputImageType
 Some convenient typedefs. More...
 
typedef OutputImageType OutputType
 
typedef OutputImageType::Pointer OutputImagePointer
 
typedef SlicedData::RegionType OutputImageRegionType
 
- Public Types inherited from mitk::BaseDataSource
typedef BaseDataSource Self
 
typedef itk::ProcessObject Superclass
 
typedef itk::SmartPointer< SelfPointer
 
typedef itk::SmartPointer< const SelfConstPointer
 
typedef BaseData OutputType
 
typedef itk::DataObject::DataObjectIdentifierType DataObjectIdentifierType
 

Public Member Functions

virtual std::vector< std::string > GetClassHierarchy () const override
 
virtual const char * GetClassName () const
 
Pointer Clone () const
 
OutputTypeGetOutput ()
 Get the output data of this image source object. More...
 
const OutputTypeGetOutput () const
 
OutputTypeGetOutput (DataObjectPointerArraySizeType idx)
 
const OutputTypeGetOutput (DataObjectPointerArraySizeType idx) const
 
itk::DataObject::Pointer MakeOutput (DataObjectPointerArraySizeType idx) override
 Make a DataObject of the correct type to used as the specified output. More...
 
itk::DataObject::Pointer MakeOutput (const DataObjectIdentifierType &name) override
 
virtual vtkImageData * GetVtkImageData ()
 
virtual const vtkImageData * GetVtkImageData () const
 
- Public Member Functions inherited from mitk::BaseDataSource
OutputTypeGetOutput ()
 
const OutputTypeGetOutput () const
 
OutputTypeGetOutput (DataObjectPointerArraySizeType idx)
 
const OutputTypeGetOutput (DataObjectPointerArraySizeType idx) const
 
virtual void GraftOutput (OutputType *output)
 Graft the specified BaseData onto this BaseDataSource's output. More...
 
virtual void GraftOutput (const DataObjectIdentifierType &key, OutputType *output)
 
virtual void GraftNthOutput (unsigned int idx, OutputType *output)
 Graft the specified base data object onto this BaseDataSource's idx'th output. More...
 
bool Updating () const
 Access itk::ProcessObject::m_Updating. More...
 

Static Public Member Functions

static const char * GetStaticNameOfClass ()
 
static Pointer New ()
 Method for creation through the object factory. More...
 
- Static Public Member Functions inherited from mitk::BaseDataSource
static const char * GetStaticNameOfClass ()
 

Protected Member Functions

 ImageSource ()
 
 ~ImageSource () override
 
void GenerateData () override
 A version of GenerateData() specific for image processing filters. More...
 
virtual void ThreadedGenerateData (const OutputImageRegionType &outputRegionForThread, itk::ThreadIdType threadId)
 If an imaging filter can be implemented as a multithreaded algorithm, the filter will provide an implementation of ThreadedGenerateData(). More...
 
void PrepareOutputs () override
 This method is intentionally left blank. More...
 
virtual void AllocateOutputs ()
 The GenerateData method normally allocates the buffers for all of the outputs of a filter. More...
 
virtual void BeforeThreadedGenerateData ()
 If an imaging filter needs to perform processing after the buffer has been allocated but before threads are spawned, the filter can can provide an implementation for BeforeThreadedGenerateData(). More...
 
virtual void AfterThreadedGenerateData ()
 If an imaging filter needs to perform processing after all processing threads have completed, the filter can can provide an implementation for AfterThreadedGenerateData(). More...
 
virtual unsigned int SplitRequestedRegion (unsigned int i, unsigned int num, OutputImageRegionType &splitRegion)
 Split the output's RequestedRegion into "num" pieces, returning region "i" as "splitRegion". More...
 
- Protected Member Functions inherited from mitk::BaseDataSource
 BaseDataSource ()
 
 ~BaseDataSource () override
 

Static Protected Member Functions

static itk::ITK_THREAD_RETURN_TYPE ThreaderCallback (void *arg)
 Static function used as a "callback" by the MultiThreader. More...
 
- Static Protected Member Functions inherited from mitk::BaseDataSource
static Pointer New ()
 

Detailed Description

Superclass of all classes generating Images (instances of class Image) as output.

In itk and vtk the generated result of a ProcessObject is only guaranteed to be up-to-date, when Update() of the ProcessObject or the generated DataObject is called immediately before access of the data stored in the DataObject. This is also true for subclasses of mitk::BaseProcess and thus for mitk::ImageSource. But there are also three access methods provided that guarantee an up-to-date result (by first calling Update and then returning the result of GetOutput()): GetData(), GetPic() and GetVtkImageData().

Definition at line 36 of file mitkImageSource.h.

Member Typedef Documentation

◆ ConstPointer

Definition at line 39 of file mitkImageSource.h.

◆ OutputImagePointer

◆ OutputImageRegionType

◆ OutputImageType

Some convenient typedefs.

Definition at line 43 of file mitkImageSource.h.

◆ OutputType

◆ Pointer

◆ Self

Definition at line 39 of file mitkImageSource.h.

◆ Superclass

Constructor & Destructor Documentation

◆ ImageSource()

mitk::ImageSource::ImageSource ( )
protected

◆ ~ImageSource()

mitk::ImageSource::~ImageSource ( )
inlineoverrideprotected

Definition at line 134 of file mitkImageSource.h.

Member Function Documentation

◆ AfterThreadedGenerateData()

virtual void mitk::ImageSource::AfterThreadedGenerateData ( )
inlineprotectedvirtual

If an imaging filter needs to perform processing after all processing threads have completed, the filter can can provide an implementation for AfterThreadedGenerateData().

The execution flow in the default GenerateData() method will be: 1) Allocate the output buffer 2) Call BeforeThreadedGenerateData() 3) Spawn threads, calling ThreadedGenerateData() in each thread. 4) Call AfterThreadedGenerateData() Note that this flow of control is only available if a filter provides a ThreadedGenerateData() method and NOT a GenerateData() method.

Definition at line 222 of file mitkImageSource.h.

◆ AllocateOutputs()

virtual void mitk::ImageSource::AllocateOutputs ( )
protectedvirtual

The GenerateData method normally allocates the buffers for all of the outputs of a filter.

Some filters may want to override this default behavior. For example, a filter may have multiple outputs with varying resolution. Or a filter may want to process data in place by grafting its input to its output.

◆ BeforeThreadedGenerateData()

virtual void mitk::ImageSource::BeforeThreadedGenerateData ( )
inlineprotectedvirtual

If an imaging filter needs to perform processing after the buffer has been allocated but before threads are spawned, the filter can can provide an implementation for BeforeThreadedGenerateData().

The execution flow in the default GenerateData() method will be: 1) Allocate the output buffer 2) Call BeforeThreadedGenerateData() 3) Spawn threads, calling ThreadedGenerateData() in each thread. 4) Call AfterThreadedGenerateData() Note that this flow of control is only available if a filter provides a ThreadedGenerateData() method and NOT a GenerateData() method.

Definition at line 209 of file mitkImageSource.h.

◆ Clone()

Pointer mitk::ImageSource::Clone ( ) const

◆ GenerateData()

void mitk::ImageSource::GenerateData ( )
overrideprotected

A version of GenerateData() specific for image processing filters.

This implementation will split the processing across multiple threads. The buffer is allocated by this method. Then the BeforeThreadedGenerateData() method is called (if provided). Then, a series of threads are spawned each calling ThreadedGenerateData(). After all the threads have completed processing, the AfterThreadedGenerateData() method is called (if provided). If an image processing filter cannot be threaded, the filter should provide an implementation of GenerateData(). That implementation is responsible for allocating the output buffer. If a filter an be threaded, it should NOT provide a GenerateData() method but should provide a ThreadedGenerateData() instead.

See also
ThreadedGenerateData()

◆ GetClassHierarchy()

◆ GetClassName()

◆ GetOutput() [1/4]

OutputType* mitk::ImageSource::GetOutput ( )

Get the output data of this image source object.

The output of this function is not valid until an appropriate Update() method has been called, either explicitly or implicitly. Both the filter itself and the data object have Update() methods, and both methods update the data. Here are three ways to use GetOutput() and make sure the data is valid. In these examples, image is a pointer to some Image object, and the particular ProcessObjects involved are filters. The same examples apply to non-image (e.g. Mesh) data as well.

anotherFilter->SetInput( someFilter->GetOutput() );
anotherFilter->Update();

In this situation, someFilter and anotherFilter are said to constitute a pipeline.

image = someFilter->GetOutput();
image->Update();
someFilter->Update();
image = someFilter->GetOutput();

(In the above example, the two lines of code can be in either order.)

Note that Update() is not called automatically except within a pipeline as in the first example. When streaming (using a StreamingImageFilter) is activated, it may be more efficient to use a pipeline than to call Update() once for each filter in turn.

For an image, the data generated is for the requested Region, which can be set using ImageBase::SetRequestedRegion(). By default, the largest possible region is requested.

For Filters which have multiple outputs of different types, the GetOutput() method assumes the output is of OutputImageType. For the GetOutput(DataObjectPointerArraySizeType) method, a dynamic_cast is performed incase the filter has outputs of different types or image types. Derived classes should have named get methods for these outputs.

◆ GetOutput() [2/4]

const OutputType* mitk::ImageSource::GetOutput ( ) const

◆ GetOutput() [3/4]

OutputType* mitk::ImageSource::GetOutput ( DataObjectPointerArraySizeType  idx)

◆ GetOutput() [4/4]

const OutputType* mitk::ImageSource::GetOutput ( DataObjectPointerArraySizeType  idx) const

◆ GetStaticNameOfClass()

static const char* mitk::ImageSource::GetStaticNameOfClass ( )
inlinestatic

Definition at line 39 of file mitkImageSource.h.

◆ GetVtkImageData() [1/2]

virtual vtkImageData* mitk::ImageSource::GetVtkImageData ( )
virtual

◆ GetVtkImageData() [2/2]

virtual const vtkImageData* mitk::ImageSource::GetVtkImageData ( ) const
virtual

◆ MakeOutput() [1/2]

itk::DataObject::Pointer mitk::ImageSource::MakeOutput ( const DataObjectIdentifierType name)
overridevirtual

This is a default implementation to make sure we have something. Once all the subclasses of ProcessObject provide an appropriate MakeOutput(), then ProcessObject::MakeOutput() can be made pure virtual.

Implements mitk::BaseDataSource.

Reimplemented in mitk::ContourModelSetToImageFilter, and mitk::LabelSetImageSource.

◆ MakeOutput() [2/2]

itk::DataObject::Pointer mitk::ImageSource::MakeOutput ( DataObjectPointerArraySizeType  idx)
overridevirtual

Make a DataObject of the correct type to used as the specified output.

Every ProcessObject subclass must be able to create a DataObject that can be used as a specified output. This method is automatically called when DataObject::DisconnectPipeline() is called. DataObject::DisconnectPipeline, disconnects a data object from being an output of its current source. When the data object is disconnected, the ProcessObject needs to construct a replacement output data object so that the ProcessObject is in a valid state. So DataObject::DisconnectPipeline eventually calls ProcessObject::MakeOutput. Note that MakeOutput always returns a SmartPointer to a DataObject. If a subclass of ImageSource has multiple outputs of different types, then that class must provide an implementation of MakeOutput().

Implements mitk::BaseDataSource.

Reimplemented in mitk::ContourModelSetToImageFilter, and mitk::LabelSetImageSource.

◆ New()

static Pointer mitk::ImageSource::New ( )
static

Method for creation through the object factory.

◆ PrepareOutputs()

void mitk::ImageSource::PrepareOutputs ( )
overrideprotected

This method is intentionally left blank.

ImageSource's need not Initialize their containers. The Image::Allocate() method (called from GenerateData()) will resize the container if more memory is needed. Otherwise, the memory can be reused.

◆ SplitRequestedRegion()

virtual unsigned int mitk::ImageSource::SplitRequestedRegion ( unsigned int  i,
unsigned int  num,
OutputImageRegionType splitRegion 
)
protectedvirtual

Split the output's RequestedRegion into "num" pieces, returning region "i" as "splitRegion".

This method is called "num" times. The regions must not overlap. The method returns the number of pieces that the routine is capable of splitting the output RequestedRegion, i.e. return value is less than or equal to "num".

◆ ThreadedGenerateData()

virtual void mitk::ImageSource::ThreadedGenerateData ( const OutputImageRegionType outputRegionForThread,
itk::ThreadIdType  threadId 
)
protectedvirtual

If an imaging filter can be implemented as a multithreaded algorithm, the filter will provide an implementation of ThreadedGenerateData().

This superclass will automatically split the output image into a number of pieces, spawn multiple threads, and call ThreadedGenerateData() in each thread. Prior to spawning threads, the BeforeThreadedGenerateData() method is called. After all the threads have completed, the AfterThreadedGenerateData() method is called. If an image processing filter cannot support threading, that filter should provide an implementation of the GenerateData() method instead of providing an implementation of ThreadedGenerateData(). If a filter provides a GenerateData() method as its implementation, then the filter is responsible for allocating the output data. If a filter provides a ThreadedGenerateData() method as its implementation, then the output memory will allocated automatically by this superclass. The ThreadedGenerateData() method should only produce the output specified by "outputThreadRegion" parameter. ThreadedGenerateData() cannot write to any other portion of the output image (as this is responsibility of a different thread).

See also
GenerateData(), SplitRequestedRegion()

◆ ThreaderCallback()

static itk::ITK_THREAD_RETURN_TYPE mitk::ImageSource::ThreaderCallback ( void *  arg)
staticprotected

Static function used as a "callback" by the MultiThreader.

The threading library will call this routine for each thread, which will delegate the control to ThreadedGenerateData().


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