MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitkOpenCVToMitkImageFilter.h
Go to the documentation of this file.
1/*============================================================================
2
3The Medical Imaging Interaction Toolkit (MITK)
4
5Copyright (c) German Cancer Research Center (DKFZ)
6All rights reserved.
7
8Use of this source code is governed by a 3-clause BSD license that can be
9found in the LICENSE file.
10
11============================================================================*/
12
13#ifndef mitkOpenCVToMitkImageFilter_h
14#define mitkOpenCVToMitkImageFilter_h
15
16// mitk includes
17#include <MitkOpenCVVideoSupportExports.h>
18#include <mitkCommon.h>
19#include <mitkImageSource.h>
20
21// itk includes
22#include <itkMacro.h>
23#include <itkImage.h>
24
25// OpenCV includes
26#include <opencv2/core.hpp>
27#include <opencv2/core/core_c.h>
28
29#include <mutex>
30
31namespace mitk
32{
33
37 class MITKOPENCVVIDEOSUPPORT_EXPORT OpenCVToMitkImageFilter : public ImageSource
38 {
39 public:
40 typedef itk::RGBPixel< unsigned char > UCRGBPixelType;
41 typedef itk::RGBPixel< unsigned short > USRGBPixelType;
42 typedef itk::RGBPixel< float > FloatRGBPixelType;
43 typedef itk::RGBPixel< double > DoubleRGBPixelType;
44
48 template <typename TPixel, unsigned int VImageDimension>
49 static Image::Pointer ConvertCVMatToMitkImage(const cv::Mat input);
50
54
58 void SetOpenCVImage(const IplImage* image);
59 //itkGetMacro(OpenCVImage, const IplImage*);
60
64 void SetOpenCVMat(const cv::Mat& image);
65 itkGetMacro(OpenCVMat, cv::Mat);
66
67 OutputImageType* GetOutput(void);
68
69 //##Documentation
70 //## @brief Convenient method to insert an openCV image as a slice at a
71 //## certain time step into a 3D or 4D mitk::Image.
72 //##
73 //## @param openCVImage - the image that is inserted into the mitk Image
74 //## @param mitkImage - pointer to the mitkImage, which is changed by this method!
75 //## @param timeStep - the time step, at which the openCVImage is inserted
76 //##
77 //## @attention The parameter mitkImage will be changed!
78 void InsertOpenCVImageAsMitkTimeSlice(const cv::Mat openCVImage, Image::Pointer mitkImage, int timeStep);
79
80 protected:
81
82 OpenCVToMitkImageFilter(); // purposely hidden
83 ~OpenCVToMitkImageFilter() override;
84
85 void GenerateData() override;
86
87 protected:
88 Image::Pointer m_Image;
89 cv::Mat m_OpenCVMat;
90
91 std::mutex m_ImageMutex;
92 std::mutex m_OpenCVMatMutex;
93 };
94
95} // namespace mitk
96
97#endif
Filter for creating MITK RGB Images from an OpenCV image.
itk::RGBPixel< unsigned char > UCRGBPixelType
itk::RGBPixel< unsigned short > USRGBPixelType
itkGetMacro(OpenCVMat, cv::Mat)
mitkClassMacro(OpenCVToMitkImageFilter, ImageSource)
IGT Exceptions.