Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 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 #ifndef MLN_WORLD_INTER_PIXEL_DISPLAY_EDGE_HH 00027 # define MLN_WORLD_INTER_PIXEL_DISPLAY_EDGE_HH 00028 00033 00034 # include <mln/core/image/image2d.hh> 00035 # include <mln/core/image/dmorph/image_if.hh> 00036 # include <mln/data/fill.hh> 00037 # include <mln/world/inter_pixel/is_separator.hh> 00038 # include <mln/opt/at.hh> 00039 00040 namespace mln 00041 { 00042 00043 namespace world 00044 { 00045 00046 namespace inter_pixel 00047 { 00048 00060 template <typename I> 00061 inline 00062 I display_edge(const I& ima, mln_value(I) bg, unsigned zoom); 00063 00064 # ifndef MLN_INCLUDE_ONLY 00065 00066 00067 template <typename I> 00068 inline 00069 I display_edge(const I& ima, mln_value(I) bg, unsigned zoom) 00070 { 00071 box2d b = ima.bbox(); 00072 I output(make::box2d(((b.pmin()[0] + 1) / 2) * (zoom + 1), 00073 ((b.pmin()[1] + 1) / 2) * (zoom + 1), 00074 ((b.pmax()[0] + 1) / 2 + 1) * (zoom + 1) - 2, 00075 ((b.pmax()[1] + 1) / 2 + 1) * (zoom + 1) - 2)); 00076 data::fill(output, bg); 00077 typedef image_if<const I, is_separator> edge_t; 00078 edge_t edge = ima | is_separator(); 00079 mln_piter(edge_t) p(edge.domain()); 00080 for_all(p) 00081 if (p.row() % 2) // horizontal edge 00082 { 00083 unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1; 00084 unsigned col = (p.col() / 2) * (zoom + 1); 00085 for (unsigned i = 0; i < zoom; ++i) 00086 opt::at(output, row, col + i) = ima(p); 00087 } 00088 else // vertical edge 00089 { 00090 unsigned row = (p.row() / 2) * (zoom + 1); 00091 unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1; 00092 for (unsigned i = 0; i < zoom; ++i) 00093 opt::at(output, row + i, col) = ima(p); 00094 } 00095 return output; 00096 } 00097 00098 00099 # endif // ! MLN_INCLUDE_ONLY 00100 00101 } // end of namespace mln::world::inter_pixel 00102 00103 } // end of namespace mln::world 00104 00105 } // end of namespace mln 00106 00107 #endif // ! MLN_WORLD_INTER_PIXEL_DISPLAY_EDGE_HH