milena r3729: Add dim2/ funtion objects and display_edge(), untested

URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena ChangeLog: 2009-04-29 Fabien Freling <fabien.freling@lrde.epita.fr> Add dim2/ funtion objects and display_edge(), untested. * mln/world/inter_pixel/dim2/all.hh: New file including all directory. * mln/world/inter_pixel/dim2/is_dot.hh: New function to test dot. * mln/world/inter_pixel/dim2/is_edge.hh: New function to test edge. * mln/world/inter_pixel/dim2/is_pixel.hh: New function to test pixel. * mln/world/inter_pixel/dim2/is_row_odd.hh: New function to test row. * mln/world/inter_pixel/display_edge.hh: Display edges in an image. --- dim2/all.hh | 43 ++++++++++++++++++++++++++ dim2/is_dot.hh | 76 +++++++++++++++++++++++++++++++++++++++++++++++ dim2/is_edge.hh | 76 +++++++++++++++++++++++++++++++++++++++++++++++ dim2/is_pixel.hh | 76 +++++++++++++++++++++++++++++++++++++++++++++++ dim2/is_row_odd.hh | 76 +++++++++++++++++++++++++++++++++++++++++++++++ display_edge.hh | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 432 insertions(+) Index: trunk/milena/mln/world/inter_pixel/display_edge.hh =================================================================== --- trunk/milena/mln/world/inter_pixel/display_edge.hh (revision 0) +++ trunk/milena/mln/world/inter_pixel/display_edge.hh (revision 3729) @@ -0,0 +1,85 @@ +// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_WORLD_INTER_PIXEL_DISPLAY_EDGE_HH +# define MLN_WORLD_INTER_PIXEL_DISPLAY_EDGE_HH + +/// \file mln/world/inter_pixel/display_edge.hh +/// +/// FIXME: insert comment. + +# include <mln/core/image/image2d.hh> +# include <mln/core/image/image_if.hh> +# include <mln/data/fill.hh> +# include <mln/world/inter_pixel/dim2/is_edge.hh> +# include <mln/opt/at.hh> + +namespace mln +{ + + namespace world + { + + namespace inter_pixel + { + + template <typename I> + I display_edge(const I& ima, mln_value(I) bg, unsigned zoom) + { + unsigned nrows = ima.nrows() / 2 + 1; + unsigned ncols = ima.ncols() / 2 + 1; + I output(nrows * (zoom + 1) - 1, + ncols * (zoom + 1) - 1); + data::fill(output, bg); + typedef image_if<const I, dim2::is_edge> edge_t; + edge_t edge = ima | dim2::is_edge(); + mln_piter(edge_t) p(edge.domain()); + for_all(p) + if (p.row() % 2) // horizontal edge + { + unsigned row = (p.row() / 2 + 1) * (zoom + 1) - 1; + unsigned col = (p.col() / 2) * (zoom + 1); + for (unsigned i = 0; i < zoom; ++i) + opt::at(output, row, col + i) = ima(p); + } + else // vertical edge + { + unsigned row = (p.row() / 2) * (zoom + 1); + unsigned col = (p.col() / 2 + 1) * (zoom + 1) - 1; + for (unsigned i = 0; i < zoom; ++i) + opt::at(output, row + i, col) = ima(p); + } + return output; + } + + } // end of namespace mln::world::inter_pixel + + } // end of namespace mln::world + +} // end of namespace mln + +#endif // ! MLN_WORLD_INTER_PIXEL_DISPLAY_EDGE Index: trunk/milena/mln/world/inter_pixel/dim2/is_dot.hh =================================================================== --- trunk/milena/mln/world/inter_pixel/dim2/is_dot.hh (revision 0) +++ trunk/milena/mln/world/inter_pixel/dim2/is_dot.hh (revision 3729) @@ -0,0 +1,76 @@ +// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_WORLD_INTER_PIXEL_DIM2_IS_DOT_HH +# define MLN_WORLD_INTER_PIXEL_DIM2_IS_DOT_HH + +/// \file mln/world/inter_pixel/dim2d/is_dot.hh +/// +/// FIXME: insert comment. + +# include <mln/core/alias/point2d.hh> + +namespace mln +{ + + namespace world + { + + namespace inter_pixel + { + + namespace dim2 + { + + struct is_dot : public Function_p2b< is_dot > + { + typedef bool result; + bool operator()(const point2d& p) const; + }; + + +# ifndef MLN_INCLUDE_ONLY + + inline + bool + is_dot::operator()(const point2d& p) const + { + return p.row() % 2 && p.col() % 2; + } + +# endif // ! MLN_INCLUDE_ONLY + + + } // end of namespace mln::world::inter_pixel::dim2 + + } // end of namespace mln::world::inter_pixel + + } // end of namespace mln::world + +} // end of namespace mln + +#endif // ! MLN_WORLD_INTER_PIXEL_DIM2_IS_DOT_HH Index: trunk/milena/mln/world/inter_pixel/dim2/all.hh =================================================================== --- trunk/milena/mln/world/inter_pixel/dim2/all.hh (revision 0) +++ trunk/milena/mln/world/inter_pixel/dim2/all.hh (revision 3729) @@ -0,0 +1,43 @@ +// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_WORLD_INTER_PIXEL_DIM2_ALL_HH +# define MLN_WORLD_INTER_PIXEL_DIM2_ALL_HH + +/// \file mln/world/inter_pixel/dim2/all.hh +/// +/// File that includes all the dim2 routines. + + +// Local directory. +# include <mln/world/inter_pixel/dim2/is_dot.hh> +# include <mln/world/inter_pixel/dim2/is_edge.hh> +# include <mln/world/inter_pixel/dim2/is_pixel.hh> +# include <mln/world/inter_pixel/dim2/is_row_odd.hh> + + +#endif // ! MLN_WORLD_INTER_PIXEL_DIM2_ALL_HH Index: trunk/milena/mln/world/inter_pixel/dim2/is_row_odd.hh =================================================================== --- trunk/milena/mln/world/inter_pixel/dim2/is_row_odd.hh (revision 0) +++ trunk/milena/mln/world/inter_pixel/dim2/is_row_odd.hh (revision 3729) @@ -0,0 +1,76 @@ +// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_WORLD_INTER_PIXEL_DIM2_IS_ROW_ODD_HH +# define MLN_WORLD_INTER_PIXEL_DIM2_IS_ROW_ODD_HH + +/// \file mln/world/inter_pixel/dim2d/is_row_odd.hh +/// +/// FIXME: insert comment. + +# include <mln/core/alias/point2d.hh> + +namespace mln +{ + + namespace world + { + + namespace inter_pixel + { + + namespace dim2 + { + + struct is_row_odd : public Function_p2b< is_row_odd > + { + typedef bool result; + bool operator()(const point2d& p) const; + }; + + +# ifndef MLN_INCLUDE_ONLY + + inline + bool + is_row_odd::operator()(const point2d& p) const + { + return p.row() % 2; + } + +# endif // ! MLN_INCLUDE_ONLY + + + } // end of namespace mln::world::inter_pixel::dim2 + + } // end of namespace mln::world::inter_pixel + + } // end of namespace mln::world + +} // end of namespace mln + +#endif // ! MLN_WORLD_INTER_PIXEL_DIM2_IS_ROW_ODD_HH Index: trunk/milena/mln/world/inter_pixel/dim2/is_pixel.hh =================================================================== --- trunk/milena/mln/world/inter_pixel/dim2/is_pixel.hh (revision 0) +++ trunk/milena/mln/world/inter_pixel/dim2/is_pixel.hh (revision 3729) @@ -0,0 +1,76 @@ +// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_WORLD_INTER_PIXEL_DIM2_IS_PIXEL_HH +# define MLN_WORLD_INTER_PIXEL_DIM2_IS_PIXEL_HH + +/// \file mln/world/inter_pixel/dim2d/is_pixel.hh +/// +/// FIXME: insert comment. + +# include <mln/core/alias/point2d.hh> + +namespace mln +{ + + namespace world + { + + namespace inter_pixel + { + + namespace dim2 + { + + struct is_pixel : public Function_p2b< is_pixel > + { + typedef bool result; + bool operator()(const point2d& p) const; + }; + + +# ifndef MLN_INCLUDE_ONLY + + inline + bool + is_pixel::operator()(const point2d& p) const + { + return p.row() % 2 == 0 && p.col() % 2 == 0; + } + +# endif // ! MLN_INCLUDE_ONLY + + + } // end of namespace mln::world::inter_pixel::dim2 + + } // end of namespace mln::world::inter_pixel + + } // end of namespace mln::world + +} // end of namespace mln + +#endif // ! MLN_WORLD_INTER_PIXEL_DIM2_IS_PIXEL_HH Index: trunk/milena/mln/world/inter_pixel/dim2/is_edge.hh =================================================================== --- trunk/milena/mln/world/inter_pixel/dim2/is_edge.hh (revision 0) +++ trunk/milena/mln/world/inter_pixel/dim2/is_edge.hh (revision 3729) @@ -0,0 +1,76 @@ +// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_WORLD_INTER_PIXEL_DIM2_IS_EDGE_HH +# define MLN_WORLD_INTER_PIXEL_DIM2_IS_EDGE_HH + +/// \file mln/world/inter_pixel/dim2d/is_edge.hh +/// +/// FIXME: insert comment. + +# include <mln/core/alias/point2d.hh> + +namespace mln +{ + + namespace world + { + + namespace inter_pixel + { + + namespace dim2 + { + + struct is_edge : public Function_p2b< is_edge > + { + typedef bool result; + bool operator()(const point2d& p) const; + }; + + +# ifndef MLN_INCLUDE_ONLY + + inline + bool + is_edge::operator()(const point2d& p) const + { + return p.row() % 2 + p.col() % 2 == 1; + } + +# endif // ! MLN_INCLUDE_ONLY + + + } // end of namespace mln::world::inter_pixel::dim2 + + } // end of namespace mln::world::inter_pixel + + } // end of namespace mln::world + +} // end of namespace mln + +#endif // ! MLN_WORLD_INTER_PIXEL_DIM2_IS_EDGE_HH
participants (1)
-
Fabien Freling