Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkImageToOpenCVImageFilter.h
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef mitkImageToOpenCVImageFilter_h
18 #define mitkImageToOpenCVImageFilter_h
19 
20 #include <mitkCommon.h>
21 #include <mitkImage.h>
22 #include <mitkWeakPointer.h>
23 #include <itkOpenCVImageBridge.h>
24 #include <MitkOpenCVVideoSupportExports.h>
25 
26 #include "mitkImageSliceSelector.h"
27 
28 namespace mitk
29 {
30 
34 class MITKOPENCVVIDEOSUPPORT_EXPORT ImageToOpenCVImageFilter : public itk::Object
35 {
36  public:
37  typedef itk::RGBPixel< unsigned char > UCRGBPixelType;
38  typedef itk::RGBPixel< unsigned short > USRGBPixelType;
39  typedef itk::RGBPixel< float > FloatRGBPixelType;
40  typedef itk::RGBPixel< double > DoubleRGBPixelType;
41 
43  itkFactorylessNewMacro(Self)
44  itkCloneMacro(Self)
45 
49  void SetImage( mitk::Image* _Image );
53  itkGetMacro(Image, mitk::Image*);
54 
58  bool CheckImage(mitk::Image* image);
59 
65  IplImage* GetOpenCVImage();
66 
71  cv::Mat GetOpenCVMat();
72 
73  //##Documentation
74  //## @brief Convenient method to set a certain slice of a 3D or 4D mitk::Image as input to convert it to an openCV image
75  //##
76  //## This methods sets the input. Call GetOpenCVMat() or GetOpenCVImage() to get the image.
77  //##
78  //## @param mitkImage - the image that should be converted to an openCVImage
79  //## @param timeStep - the time step, which is converted to openCV
80  //## @param slice - the slice which is converted to openCV
81  void SetInputFromTimeSlice(Image::Pointer mitkImage, int timeStep, int slice);
82 
83  protected:
87  template<typename TPixel, unsigned int VImageDimension>
88  void ItkImageProcessing( itk::Image<TPixel,VImageDimension>* image );
89 
92 
96  mitk::WeakPointer<mitk::Image> m_Image;
97  IplImage* m_OpenCVImage;
98 
99  private:
100  ImageSliceSelector::Pointer m_sliceSelector;
101 };
102 
103 } // namespace
104 
105 #endif // mitkImageToOpenCVImageFilter_h
106 
107 
DataCollection - Class to facilitate loading/accessing structured data.
itk::RGBPixel< unsigned short > USRGBPixelType
A pseudo-Filter for creating OpenCV images from MITK images with the option of copying data or refere...
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:53
Image class for storing images.
Definition: mitkImage.h:76
Implements a weak reference to an object.
Provides access to a slice of the input image.
itk::RGBPixel< unsigned char > UCRGBPixelType