00001 #if defined (_MSC_VER) && (_MSC_VER >= 1000) 00002 #pragma once 00003 #endif 00004 #ifndef _SENSE_AvgIntensity 00005 #define _SENSE_AvgIntensity 00006 00007 #include "itkImageRegionConstIterator.h" 00008 #include "Geometric.h" 00009 #include "itkImageFileWriter.h" 00010 #include "Sensor.h" 00011 namespace mial 00012 { 00013 00015 00027 template<class DataType, class TInputImage, int nDims> 00028 class Sense_AvgIntensity: public Sensor 00029 { 00030 //**************************************************** 00031 //Member variables 00032 //**************************************************** 00033 public: 00034 //Smartpointer 00035 typedef Sense_AvgIntensity Self; 00036 typedef itk::SmartPointer<Self> Pointer; 00037 typedef itk::SmartPointer<const Self> ConstPointer; 00038 typedef itk::WeakPointer<const Self> ConstWeakPointer; 00039 itkNewMacro(Self); 00040 00041 typedef TInputImage InputImageType; 00042 typedef typename InputImageType::ConstPointer InputImagePointer; 00043 00044 typedef itk::Image<DataType,nDims> OutputImageType; 00045 typedef typename OutputImageType::ConstPointer OutputImagePointer; 00046 00047 00048 struct sensorIn: public Sensor::sensorIn{ 00049 //Smartpointer 00050 typedef sensorIn Self; 00051 typedef itk::SmartPointer<Self> Pointer; 00052 typedef itk::SmartPointer<const Self> ConstPointer; 00053 typedef itk::WeakPointer<const Self> ConstWeakPointer; 00054 itkNewMacro(Self); 00055 00056 //Define all custom here 00057 InputImagePointer imageIn; 00058 typedef Geometric<DataType,nDims> GeometricType; 00059 typename GeometricType::Pointer geom; 00060 protected: 00061 sensorIn(){}; 00062 }; 00063 00064 struct sensorOut: public Sensor::sensorOut{ 00065 //Smartpointer 00066 typedef sensorOut Self; 00067 typedef itk::SmartPointer<Self> Pointer; 00068 typedef itk::SmartPointer<const Self> ConstPointer; 00069 typedef itk::WeakPointer<const Self> ConstWeakPointer; 00070 itkNewMacro(Self); 00071 00072 //Define all custom here 00073 DataType avgIntensity; 00074 protected: 00075 sensorOut(){}; 00076 }; 00077 00078 private: 00079 00080 typename sensorOut::Pointer sensorOutput; 00081 00082 00083 //**************************************************** 00084 //Member functions 00085 //**************************************************** 00086 public: 00087 00088 //Run the sensor 00089 virtual void run(typename Sensor::sensorIn * const i); 00090 00091 //Overide in derived class if custom sensor output desired 00092 //virtual Sensor::sensorOut::Pointer getOutput(){ return sensorOutput;}; 00093 00094 private: 00095 //write an image to file 00096 void writeImageToFile(OutputImagePointer img,char * name); 00097 00098 protected: 00099 Sense_AvgIntensity(); 00100 00101 }; 00102 } // end namespace mial 00103 #include "Sense_AvgIntensity.cxx" 00104 #endif