00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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 {
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
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