00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00019
00020 #ifndef _Image3Dlinear_hxx
00021 #define _Image3Dlinear_hxx
00022
00023 #include<ImLib3D/Interpolator3D.hpp>
00024
00025
00026
00027
00028 template<class Im3DValue>
00029 Image3Dlinear<Im3DValue>::~Image3Dlinear()
00030 {
00031 if(destroyInterpolator && interpolator){delete interpolator;}
00032 this->DeAllocate();
00033 }
00034
00035
00036 template<class Im3DValue>
00037 Im3DValue Image3Dlinear<Im3DValue>::SafeValue(int pos) const
00038 {
00039 if ((pos < 0) || (pos >= this->GetNVoxels()))
00040 return zero;
00041 else return (*this)(pos);
00042 }
00043
00044 template<class Im3DValue>
00045 void
00046 Image3Dlinear<Im3DValue>::ComplexImag(Image3Df &imag) const
00047 {
00048 imag.Resize(this->Size());
00049
00050 typename _Self::const_iteratorFast p;
00051 Image3Df::iteratorFast pImag;
00052 for (p = this->begin(),pImag=imag.begin(); p != this->end(); p++,pImag++)
00053 {
00054 *pImag=(*p).imag();
00055 }
00056 }
00057 template<class Im3DValue>
00058 void
00059 Image3Dlinear<Im3DValue>::ComplexReal(Image3Df &imag) const
00060 {
00061 imag.Resize(this->Size());
00062
00063 typename _Self::const_iteratorFast p;
00064 Image3Df::iteratorFast pImag;
00065 for (p = this->begin(),pImag=imag.begin(); p != this->end(); p++,pImag++)
00066 {
00067 *pImag=(*p).real();
00068 }
00069 }
00070 template<class Im3DValue>
00071 void
00072 Image3Dlinear<Im3DValue>::ComplexNorm2(Image3Df &imag) const
00073 {
00074 imag.Resize(this->Size());
00075
00076 typename _Self::const_iteratorFast p;
00077 Image3Df::iteratorFast pImag;
00078 for (p = this->begin(),pImag=imag.begin(); p != this->end(); p++,pImag++)
00079 {
00080 *pImag=norm(*p);
00081 }
00082 }
00083 template<class Im3DValue>
00084 void
00085 Image3Dlinear<Im3DValue>::ComplexModule(Image3Df &imag) const
00086 {
00087 imag.Resize(this->Size());
00088
00089 typename _Self::const_iteratorFast p;
00090 Image3Df::iteratorFast pImag;
00091 for (p = this->begin(),pImag=imag.begin(); p != this->end(); p++,pImag++)
00092 {
00093 *pImag=sqrt(norm(*p));
00094 }
00095 }
00096
00098 template<class Im3DValue>
00099 double
00100 Image3Dlinear<Im3DValue>::L2Norm() const
00101 {
00102 double energie = 0;
00103 typename _Self::const_iteratorFastMasked p;
00104 for (p=this->begin(); p!=this->end(); p++)
00105 {
00106 energie += (*p)*(*p);
00107 }
00108 return sqrt(energie);
00109 }
00110
00111 template<class Im3DValue>
00112 void
00113 Image3Dlinear<Im3DValue>::GetComponent(int c,Image3Df &res) const
00114 {
00115 res.Resize(this->Size());
00116 typename _Self::const_iteratorFast p;
00117 Image3Df::iteratorFast rp;
00118 for(p=this->begin(),rp=res.begin();p!=this->end(); p++,rp++)
00119 {
00120 *rp=(*p)(c);
00121 }
00122 }
00123 template<class Im3DValue>
00124 void
00125 Image3Dlinear<Im3DValue>::SetComponent(int c,const Image3Df &src)
00126 {
00127 src.Resize(this->Size());
00128 typename _Self::iteratorFast p;
00129 Image3Df::const_iteratorFast rp;
00130 for(p=this->begin(),rp=src.begin();p!=this->end(); p++,rp++)
00131 {
00132 (*p)(c)=*rp;
00133 }
00134 }
00135
00136 #endif // _Image3Dlinear_hxx