Medical Imaging Interaction Toolkit  2016.11.0
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
 
virtual itk::DataObject::Pointer MakeOutput (DataObjectPointerArraySizeType idx) override
 Make a DataObject of the correct type to used as the specified output. More...
 
virtual 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 ()
 
virtual ~ImageSource ()
 
virtual 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...
 
virtual 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 ()
 
virtual ~BaseDataSource ()
 

Static Protected Member Functions

static 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 40 of file mitkImageSource.h.

Member Typedef Documentation

Definition at line 43 of file mitkImageSource.h.

Some convenient typedefs.

Definition at line 49 of file mitkImageSource.h.

Definition at line 43 of file mitkImageSource.h.

Constructor & Destructor Documentation

ImageSource::ImageSource ( )
protected

Definition at line 22 of file mitkImageSource.cpp.

References MakeOutput().

virtual mitk::ImageSource::~ImageSource ( )
inlineprotectedvirtual

Definition at line 137 of file mitkImageSource.h.

Member Function Documentation

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.

Reimplemented in itk::KspaceImageFilter< TPixelType >.

Definition at line 225 of file mitkImageSource.h.

void 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.

Definition at line 105 of file mitkImageSource.cpp.

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.

Reimplemented in itk::KspaceImageFilter< TPixelType >.

Definition at line 212 of file mitkImageSource.h.

Pointer mitk::ImageSource::Clone ( ) const
void ImageSource::GenerateData ( )
overrideprotectedvirtual

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()

Reimplemented in mitk::USDevice, mitk::USCombinedModality, mitk::ToFImageGrabber, mitk::ExtractSliceFilter, mitk::CreateDistanceImageFromSurfaceFilter, mitk::GeometryClipImageFilter, mitk::HeightFieldSurfaceClipImageFilter, mitk::ToFCompositeFilter, mitk::ToFImageRecorderFilter, mitk::OverwriteSliceImageFilter, mitk::AutoCropImageFilter, mitk::ExtractImageFilter, mitk::CompareImageDataFilter, mitk::ExtractDirectedPlaneImageFilter, mitk::OverwriteDirectedPlaneImageFilter, mitk::MaskImageFilter, mitk::BoundingShapeCropper, mitk::ExtractDirectedPlaneImageFilterNew, mitk::DiffusionImageCreationFilter, mitk::OpenCVToMitkImageFilter, mitk::ITKImageImport< TInputImage >, mitk::DemonsRegistration, mitk::SymmetricForcesDemonsRegistration, mitk::CorrectorAlgorithm, mitk::BoundingObjectCutter, mitk::RawImageFileReader, mitk::MultiComponentImageDataComparisonFilter, mitk::OtsuSegmentationFilter, mitk::SurfaceStampImageFilter, mitk::DWIHeadMotionCorrectionFilter, mitk::SurfaceToImageFilter, mitk::DiffusionImageTransformedCreationFilter< TTransformType >, itk::TractsToVectorImageFilter< PixelType >, mitk::ToFImageDownsamplingFilter, mitk::MRNormTwoRegionsBasedFilter, mitk::RGBToRGBACastImageFilter, mitk::MaskAndCutRoiImageFilter, mitk::BSplineRegistration, mitk::HistogramMatching, mitk::PyramidalRegistrationMethod, mitk::MRNormLinearStatisticBasedFilter, mitk::BilateralFilter, mitk::ContourModelSetToImageFilter, mitk::PadImageFilter, mitk::NrrdTbssImageReader, mitk::NrrdTbssRoiImageReader, mitk::ImageRegistrationMethod, mitk::Convert2Dto3DImageFilter, mitk::VtiFileReader, mitk::VtkImageReader, mitk::ImageTimeSelector, mitk::ImageSliceSelector, mitk::ImageChannelSelector, mitk::ItkImageFileReader, mitk::USImageLoggingFilter, and mitk::BoundingObjectToSegmentationFilter.

Definition at line 120 of file mitkImageSource.cpp.

References mitk::ImageSource::ThreadStruct::Filter.

OutputType* mitk::ImageSource::GetOutput ( DataObjectPointerArraySizeType  idx)
const OutputType* mitk::ImageSource::GetOutput ( DataObjectPointerArraySizeType  idx) const
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.

Referenced by mitk::ItkImageFileReader::GenerateData(), mitk::OtsuSegmentationFilter::GenerateData(), mitk::BoundingObjectCutter::GenerateData(), mitk::ExtractDirectedPlaneImageFilterNew::GenerateData(), mitk::BoundingShapeCropper::GenerateData(), mitk::ExtractImageFilter::GenerateData(), mitk::HeightFieldSurfaceClipImageFilter::GenerateData(), mitk::ToFImageGrabber::GenerateData(), mitk::HistogramMatching::GenerateData2(), mitk::DemonsRegistration::GenerateData2(), mitk::SymmetricForcesDemonsRegistration::GenerateData2(), mitk::BSplineRegistration::GenerateData2(), mitk::BoundingObjectCutter::GenerateInputRequestedRegion(), mitk::BoundingShapeCropper::GenerateInputRequestedRegion(), mitk::HeightFieldSurfaceClipImageFilter::GenerateInputRequestedRegion(), mitk::ImageSliceSelector::GenerateOutputInformation(), mitk::BoundingObjectCutter::GenerateOutputInformation(), mitk::BoundingShapeCropper::GenerateOutputInformation(), mitk::HeightFieldSurfaceClipImageFilter::GenerateOutputInformation(), mitk::ImageStatisticsHolder::GetScalarHistogram(), mitk::ToFImageGrabber::InitializeImages(), mitk::ExtractImageFilter::ItkImageProcessing(), and mitk::ToFImageDownsamplingFilter::ItkImageResampling().

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

Definition at line 43 of file mitkImageSource.h.

vtkImageData * ImageSource::GetVtkImageData ( )
virtual

Definition at line 192 of file mitkImageSource.cpp.

References Update().

const vtkImageData * ImageSource::GetVtkImageData ( ) const
virtual

Definition at line 198 of file mitkImageSource.cpp.

itk::DataObject::Pointer 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::TbssImageSource, mitk::TbssRoiImageSource, mitk::LabelSetImageSource, mitk::ContourModelSetToImageFilter, mitk::QBallImageSource, mitk::TensorImageSource, and mitk::QBallImageSource.

Definition at line 31 of file mitkImageSource.cpp.

References mitk::Image::New().

Referenced by ImageSource(), mitk::ToFImageGrabber::ToFImageGrabber(), and mitk::USTelemedDevice::USTelemedDevice().

itk::DataObject::Pointer 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 appopriate MakeOutput(), then ProcessObject::MakeOutput() can be made pure virtual.

Implements mitk::BaseDataSource.

Reimplemented in mitk::TbssImageSource, mitk::TbssRoiImageSource, mitk::ContourModelSetToImageFilter, mitk::QBallImageSource, mitk::TensorImageSource, and mitk::LabelSetImageSource.

Definition at line 36 of file mitkImageSource.cpp.

References mitk::Image::New().

void ImageSource::PrepareOutputs ( )
overrideprotectedvirtual

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.

Definition at line 187 of file mitkImageSource.cpp.

unsigned int 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".

Definition at line 47 of file mitkImageSource.cpp.

References mitk::Image::GetDimension(), and mitk::SlicedData::GetRequestedRegion().

void 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()

Definition at line 149 of file mitkImageSource.cpp.

ITK_THREAD_RETURN_TYPE 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().

Definition at line 158 of file mitkImageSource.cpp.

References mitk::ImageSource::ThreadStruct::Filter.


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