IGSTK
igstkVideoFrameSpatialObject.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Image Guided Surgery Software Toolkit
4  Module: $RCSfile: igstkVideoFrameSpatialObject.h,v $
5  Language: C++
6  Date: $Date: 2009-06-18 18:40:55 $
7  Version: $Revision: 1.1 $
8 
9  Copyright (c) ISC Insight Software Consortium. All rights reserved.
10  See IGSTKCopyright.txt or http://www.igstk.org/copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __igstkVideoFrameSpatialObject_h
18 #define __igstkVideoFrameSpatialObject_h
19 
20 #include "igstkMacros.h"
21 #include "igstkSpatialObject.h"
22 #include "igstkFrame.h"
23 #include "igstkTimeStamp.h"
24 #include "igstkVideoImagerTool.h"
25 
26 #include "itkVTKImageExport.h"
27 #include "itkImage.h"
28 #include "itkSize.h"
29 #include "itkImageRegion.h"
30 #include "itkIndex.h"
31 #include "itkImportImageFilter.h"
32 #include "itkRGBPixel.h"
33 
34 #include "vtkImageData.h"
35 #include "vtkImageImport.h"
36 
37 #define DIMENSION 2
38 
39 namespace igstk
40 {
41 
42 template < class TPixelType, unsigned int TChannels >
44 : public SpatialObject
45 {
46 
47 public:
51 
52  typedef itk::SpatialObject<3> VideoFrameSpatialObjectType;
53 
54  typedef typename itk::RGBPixel< TPixelType > RGBPixelType;
55  typedef typename itk::ImportImageFilter< RGBPixelType, DIMENSION >
57  typedef typename itk::Image< RGBPixelType , DIMENSION > RGBImageType;
58 
59  typedef TPixelType PixelType;
60  typedef typename itk::ImportImageFilter< PixelType, DIMENSION >
62  typedef typename itk::Image< PixelType , DIMENSION > ImageType;
63 
64  typedef Frame FrameType;
66 
67  itkStaticConstMacro( m_NumberOfChannels, unsigned int, TChannels );
68 
69  void Initialize();
70 
71  igstkLoadedTemplatedConstObjectEventMacro( ITKImageModifiedEvent,
72  IGSTKEvent, ImageType);
73 
74  igstkLoadedTemplatedConstObjectEventMacro( ITKRGBImageModifiedEvent,
75  IGSTKEvent, RGBImageType);
76 
78  virtual bool IsEmpty() const;
79 
80  vtkImageData* GetImageData();
81  TimeStamp::TimePeriodType GetFrameExpirationTime() const;
82  TimeStamp::TimePeriodType GetFrameStartTime() const;
83 
84  igstkSetMacro(Width, unsigned int);
85  igstkGetMacro(Width, unsigned int);
86 
87  igstkSetMacro(Height, unsigned int);
88  igstkGetMacro(Height, unsigned int);
89 
90  igstkSetMacro(NumberOfScalarComponents, unsigned int);
91  igstkGetMacro(NumberOfScalarComponents, unsigned int);
92 
93  //igstkGetMacro(NumberOfChannels, unsigned int);
94  const unsigned int GetNumberOfChannels() const;
95 
96  igstkSetMacro(PixelSizeX, double);
97  igstkGetMacro(PixelSizeX, double);
98 
99  igstkSetMacro(PixelSizeY, double);
100  igstkGetMacro(PixelSizeY, double);
101 
102  void RequestGetITKImage();
103  void RequestGetVTKImage()const;
105 
106 
107  void UpdateImages();
108  TPixelType* GetImagePtr();
109 
110 protected:
111  VideoFrameSpatialObject( void );
112  ~VideoFrameSpatialObject( void );
113 
114 private:
115 
116  typename RGBImageType::Pointer m_RGBImage;
117  typename RGBImportFilterType::Pointer m_RGBImportFilter;
118 
119  typename ImageType::Pointer m_Image;
120  typename ImportFilterType::Pointer m_ImportFilter;
121 
122  itk::Size<DIMENSION> m_Size;
123  itk::ImageRegion<DIMENSION> m_Region;
124  itk::Index<DIMENSION> m_Start;
125 
126  vtkImageData* m_VTKImage;
127  TPixelType * m_RawBuffer;
128 
129  VTKImageModifiedEvent m_VtkImageLoadedEvent;
130 
131  igstk::VideoImagerTool::Pointer m_VideoImagerTool;
133  FrameType m_Frame;
134 
135  unsigned int m_Width;
136  unsigned int m_Height;
137  double m_PixelSizeX;
138  double m_PixelSizeY;
139  RGBPixelType* m_RGBPixelContainer;
140 
141  unsigned int m_NumberOfScalarComponents;
142 
144  typedef itk::VTKImageExport< RGBImageType > ITKRGBExportFilterType;
145  typedef typename ITKRGBExportFilterType::Pointer ITKRGBExportFilterPointer;
146 
147  typedef itk::VTKImageExport< ImageType > ITKExportFilterType;
148  typedef typename ITKExportFilterType::Pointer ITKExportFilterPointer;
149 
150  typedef vtkImageImport VTKImportFilterType;
151  typedef VTKImportFilterType* VTKImportFilterPointer;
152 
154  ITKRGBExportFilterPointer m_ItkRGBExporter;
155  ITKExportFilterPointer m_ItkExporter;
156 
157  VTKImportFilterPointer m_VtkRGBImporter;
158  VTKImportFilterPointer m_VtkImporter;
159 };
160 
161 } // end namespace igstk
162 
163 #ifndef IGSTK_MANUAL_INSTANTIATION
164 #include "igstkVideoFrameSpatialObject.txx"
165 #endif
166 
167 #endif // __igstkVideoFrameSpatialObject_h
TimeStamp::TimePeriodType GetFrameStartTime() const
TimeStamp provides periods of validity for data.
#define igstkGetMacro(name, type)
Get built-in type.
Definition: igstkMacros.h:105
#define igstkStandardTemplatedClassTraitsMacro(classname, superclassname)
Convenience macro for the traits of a templated class.
Definition: igstkMacros.h:286
TimeStamp::TimePeriodType GetFrameExpirationTime() const
Geometrical abstraction of physical objects present in the surgical scene.
virtual bool IsEmpty() const
Returns wheter the image has any pixels allocated or not.
itk::Image< RGBPixelType, DIMENSION > RGBImageType
itkStaticConstMacro(m_NumberOfChannels, unsigned int, TChannels)
defines standard system-wide macros, constants, and other common parameters in the IGSTK Library...
::itk::SmartPointer< Self > Pointer
Definition: igstkObject.h:50
itk::ImportImageFilter< RGBPixelType, DIMENSION > RGBImportFilterType
const unsigned int GetNumberOfChannels() const
itk::Image< PixelType, DIMENSION > ImageType
Abstract superclass for concrete IGSTK VideoImagerTool classes.
#define DIMENSION
#define igstkSetMacro(name, type)
Set built-in type.
Definition: igstkMacros.h:93
igstkStandardTemplatedClassTraitsMacro(VideoFrameSpatialObject, SpatialObject) typedef itk typedef itk::RGBPixel< TPixelType > RGBPixelType
Macro with standard traits declarations.
igstkLoadedTemplatedConstObjectEventMacro(ITKImageModifiedEvent, IGSTKEvent, ImageType)
Frame from an external input device.
Definition: igstkFrame.h:49
void SetVideoImagerTool(igstk::VideoImagerTool::Pointer)
itk::ImportImageFilter< PixelType, DIMENSION > ImportFilterType