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 <vector> 00035 #include "simple_tools.h" 00036 #include "colordefs.h" 00037 #include "LevelSetFunction.h" 00038 #include "level_set.h" 00039 #include "cimg_dependent.h" 00040 00041 using namespace std; 00042 using namespace lsseg; 00043 00044 int main() 00045 { 00046 const int num_regs = 4; // number of regions 00047 const int num_fragments = 80; // number of disjoint fragments 00048 const int X = 200; // resolution of image 00049 const int Y = 200; // - '' - 00050 vector<LevelSetFunction> ls_vec(num_regs, LevelSetFunction(X,Y)); 00051 00052 random_scattered_voronoi(&ls_vec[0], num_regs, num_fragments); 00053 00054 for (int i = 0; i != num_regs; ++i) { 00055 display_image(ls_vec[i]); 00056 } 00057 00058 vector<const int*> colors; 00059 colors.push_back(RED); 00060 colors.push_back(GREEN); 00061 colors.push_back(BLUE); 00062 colors.push_back(YELLOW); 00063 colors.push_back(CYAN); 00064 colors.push_back(MAGENTA); 00065 colors.push_back(GREY); 00066 00067 Image<double> visu(X, Y, 1, 3); 00068 vector<const LevelSetFunction*> lsptr(num_regs); 00069 for (int i = 0; i < num_regs; lsptr[i] = &ls_vec[i++]); 00070 visualize_multisets(&lsptr[0], num_regs, visu, &colors[0]); 00071 display_image(visu); 00072 00073 return 1; 00074 }; 00075