00001 #ifndef _Sense_ProjectiveSpherical_CXX
00002 #define _Sense_ProjectiveSpherical_CXX
00003
00004 #include "Sense_ProjectiveSpherical.h"
00005 #define PI 3.141592654
00006
00007 namespace mial
00008 {
00009
00010 template<class DataType, class TInputImage, class TGradientImage, int nDims>
00011 Sense_ProjectiveSpherical<DataType,TInputImage,TGradientImage,nDims>
00012 ::Sense_ProjectiveSpherical()
00013 : Sensor()
00014 {
00015
00016 }
00017
00018 template<class DataType, class TInputImage, class TGradientImage, int nDims>
00019 void
00020 Sense_ProjectiveSpherical<DataType,TInputImage,TGradientImage,nDims>
00021 ::writeImageToFile(OutputImagePointer img,char * name)
00022 {
00023 typedef typename itk::ImageFileWriter<OutputImageType> WriterType;
00024 WriterType::Pointer writer = WriterType::New();
00025 writer->SetFileName(name);
00026 writer->SetInput(img);
00027 writer->Update();
00028 }
00029
00030 template<class DataType, class TInputImage, class TGradientImage, int nDims>
00031 void
00032 Sense_ProjectiveSpherical<DataType, TInputImage, TGradientImage, nDims>
00033 ::run(void * i)
00034 {
00035
00036 sensorIn in = *(reinterpret_cast<sensorIn *>(i));
00037
00038
00039 int N = ceil(sqrt(1000));
00040 DataType theta =0;
00041 DataType phi =0;
00042 MatrixType points(1000,3);
00043 VectorType pnt(3);
00044 MatrixType M(3,3);
00045 VectorType trans(3);
00046
00047 int cnt =0;
00048 for(int i=0; i < N; i++)
00049 {
00050 theta = -PI+2*i/(N-1)*PI;
00051 for(int j=0; j < N; j++)
00052 {
00053 phi = (j/(N-1))*(PI/2);
00054 pnt(1) = cos(phi)*cos(theta);
00055 pnt(2) = cos(phi)*sin(theta);
00056 pnt(3) = sin(phi);
00057 points.set_row(cnt) = M*pnt + trans;
00058 cnt++;
00059 }
00060 }
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070 this->sensorOutput.imageOut = gradientFilter->GetOutput();
00071
00072 gradientFilter->Update();
00073 }
00074 }
00075 #endif