00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __igstkVideoFrameSpatialObject_h
00018 #define __igstkVideoFrameSpatialObject_h
00019
00020 #include "igstkMacros.h"
00021 #include "igstkSpatialObject.h"
00022 #include "igstkFrame.h"
00023 #include "igstkTimeStamp.h"
00024 #include "igstkVideoImagerTool.h"
00025
00026 #include "itkVTKImageExport.h"
00027 #include "itkImage.h"
00028 #include "itkSize.h"
00029 #include "itkImageRegion.h"
00030 #include "itkIndex.h"
00031 #include "itkImportImageFilter.h"
00032 #include "itkRGBPixel.h"
00033
00034 #include "vtkImageData.h"
00035 #include "vtkImageImport.h"
00036
00037 #define DIMENSION 2
00038
00039 namespace igstk
00040 {
00041
00042 template < class TPixelType, unsigned int TChannels >
00043 class VideoFrameSpatialObject
00044 : public SpatialObject
00045 {
00046
00047 public:
00049 igstkStandardTemplatedClassTraitsMacro( VideoFrameSpatialObject,
00050 SpatialObject )
00051
00052 typedef itk::SpatialObject<3> VideoFrameSpatialObjectType;
00053
00054 typedef typename itk::RGBPixel< TPixelType > RGBPixelType;
00055 typedef typename itk::ImportImageFilter< RGBPixelType, DIMENSION >
00056 RGBImportFilterType;
00057 typedef typename itk::Image< RGBPixelType , DIMENSION > RGBImageType;
00058
00059 typedef TPixelType PixelType;
00060 typedef typename itk::ImportImageFilter< PixelType, DIMENSION >
00061 ImportFilterType;
00062 typedef typename itk::Image< PixelType , DIMENSION > ImageType;
00063
00064 typedef Frame FrameType;
00065 typedef typename TimeStamp::TimePeriodType TimePeriodType;
00066
00067 itkStaticConstMacro( m_NumberOfChannels, unsigned int, TChannels );
00068
00069 void Initialize();
00070
00071 igstkLoadedTemplatedConstObjectEventMacro( ITKImageModifiedEvent,
00072 IGSTKEvent, ImageType);
00073
00074 igstkLoadedTemplatedConstObjectEventMacro( ITKRGBImageModifiedEvent,
00075 IGSTKEvent, RGBImageType);
00076
00078 virtual bool IsEmpty() const;
00079
00080 vtkImageData* GetImageData();
00081 TimeStamp::TimePeriodType GetFrameExpirationTime() const;
00082 TimeStamp::TimePeriodType GetFrameStartTime() const;
00083
00084 igstkSetMacro(Width, unsigned int);
00085 igstkGetMacro(Width, unsigned int);
00086
00087 igstkSetMacro(Height, unsigned int);
00088 igstkGetMacro(Height, unsigned int);
00089
00090 igstkSetMacro(NumberOfScalarComponents, unsigned int);
00091 igstkGetMacro(NumberOfScalarComponents, unsigned int);
00092
00093
00094 const unsigned int GetNumberOfChannels() const;
00095
00096 igstkSetMacro(PixelSizeX, double);
00097 igstkGetMacro(PixelSizeX, double);
00098
00099 igstkSetMacro(PixelSizeY, double);
00100 igstkGetMacro(PixelSizeY, double);
00101
00102 void RequestGetITKImage();
00103 void RequestGetVTKImage()const;
00104 void SetVideoImagerTool(igstk::VideoImagerTool::Pointer);
00105
00106
00107 void UpdateImages();
00108 TPixelType* GetImagePtr();
00109
00110 protected:
00111 VideoFrameSpatialObject( void );
00112 ~VideoFrameSpatialObject( void );
00113
00114 private:
00115
00116 typename RGBImageType::Pointer m_RGBImage;
00117 typename RGBImportFilterType::Pointer m_RGBImportFilter;
00118
00119 typename ImageType::Pointer m_Image;
00120 typename ImportFilterType::Pointer m_ImportFilter;
00121
00122 itk::Size<DIMENSION> m_Size;
00123 itk::ImageRegion<DIMENSION> m_Region;
00124 itk::Index<DIMENSION> m_Start;
00125
00126 vtkImageData* m_VTKImage;
00127 TPixelType * m_RawBuffer;
00128
00129 VTKImageModifiedEvent m_VtkImageLoadedEvent;
00130
00131 igstk::VideoImagerTool::Pointer m_VideoImagerTool;
00133 FrameType m_Frame;
00134
00135 unsigned int m_Width;
00136 unsigned int m_Height;
00137 double m_PixelSizeX;
00138 double m_PixelSizeY;
00139 RGBPixelType* m_RGBPixelContainer;
00140
00141 unsigned int m_NumberOfScalarComponents;
00142
00144 typedef itk::VTKImageExport< RGBImageType > ITKRGBExportFilterType;
00145 typedef typename ITKRGBExportFilterType::Pointer ITKRGBExportFilterPointer;
00146
00147 typedef itk::VTKImageExport< ImageType > ITKExportFilterType;
00148 typedef typename ITKExportFilterType::Pointer ITKExportFilterPointer;
00149
00150 typedef vtkImageImport VTKImportFilterType;
00151 typedef VTKImportFilterType* VTKImportFilterPointer;
00152
00154 ITKRGBExportFilterPointer m_ItkRGBExporter;
00155 ITKExportFilterPointer m_ItkExporter;
00156
00157 VTKImportFilterPointer m_VtkRGBImporter;
00158 VTKImportFilterPointer m_VtkImporter;
00159 };
00160
00161 }
00162
00163 #ifndef IGSTK_MANUAL_INSTANTIATION
00164 #include "igstkVideoFrameSpatialObject.txx"
00165 #endif
00166
00167 #endif // __igstkVideoFrameSpatialObject_h