00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
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 }