Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

Image3Dlinear.hxx

Go to the documentation of this file.
00001 /* ImLib3D
00002  * Copyright (c) 2001, ULP-IPB Strasbourg.
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or (at
00007  * your option) any later version.
00008  * 
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017  */
00019 
00020 #ifndef _Image3Dlinear_hxx
00021 #define _Image3Dlinear_hxx
00022 
00023 #include<ImLib3D/Interpolator3D.hpp>
00024 
00025 // *******************************************************
00026 // ********************** Image3Dlinear ********************
00027 // *******************************************************
00028 template<class Im3DValue>
00029 Image3Dlinear<Im3DValue>::~Image3Dlinear()
00030 {
00031     if(destroyInterpolator && interpolator){delete interpolator;}
00032     this->DeAllocate(); 
00033 }
00034 
00035 // *************************** Accessors ******* ***********
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

Generated on Fri Jun 17 13:36:04 2005 for ImLib3D by  doxygen 1.4.2