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

FileConversion.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  */
00018 
00020 #include<ImLib3D/FileConversion.hpp>
00021 #include<ImLib3D/Transformation.hpp>
00022 
00023 void
00024 IP3D::ReadFromFileBruker(const string &fname,int imageNumber,Image3Dlinear<short int> &res)
00025 {
00026     typedef Image3Dlinear<short int> ImType;
00027     // this is a horrible hack that works for me...
00028     string prefix=fname+SPrintf("/%d",imageNumber)+"/pdata/1/";
00029     string info;
00030     Read(prefix+"d3proc",info,true);
00031     uint pos;
00032     pos=info.find("##$IM_SIX=")+10;
00033     printf("pos:%d\n",(int)pos);
00034     int six=LongInt(info.substr(pos,info.size()-pos));
00035     pos=info.find("##$IM_SIY=")+10;
00036     int siy=LongInt(info.substr(pos,info.size()-pos));
00037     pos=info.find("##$IM_SIZ=")+10;
00038     int siz=LongInt(info.substr(pos,info.size()-pos));
00039     printf("CReadFromFileBruker:: XZY: %d %d %d\n",six,siy,siz);
00040     int dataSize;
00041     ImType::value_type *data=(ImType::value_type *)Read(prefix+"2dseq",&dataSize,true);
00042     if(dataSize!=six*siy*siz*(int)sizeof(ImType::value_type))
00043     {ThrowError("CReadFromFileBruker: bad file size");}
00044     IP3D::ImageFromRawData(data,Size3D(six,siz,siy),"XZY",res,true);
00045     delete [] data;
00046     if(six==siy && six==siz)
00047     {// guess this is a 3D aquisition !! :-(
00048         IP3D::SwapAxes(res,"XZ",res);
00049         IP3D::SwapAxes(res,"YZ",res);
00050 //      CFlip    ::Apply(res,"Z" ,res);
00051     }
00052     else
00053     {
00054         // flip in y direction
00055         IP3D::Flip(res,"Y",res);
00056     }
00057 }

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