00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date: 2010-01-28 18:32:03 +0100 (Do, 28 Jan 2010) $ 00006 Version: $Revision: 21147 $ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 #ifndef mitkOpenCVToMitkImageFilter_h 00019 #define mitkOpenCVToMitkImageFilter_h 00020 00021 #include <mitkCommon.h> 00022 #include <mitkImageSource.h> 00023 #include <itkMacro.h> 00024 #include <itkImage.h> 00025 #include <itkRGBPixel.h> 00026 #include <cv.h> 00027 00028 #include "mitkOpenCVVideoSupportExports.h" 00029 00030 namespace mitk 00031 { 00032 00038 class MITK_OPENCVVIDEOSUPPORT_EXPORT OpenCVToMitkImageFilter : public ImageSource 00039 { 00040 public: 00041 typedef itk::RGBPixel< unsigned char > UCRGBPixelType; 00042 typedef itk::RGBPixel< unsigned short > USRGBPixelType; 00043 typedef itk::RGBPixel< float > FloatRGBPixelType; 00044 typedef itk::RGBPixel< double > DoubleRGBPixelType; 00045 00046 template <typename TPixel, unsigned int VImageDimension> 00047 static mitk::Image::Pointer ConvertIplToMitkImage( const IplImage * input, bool copyBuffer = true ); 00048 00049 mitkClassMacro(OpenCVToMitkImageFilter, ImageSource); 00050 itkNewMacro(OpenCVToMitkImageFilter); 00051 00052 itkSetObjectMacro(OpenCVImage, const IplImage); 00053 itkGetMacro(OpenCVImage, const IplImage*); 00054 00055 virtual DataObjectPointer MakeOutput(unsigned int idx); 00056 OutputImageType* GetOutput(unsigned int idx); 00057 00058 protected: 00059 00060 OpenCVToMitkImageFilter(); // purposely hidden 00061 virtual ~OpenCVToMitkImageFilter(); 00062 00063 virtual void GenerateData(); 00064 00065 protected: 00066 mitk::Image::Pointer m_Image; 00067 const IplImage* m_OpenCVImage; 00068 }; 00069 00070 } // namespace 00071 00072 #endif // mitkOpenCVToMitkImageFilter_h 00073 00074