Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitk::OpenCVToMitkImageFilter Class Reference

Filter for creating MITK RGB Images from an OpenCV image. More...

#include <mitkOpenCVToMitkImageFilter.h>

Inheritance diagram for mitk::OpenCVToMitkImageFilter:
Collaboration diagram for mitk::OpenCVToMitkImageFilter:

Public Types

typedef itk::RGBPixel< unsigned char > UCRGBPixelType
 
typedef itk::RGBPixel< unsigned short > USRGBPixelType
 
typedef itk::RGBPixel< float > FloatRGBPixelType
 
typedef itk::RGBPixel< double > DoubleRGBPixelType
 
- Public Types inherited from mitk::ImageSource
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

 mitkClassMacro (OpenCVToMitkImageFilter, ImageSource)
 
Pointer Clone () const
 
void SetOpenCVImage (const IplImage *image)
 
void SetOpenCVMat (const cv::Mat &image)
 
virtual cv::Mat GetOpenCVMat ()
 
OutputImageTypeGetOutput (void)
 
void InsertOpenCVImageAsMitkTimeSlice (const cv::Mat openCVImage, Image::Pointer mitkImage, int timeStep)
 Convenient method to insert an openCV image as a slice at a certain time step into a 3D or 4D mitk::Image. More...
 
- Public Member Functions inherited from mitk::ImageSource
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

template<typename TPixel , unsigned int VImageDimension>
static Image::Pointer ConvertCVMatToMitkImage (const cv::Mat input)
 
static Pointer New ()
 
- Static Public Member Functions inherited from mitk::ImageSource
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

 OpenCVToMitkImageFilter ()
 
virtual ~OpenCVToMitkImageFilter ()
 
virtual void GenerateData () override
 A version of GenerateData() specific for image processing filters. More...
 
- Protected Member Functions inherited from mitk::ImageSource
 ImageSource ()
 
virtual ~ImageSource ()
 
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 ()
 

Protected Attributes

Image::Pointer m_Image
 
cv::Mat m_OpenCVMat
 
itk::FastMutexLock::Pointer m_ImageMutex
 
itk::FastMutexLock::Pointer m_OpenCVMatMutex
 

Additional Inherited Members

- Static Protected Member Functions inherited from mitk::ImageSource
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

Filter for creating MITK RGB Images from an OpenCV image.

Definition at line 39 of file mitkOpenCVToMitkImageFilter.h.

Member Typedef Documentation

typedef itk::RGBPixel< double > mitk::OpenCVToMitkImageFilter::DoubleRGBPixelType

Definition at line 45 of file mitkOpenCVToMitkImageFilter.h.

typedef itk::RGBPixel< float > mitk::OpenCVToMitkImageFilter::FloatRGBPixelType

Definition at line 44 of file mitkOpenCVToMitkImageFilter.h.

typedef itk::RGBPixel< unsigned char > mitk::OpenCVToMitkImageFilter::UCRGBPixelType

Definition at line 42 of file mitkOpenCVToMitkImageFilter.h.

typedef itk::RGBPixel< unsigned short > mitk::OpenCVToMitkImageFilter::USRGBPixelType

Definition at line 43 of file mitkOpenCVToMitkImageFilter.h.

Constructor & Destructor Documentation

mitk::OpenCVToMitkImageFilter::OpenCVToMitkImageFilter ( )
protected

Definition at line 29 of file mitkOpenCVToMitkImageFilter.cpp.

References m_ImageMutex, m_OpenCVMatMutex, and mitk::New().

mitk::OpenCVToMitkImageFilter::~OpenCVToMitkImageFilter ( )
protectedvirtual

Definition at line 35 of file mitkOpenCVToMitkImageFilter.cpp.

Member Function Documentation

Pointer mitk::OpenCVToMitkImageFilter::Clone ( ) const
template<typename TPixel , unsigned int VImageDimension>
Image::Pointer mitk::OpenCVToMitkImageFilter::ConvertCVMatToMitkImage ( const cv::Mat  input)
static

the static function for the conversion

Definition at line 124 of file mitkOpenCVToMitkImageFilter.cpp.

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

void mitk::OpenCVToMitkImageFilter::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 from mitk::ImageSource.

Definition at line 53 of file mitkOpenCVToMitkImageFilter.cpp.

References m_Image, m_ImageMutex, m_OpenCVMat, m_OpenCVMatMutex, and MITK_WARN.

virtual cv::Mat mitk::OpenCVToMitkImageFilter::GetOpenCVMat ( )
virtual
ImageSource::OutputImageType * mitk::OpenCVToMitkImageFilter::GetOutput ( void  )

Definition at line 115 of file mitkOpenCVToMitkImageFilter.cpp.

References m_Image.

Referenced by InsertOpenCVImageAsMitkTimeSlice().

void mitk::OpenCVToMitkImageFilter::InsertOpenCVImageAsMitkTimeSlice ( const cv::Mat  openCVImage,
Image::Pointer  mitkImage,
int  timeStep 
)

Convenient method to insert an openCV image as a slice at a certain time step into a 3D or 4D mitk::Image.

Parameters
openCVImage- the image that is inserted into the mitk Image
mitkImage- pointer to the mitkImage, which is changed by this method!
timeStep- the time step, at which the openCVImage is inserted
Attention
The parameter mitkImage will be changed!

Definition at line 136 of file mitkOpenCVToMitkImageFilter.cpp.

References GetData(), GetOutput(), m_Image, m_ImageMutex, SetOpenCVMat(), and Update().

mitk::OpenCVToMitkImageFilter::mitkClassMacro ( OpenCVToMitkImageFilter  ,
ImageSource   
)
static Pointer mitk::OpenCVToMitkImageFilter::New ( )
static
void mitk::OpenCVToMitkImageFilter::SetOpenCVImage ( const IplImage *  image)

sets an iplimage as input

Definition at line 47 of file mitkOpenCVToMitkImageFilter.cpp.

References SetOpenCVMat().

void mitk::OpenCVToMitkImageFilter::SetOpenCVMat ( const cv::Mat &  image)

sets an opencv mat as input (will be used if OpenCVImage Ipl image is 0)

Definition at line 39 of file mitkOpenCVToMitkImageFilter.cpp.

References m_OpenCVMat, and m_OpenCVMatMutex.

Referenced by InsertOpenCVImageAsMitkTimeSlice(), and SetOpenCVImage().

Member Data Documentation

Image::Pointer mitk::OpenCVToMitkImageFilter::m_Image
protected
itk::FastMutexLock::Pointer mitk::OpenCVToMitkImageFilter::m_ImageMutex
protected
cv::Mat mitk::OpenCVToMitkImageFilter::m_OpenCVMat
protected

Definition at line 91 of file mitkOpenCVToMitkImageFilter.h.

Referenced by GenerateData(), and SetOpenCVMat().

itk::FastMutexLock::Pointer mitk::OpenCVToMitkImageFilter::m_OpenCVMatMutex
protected

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