/home/oan/prosjekt/gotools/segmentation/gpl_distro/lsseg_1.0_gpl/app/generate_stack.C

Go to the documentation of this file.
00001 //===========================================================================
00002 // The Level-Set Segmentation Library (LSSEG)
00003 //
00004 //
00005 // Copyright (C) 2000-2005 SINTEF ICT, Applied Mathematics, Norway.
00006 //
00007 // This program is free software; you can redistribute it and/or          
00008 // modify it under the terms of the GNU General Public License            
00009 // as published by the Free Software Foundation version 2 of the License. 
00010 //
00011 // This program is distributed in the hope that it will be useful,        
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of         
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          
00014 // GNU General Public License for more details.                           
00015 //
00016 // You should have received a copy of the GNU General Public License      
00017 // along with this program; if not, write to the Free Software            
00018 // Foundation, Inc.,                                                      
00019 // 59 Temple Place - Suite 330,                                           
00020 // Boston, MA  02111-1307, USA.                                           
00021 //
00022 // Contact information: e-mail: tor.dokken@sintef.no                      
00023 // SINTEF ICT, Department of Applied Mathematics,                         
00024 // P.O. Box 124 Blindern,                                                 
00025 // 0314 Oslo, Norway.                                                     
00026 // 
00027 //
00028 // Other licenses are also available for this software, notably licenses
00029 // for:
00030 // - Building commercial software.                                        
00031 // - Building software whose source code you wish to keep private.        
00032 //
00033 //===========================================================================
00034 #include "Image.h"
00035 #include "level_set.h"
00036 #include "simple_tools.h"
00037 #include <string>
00038 #include <iostream>
00039 #include <fstream>
00040 
00041 using namespace std;
00042 using namespace lsseg;
00043 
00044 int main(int varnum, char** vararg) 
00045 {
00046     if (varnum < 2) {
00047         cerr << endl << "usage: volumesmoothing_test <filelist_name> [savefile]" << endl << endl;
00048         cerr << "The first argument (filelist_name) should be an ASCII file containing the name " << endl;
00049         cerr << "of one image file per line.  All the images mentioned are supposed to have the " << endl;
00050         cerr << "same x and y resolution and number of channels.  The fileformats are directly " << endl;
00051         cerr << "specified by the file suffixes (jpeg, png, etc.)" << endl << endl;
00052         cerr << "The saved file will contain a 3D image where the original images are stacked along" << endl;
00053         cerr << "the z coordinate.  This file can be read into an lsseg::Image object by using its" << endl;
00054         cerr << "read() member function.  The saved file should conventionally have the suffix .stack ." << endl;
00055         cerr << endl;
00056         return -1;
00057     }
00058     string savefile;
00059     if (varnum > 2) {
00060         savefile = string(vararg[2]);
00061     }
00062 
00063     string filelist_name(vararg[1]);
00064     ifstream is(filelist_name.c_str());
00065     if (!is) {
00066         cerr << "Unable to open file: " << filelist_name << endl;
00067         return -1;
00068     }
00069 
00070     Image<double> I;
00071     read_image_sequence(is, I, true);
00072 
00073     cout << "Image dimensions are: ";
00074     cout << I.dimx() << " " << I.dimy() << " " << I.dimz() << endl;
00075     cout << "Number of channels: " << I.numChannels() << endl;
00076 
00077     if (savefile.size() > 0) {
00078         ofstream os(savefile.c_str());
00079         I.write(os, true);
00080         os.close();
00081     }
00082 
00083     return 0;
00084 }

Generated on Tue Nov 28 18:35:47 2006 for lsseg by  doxygen 1.4.7