Medical Imaging Interaction Toolkit  2023.12.00
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkImageToOpenCVImageFilter_h
14 #define mitkImageToOpenCVImageFilter_h
15 
16 #include <mitkCommon.h>
17 #include <mitkImage.h>
18 #include <mitkWeakPointer.h>
19 #include <itkOpenCVImageBridge.h>
20 #include <MitkOpenCVVideoSupportExports.h>
21 #include <opencv2/core.hpp>
22 
23 #include "mitkImageSliceSelector.h"
24 
25 namespace mitk
26 {
27 
31 class MITKOPENCVVIDEOSUPPORT_EXPORT ImageToOpenCVImageFilter : public itk::Object
32 {
33  public:
34  typedef itk::RGBPixel< unsigned char > UCRGBPixelType;
35  typedef itk::RGBPixel< unsigned short > USRGBPixelType;
36  typedef itk::RGBPixel< float > FloatRGBPixelType;
37  typedef itk::RGBPixel< double > DoubleRGBPixelType;
38 
40  itkFactorylessNewMacro(Self);
41  itkCloneMacro(Self);
42 
46  void SetImage( mitk::Image* _Image );
50  mitk::Image* GetImage();
51 
55  bool CheckImage(mitk::Image* image);
56 
61  cv::Mat GetOpenCVMat();
62 
63  //##Documentation
64  //## @brief Convenient method to set a certain slice of a 3D or 4D mitk::Image as input to convert it to an openCV image
65  //##
66  //## This methods sets the input. Call GetOpenCVMat() to get the image.
67  //##
68  //## @param mitkImage - the image that should be converted to an openCVImage
69  //## @param timeStep - the time step, which is converted to openCV
70  //## @param slice - the slice which is converted to openCV
71  void SetInputFromTimeSlice(Image::Pointer mitkImage, int timeStep, int slice);
72 
73  protected:
77  template<typename TPixel, unsigned int VImageDimension>
78  void ItkImageProcessing( itk::Image<TPixel,VImageDimension>* image );
79 
81  ~ImageToOpenCVImageFilter() override;
82 
87  cv::Mat m_OpenCVImage;
88 
89  private:
90  ImageSliceSelector::Pointer m_sliceSelector;
91 };
92 
93 } // namespace
94 
95 #endif
mitk::ImageToOpenCVImageFilter
A pseudo-filter for creating OpenCV images from MITK images with the option of copying data or refere...
Definition: mitkImageToOpenCVImageFilter.h:31
mitkImage.h
mitk::ImageToOpenCVImageFilter::UCRGBPixelType
itk::RGBPixel< unsigned char > UCRGBPixelType
Definition: mitkImageToOpenCVImageFilter.h:34
mitk::ImageToOpenCVImageFilter::USRGBPixelType
itk::RGBPixel< unsigned short > USRGBPixelType
Definition: mitkImageToOpenCVImageFilter.h:35
mitk::Image
Image class for storing images.
Definition: mitkImage.h:69
itk::SmartPointer< Self >
mitkClassMacroItkParent
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
mitk::ImageToOpenCVImageFilter::FloatRGBPixelType
itk::RGBPixel< float > FloatRGBPixelType
Definition: mitkImageToOpenCVImageFilter.h:36
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::ImageToOpenCVImageFilter::DoubleRGBPixelType
itk::RGBPixel< double > DoubleRGBPixelType
Definition: mitkImageToOpenCVImageFilter.h:37
mitkImageSliceSelector.h
mitkCommon.h
mitk::ImageToOpenCVImageFilter::m_OpenCVImage
cv::Mat m_OpenCVImage
Definition: mitkImageToOpenCVImageFilter.h:87
mitkWeakPointer.h
mitk::ImageToOpenCVImageFilter::m_Image
mitk::WeakPointer< mitk::Image > m_Image
Definition: mitkImageToOpenCVImageFilter.h:86
mitk::WeakPointer< mitk::Image >