Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE) 00002 // 00003 // This file is part of Olena. 00004 // 00005 // Olena is free software: you can redistribute it and/or modify it under 00006 // the terms of the GNU General Public License as published by the Free 00007 // Software Foundation, version 2 of the License. 00008 // 00009 // Olena is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Olena. If not, see <http://www.gnu.org/licenses/>. 00016 // 00017 // As a special exception, you may use this file as part of a free 00018 // software project without restriction. Specifically, if other files 00019 // instantiate templates or use macros or inline functions from this 00020 // file, or you compile this file and link it with other files to produce 00021 // an executable, this file does not by itself cause the resulting 00022 // executable to be covered by the GNU General Public License. This 00023 // exception does not however invalidate any other reasons why the 00024 // executable file might be covered by the GNU General Public License. 00025 00026 #include <mln/core/image/image2d.hh> 00027 #include <mln/core/image/dmorph/sub_image.hh> 00028 00029 00030 #include <mln/data/fill.hh> 00031 #include <mln/debug/println.hh> 00032 #include <mln/core/alias/w_window2d_int.hh> 00033 #include <mln/core/alias/w_window2d_float.hh> 00034 00035 #include <mln/make/win_chamfer.hh> 00036 #include <mln/geom/chamfer.hh> 00037 #include <mln/data/compare.hh> 00038 00039 #include <mln/opt/at.hh> 00040 00041 00042 int main() 00043 { 00044 using namespace mln; 00045 unsigned max = 51; 00046 00047 image2d<bool> ima(9, 9); 00048 00049 { 00050 data::fill(ima, false); 00051 opt::at(ima, 4,4) = true; 00052 const w_window2d_int& w_win = make::mk_chamfer_3x3_int<2, 0> (); 00053 image2d<unsigned> out = geom::chamfer(ima, w_win, max); 00054 unsigned r[9][9] = 00055 { 00056 {16, 14, 12, 10, 8, 10, 12, 14, 16}, 00057 {14, 12, 10, 8, 6, 8, 10, 12, 14}, 00058 {12, 10, 8, 6, 4, 6, 8, 10, 12}, 00059 {10, 8, 6, 4, 2, 4, 6, 8, 10}, 00060 { 8, 6, 4, 2, 0, 2, 4, 6, 8}, 00061 {10, 8, 6, 4, 2, 4, 6, 8, 10}, 00062 {12, 10, 8, 6, 4, 6, 8, 10, 12}, 00063 {14, 12, 10, 8, 6, 8, 10, 12, 14}, 00064 {16, 14, 12, 10, 8, 10, 12, 14, 16} 00065 }; 00066 00067 image2d<unsigned> ref (make::image(r)); 00068 mln_assertion (out == ref); 00069 } 00070 00071 { 00072 data::fill(ima, false); 00073 opt::at(ima, 4,4) = true; 00074 const w_window2d_int& w_win = make::mk_chamfer_3x3_int<2, 3> (); 00075 image2d<unsigned> out = geom::chamfer(ima, w_win, max); 00076 00077 unsigned r[9][9] = 00078 { 00079 {12, 11, 10, 9, 8, 9, 10, 11, 12}, 00080 {11, 9, 8, 7, 6, 7, 8, 9, 11}, 00081 {10, 8, 6, 5, 4, 5, 6, 8, 10}, 00082 { 9, 7, 5, 3, 2, 3, 5, 7, 9}, 00083 { 8, 6, 4, 2, 0, 2, 4, 6, 8}, 00084 { 9, 7, 5, 3, 2, 3, 5, 7, 9}, 00085 {10, 8, 6, 5, 4, 5, 6, 8, 10}, 00086 {11, 9, 8, 7, 6, 7, 8, 9, 11}, 00087 {12, 11, 10, 9, 8, 9, 10, 11, 12} 00088 }; 00089 00090 image2d<unsigned> ref (make::image(r)); 00091 mln_assertion (out == ref); 00092 } 00093 00094 { 00095 data::fill(ima, false); 00096 opt::at(ima, 4,4) = true; 00097 const w_window2d_int& w_win = make::mk_chamfer_5x5_int<4, 6, 9> (); 00098 image2d<unsigned> out = geom::chamfer(ima, w_win, max); 00099 image2d<unsigned>::fwd_piter p(out.domain()); 00100 for_all(p) 00101 out(p) = out(p) / 2; 00102 00103 unsigned r[9][9] = 00104 { 00105 {12, 10, 9, 8, 8, 8, 9, 10, 12}, 00106 {10, 9, 7, 6, 6, 6, 7, 9, 10}, 00107 { 9, 7, 6, 4, 4, 4, 6, 7, 9}, 00108 { 8, 6, 4, 3, 2, 3, 4, 6, 8}, 00109 { 8, 6, 4, 2, 0, 2, 4, 6, 8}, 00110 { 8, 6, 4, 3, 2, 3, 4, 6, 8}, 00111 { 9, 7, 6, 4, 4, 4, 6, 7, 9}, 00112 {10, 9, 7, 6, 6, 6, 7, 9, 10}, 00113 {12, 10, 9, 8, 8, 8, 9, 10, 12} 00114 }; 00115 00116 image2d<unsigned> ref (make::image(r)); 00117 mln_assertion (out == ref); 00118 00119 } 00120 00121 }