/home/oan/prosjekt/gotools/segmentation/gpl_distro/lsseg_1.0_gpl/app/tvfilter.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 <iostream>
00035 #include "cimg_dependent.h"
00036 #include "Filters.h"
00037 
00038 using namespace std;
00039 using namespace lsseg;
00040 
00041 int main(int varnum, char** vararg)
00042 {
00043     if (varnum < 4) {
00044         cerr << "This program will display the process of TV-flow (total-varaion-diminishing flow)" << endl;
00045         cerr << "on an image." << endl;
00046         cerr << endl;
00047         cerr << "Usage: tvfilter <filename> <dt> <num timesteps> [savefile]" << endl;
00048         cerr << "Suggestion:try dt = 1 and num_timesteps = 20" << endl;
00049         cerr << endl;
00050         return -1;
00051     }
00052 
00053     Image<double> img;
00054     load_image(vararg[1], img, false);
00055 
00056     permanent_display(img);
00057 
00058     Image<double> res;
00059     
00060     double dt = atof(vararg[2]);
00061     int iter = atoi(vararg[3]);
00062     
00063     const char* save = (varnum > 4) ? vararg[4] : 0;
00064 
00065     UpdatableImage uimg(img, "development");
00066 
00067     for (int i = 0; i < iter; ++i) {
00068         anisotropic_smoothing(img, res, dt, 0, 1);
00069         uimg.update(res);
00070         img = res;
00071         cout << i << endl;
00072     }
00073 
00074     display_image(res);
00075     if (save) {
00076         cout << "Now saving result." << endl;
00077         save_image(save, res);
00078     }
00079     return 1;
00080 };
00081 

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