Medical Imaging Interaction Toolkit  2018.4.99-b20efe7f
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_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()

ImageSource::ImageSource ( )
protected

Definition at line 18 of file mitkImageSource.cpp.

References MakeOutput().

◆ ~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.

Referenced by GenerateData().

◆ AllocateOutputs()

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 101 of file mitkImageSource.cpp.

References GetOutput().

Referenced by GenerateData().

◆ BeforeThreadedGenerateData()

virtual void mitk::ImageSource::BeforeThreadedGenerateData ( void  )
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.

Referenced by GenerateData().

◆ Clone()

Pointer mitk::ImageSource::Clone ( ) const

◆ GenerateData()

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

Definition at line 116 of file mitkImageSource.cpp.

References AfterThreadedGenerateData(), AllocateOutputs(), BeforeThreadedGenerateData(), mitk::ImageSource::ThreadStruct::Filter, and ThreaderCallback().

◆ GetClassHierarchy()

◆ GetClassName()

◆ GetOutput() [1/4]

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

◆ GetOutput() [2/4]

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

◆ GetOutput() [3/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.

Referenced by mitk::pa::SpectralUnmixingFilterBase::AddRelativeErrorSettings(), AllocateOutputs(), mitk::ToFImageRecorderFilter::CreateOutputsForAllInputs(), mitk::ToFCompositeFilter::CreateOutputsForAllInputs(), mitk::BoundingObjectToSegmentationFilter::GenerateData(), mitk::CastToFloatImageFilter::GenerateData(), mitk::USImageLoggingFilter::GenerateData(), mitk::ItkImageFileReader::GenerateData(), mitk::ImageChannelSelector::GenerateData(), mitk::VtiFileReader::GenerateData(), mitk::VtkImageReader::GenerateData(), mitk::ImageTimeSelector::GenerateData(), mitk::CropImageFilter::GenerateData(), mitk::TemporalJoinImagesFilter::GenerateData(), mitk::Convert2Dto3DImageFilter::GenerateData(), mitk::PhotoacousticBModeFilter::GenerateData(), mitk::BeamformingFilter::GenerateData(), mitk::BandpassFilter::GenerateData(), mitk::PadImageFilter::GenerateData(), mitk::TrackedUltrasound::GenerateData(), mitk::ContourModelSetToImageFilter::GenerateData(), mitk::CESTImageNormalizationFilter::GenerateData(), mitk::USCombinedModality::GenerateData(), mitk::RGBToRGBACastImageFilter::GenerateData(), mitk::SurfaceToImageFilter::GenerateData(), mitk::OtsuSegmentationFilter::GenerateData(), mitk::SurfaceStampImageFilter::GenerateData(), mitk::RawImageFileReader::GenerateData(), mitk::BoundingObjectCutter::GenerateData(), mitk::CorrectorAlgorithm::GenerateData(), mitk::BoundingShapeCropper::GenerateData(), mitk::ExtractDirectedPlaneImageFilterNew::GenerateData(), mitk::MaskImageFilter::GenerateData(), mitk::ExtractDirectedPlaneImageFilter::GenerateData(), mitk::ExtractImageFilter::GenerateData(), mitk::AutoCropImageFilter::GenerateData(), mitk::ToFCompositeFilter::GenerateData(), mitk::HeightFieldSurfaceClipImageFilter::GenerateData(), mitk::CreateDistanceImageFromSurfaceFilter::GenerateData(), mitk::GeometryClipImageFilter::GenerateData(), mitk::USIGTLDevice::GenerateData(), mitk::PhotoacousticMotionCorrectionFilter::GenerateData(), mitk::ExtractSliceFilter::GenerateData(), mitk::ToFImageGrabber::GenerateData(), mitk::USVideoDevice::GenerateData(), mitk::USDevice::GenerateData(), mitk::ImageChannelSelector::GenerateInputRequestedRegion(), mitk::ImageSliceSelector::GenerateInputRequestedRegion(), mitk::ImageTimeSelector::GenerateInputRequestedRegion(), mitk::PhotoacousticBModeFilter::GenerateInputRequestedRegion(), mitk::BeamformingFilter::GenerateInputRequestedRegion(), mitk::ContourModelSetToImageFilter::GenerateInputRequestedRegion(), mitk::RGBToRGBACastImageFilter::GenerateInputRequestedRegion(), mitk::SurfaceToImageFilter::GenerateInputRequestedRegion(), mitk::SurfaceStampImageFilter::GenerateInputRequestedRegion(), mitk::ImageToImageFilter::GenerateInputRequestedRegion(), mitk::BoundingObjectCutter::GenerateInputRequestedRegion(), mitk::BoundingShapeCropper::GenerateInputRequestedRegion(), mitk::MaskImageFilter::GenerateInputRequestedRegion(), mitk::ExtractImageFilter::GenerateInputRequestedRegion(), mitk::HeightFieldSurfaceClipImageFilter::GenerateInputRequestedRegion(), mitk::GeometryClipImageFilter::GenerateInputRequestedRegion(), mitk::ImageChannelSelector::GenerateOutputInformation(), mitk::ImageSliceSelector::GenerateOutputInformation(), mitk::ImageTimeSelector::GenerateOutputInformation(), mitk::TemporalJoinImagesFilter::GenerateOutputInformation(), mitk::PhotoacousticBModeFilter::GenerateOutputInformation(), mitk::BilateralFilter::GenerateOutputInformation(), mitk::BeamformingFilter::GenerateOutputInformation(), mitk::CESTImageNormalizationFilter::GenerateOutputInformation(), mitk::ContourModelSetToImageFilter::GenerateOutputInformation(), mitk::MRNormTwoRegionsBasedFilter::GenerateOutputInformation(), mitk::RGBToRGBACastImageFilter::GenerateOutputInformation(), mitk::MRNormLinearStatisticBasedFilter::GenerateOutputInformation(), mitk::SurfaceToImageFilter::GenerateOutputInformation(), mitk::SurfaceStampImageFilter::GenerateOutputInformation(), mitk::BoundingObjectCutter::GenerateOutputInformation(), mitk::BoundingShapeCropper::GenerateOutputInformation(), mitk::ExtractDirectedPlaneImageFilterNew::GenerateOutputInformation(), mitk::MaskImageFilter::GenerateOutputInformation(), mitk::AutoCropImageFilter::GenerateOutputInformation(), mitk::ExtractImageFilter::GenerateOutputInformation(), mitk::ToFCompositeFilter::GenerateOutputInformation(), mitk::HeightFieldSurfaceClipImageFilter::GenerateOutputInformation(), mitk::GeometryClipImageFilter::GenerateOutputInformation(), mitk::ExtractSliceFilter::GenerateOutputInformation(), mitk::PhotoacousticMotionCorrectionFilter::GetPaOutput(), mitk::ImageStatisticsHolder::GetScalarHistogram(), mitk::PhotoacousticMotionCorrectionFilter::GetUsOutput(), GetVtkImageData(), mitk::ToFImageGrabber::InitializeImages(), mitk::ContourModelSetToImageFilter::InitializeOutputEmpty(), mitk::MRNormTwoRegionsBasedFilter::InternalComputeMask(), mitk::MRNormLinearStatisticBasedFilter::InternalComputeMask(), mitk::AutoCropImageFilter::ITKCrop3DImage(), mitk::BilateralFilter::ItkImageProcessing(), mitk::ExtractImageFilter::ItkImageProcessing(), mitk::ToFImageDownsamplingFilter::ItkImageResampling(), mitk::CESTImageNormalizationFilter::NormalizeTimeSteps(), mitk::SubImageSelector::SetChannelItem(), mitk::SubImageSelector::SetSliceItem(), mitk::SubImageSelector::SetVolumeItem(), SplitRequestedRegion(), mitk::SurfaceToImageFilter::Stencil3DImage(), mitk::SurfaceStampImageFilter::SurfaceStampBinaryOutputProcessing(), mitk::SurfaceStampImageFilter::SurfaceStampProcessing(), mitk::RawImageFileReader::TypedGenerateData(), and mitk::pa::SpectralUnmixingSO2::Verbose().

◆ GetOutput() [4/4]

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

◆ GetStaticNameOfClass()

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

Definition at line 39 of file mitkImageSource.h.

◆ GetVtkImageData() [1/2]

vtkImageData * ImageSource::GetVtkImageData ( )
virtual

◆ GetVtkImageData() [2/2]

const vtkImageData * ImageSource::GetVtkImageData ( ) const
virtual

◆ MakeOutput() [1/2]

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::LabelSetImageSource, and mitk::ContourModelSetToImageFilter.

Definition at line 27 of file mitkImageSource.cpp.

References mitk::Image::New().

Referenced by mitk::ToFImageRecorderFilter::CreateOutputsForAllInputs(), mitk::ToFCompositeFilter::CreateOutputsForAllInputs(), ImageSource(), mitk::USVideoDevice::Init(), MakeOutput(), mitk::ToFImageGrabber::ToFImageGrabber(), mitk::USDiPhASDevice::USDiPhASDevice(), and mitk::USTelemedDevice::USTelemedDevice().

◆ MakeOutput() [2/2]

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::ContourModelSetToImageFilter, and mitk::LabelSetImageSource.

Definition at line 32 of file mitkImageSource.cpp.

References MakeOutput(), and mitk::Image::New().

◆ New()

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

◆ PrepareOutputs()

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

Definition at line 183 of file mitkImageSource.cpp.

◆ SplitRequestedRegion()

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 43 of file mitkImageSource.cpp.

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

◆ ThreadedGenerateData()

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 145 of file mitkImageSource.cpp.

◆ ThreaderCallback()

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 154 of file mitkImageSource.cpp.

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

Referenced by GenerateData().


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