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

Image3Dlinear.cpp

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  */
00020 #include<ImLib3D/Image3Dlinear.hpp>
00021 #include<ImLib3D/FileConversion.hpp>
00022 #include<ImLib3D/TemplateGroups.hpp>
00023 #include<ImLib3D/SparseImage3D.hpp>
00024 
00025 
00026 template<class ImageType>
00027 void ReadFromFileAsImage3Df(const string &filename,Image3Df &res)
00028 {
00029     ImageType ima(filename);
00030     res=ima;
00031 }
00032 
00033 template<>
00034 void 
00035 Image3Df::ReadWithImageTypeConversion(const string &fname0)
00036 {
00037     printf("ReadWithImageTypeConversion\n");
00038     string fname=fname0;
00039 #ifdef NOTDEF //FIXME
00040     if(!FileExists(fname) && FileExists(fname+".hdr") && FileExists(fname+".img"))
00041     {// this seems to be an avw image
00042         printf("ReadWithImageTypeConversion::avw detected\n");
00043         string tmp=WriteTmpFile("empty");
00044         IP3D::ReadFromFileAVWNT(Strings("CReadFromFileAVW",fname,tmp));
00045         fname=tmp;
00046     }
00047 #endif// NOTDEF
00048     printf("ReadWithImageTypeConversion:: fname:%s\n",fname.c_str());
00049     string type=Container3D_ReadImageType(fname);
00050     if(type=="NOT IMLIB3D IMAGE"){ThrowError("ReadWithImageTypeConversion:: \"%s\" is not a valid image",fname);}
00051     CallWithImage3DFloatCastable_2(ReadFromFileAsImage3Df,type,fname,(*this));
00052     if(fname!=fname0){RemoveFile(fname);}
00053 }
00054 
00055 
00056 
00057 #ifdef NOTDEF
00058 #include<ImLib3D/Image3Dlinear.hpp>
00059 #include<ImLib3D/FileConversion.hpp>
00060 #include<ImLib3D/TemplateGroups.hpp>
00061 #include<ImLib3D/SparseImage3D.hpp>
00062 
00063 // *******************************************************
00064 // ********************** Mask3D **** ********************
00065 // *******************************************************
00066 
00067 
00069 void Mask3D::Invert()
00070 {
00071     Mask3D::iteratorFast p;
00072     for (p=begin(); p!=end(); p++)
00073     {
00074         if (!(*p)) { (*p) = 1;}
00075         else       { (*p) = 0;}
00076     }
00077 }
00078 
00079 
00080 
00082 void 
00083 Mask3D::Normalize()
00084 {
00085     Mask3D::iteratorFast p;
00086     for (p=begin(); p!=end(); p++)
00087     {
00088         if (*p){(*p) = 1;}
00089     }
00090 }
00091 
00093 void 
00094 Mask3D::Select(byte v)
00095 {
00096     Mask3D::iteratorFast p;
00097     for (p=begin(); p!=end(); p++)
00098     {
00099         if (*p==v){(*p) = 1;}else{*p=0;}
00100     }
00101 }
00102 
00103 
00104 
00105 
00106 
00107 #endif //NOTDEF

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