/home/oan/prosjekt/gotools/segmentation/gpl_distro/lsseg_1.0_gpl/app/filter2DTests.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 <time.h>
00035 #include <iostream>
00036 #include "Image.h"
00037 #include "Filters.h"
00038 #include "cimg_dependent.h"
00039 
00040 
00041 using namespace lsseg;
00042 using namespace std;
00043 
00044 //const char filename[] = "data/zebra.jpg";
00045 
00046 int main(int varnum, char** vararg)
00047 {
00048     if (varnum < 2) {
00049         cerr << endl;
00050         cerr << "This program takes an image as input, converts it to greycsale,  and computes " << endl;
00051         cerr << "and displays the following derived images : " << endl;
00052         cerr << "1) The structure tensor, with its 3 different components " << endl;
00053         cerr << "2) The image smoothed with the total variation diminishing scheme " << endl;
00054         cerr << "3) The scale measure (gives an idea about the magnitude of the structures " << endl;
00055         cerr << "   to which each pixel belongs" << endl;
00056         cerr << endl;
00057         cerr << "Push spacebar to go from one visualization to the next. " << endl;
00058         cerr << endl;
00059         cerr << "Usage: filter2DTests <filename> " << endl;
00060         cerr << endl;
00061         return -1;
00062     }
00063 
00064 
00065     const char* filename = vararg[1];
00066 
00067     Image<double> img;
00068     load_image(filename, img, true); // to grey
00069     display_image(img);
00070 
00071     // ---- TEST OF STRUCTURE TENSOR ---- 
00072 
00073     Image<double> G;
00074     cout << "Entering compute_structure_tensor_2D" << endl;
00075     clock_t start = clock();
00076     compute_structure_tensor_2D(img, G);
00077     clock_t end = clock();
00078     cout << "Exited from compute_structure_tensor_2D" << endl;
00079     cout << "Computation took: " << (end - start) / double(1000) << " ms." << endl;
00080 
00081     cout << "Displaying all three channels: " << endl;
00082     display_image(G);
00083 
00084     Image<double> G_ch;
00085     for (int ch = 0; ch < G.numChannels(); ++ch) {
00086         G.makeChannelImage(G_ch, ch);
00087         cout << "Displaying separate channel: " << ch << endl;
00088         display_image(G_ch);
00089     }
00090 
00091     // ---- TEST OF ANISOTROPIC SMOOTHING ---- 
00092     const double dt = 1;
00093     const double T = 20;
00094 
00095     Image<double> NGF(img);
00096     Image<double> NGF2(img, false);
00097     for (double t = 0; t < T; t+= dt) {
00098         cout << t << endl;
00099         nonlinear_gauss_filter_2D(NGF, NGF2, dt, 0, 1);
00100         NGF2.swap(NGF);
00101     }
00102     cout << "Displaying total variation image: " << endl;
00103     display_image(NGF);
00104                        
00105     // ---- TEST OF SCALE MEASURE ---- 
00106     
00107     Image<double> S, Tacc;
00108     compute_scale_factor_2D(img, S, Tacc, dt, T);
00109     cout << "Displaying scale image: " << endl;
00110     display_image(S);
00111 
00112 
00113 
00114 };
00115 

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