proto-1.0 220: Add morphological gradients

ChangeLog | 12 +++++ Makefile.am | 1 img/Makefile.am | 1 img/lena-small.pgm | 5 ++ oln/makefile.src | 4 + oln/morpho/gradient.hh | 104 ++++++++++++++++++++++++++++++++++++++++++++ tests/morpho/tests/gradient | 48 ++++++++++++++++++++ 7 files changed, 175 insertions(+) Index: olena/ChangeLog from Roland Levillain <roland@lrde.epita.fr> Add morphological gradients. * oln/morpho/gradient.hh: New file. * tests/morpho/tests/gradient: New test. * img/lena-small.pgm: New image. * img/Makefile.am (SOURCE_IMGS): Add $(srcdir)/lena-small.pgm. * oln/makefile.src (OLN_DEP): Add convert/abstract/conversion.hh, convert/conversion.hh, convert/force.hh and morpho/gradient.hh. * Makefile.am (EXTRA_DIST): Add TODO. 2005-06-23 Roland Levillain <roland@lrde.epita.fr> Index: olena/tests/morpho/tests/gradient --- olena/tests/morpho/tests/gradient (révision 0) +++ olena/tests/morpho/tests/gradient (révision 0) @@ -0,0 +1,48 @@ + // -*- C++ -*- +#include "data.hh" +#include <oln/utils/md5.hh> + +#include <ntg/int.hh> +#include <oln/core/2d/image2d.hh> +#include <oln/core/gen/image_with_nbh.hh> +#include <oln/io/read_image.hh> +#include <oln/io/write_image.hh> +#include <oln/morpho/gradient.hh> + +using namespace oln; + +bool check() +{ + typedef image2d<ntg::int_u8> ima_type; + ima_type input; + input = io::read(rdata("lena-small.pgm")); + + // Beucher gradient. + utils::key::value_type bg_data_key[16] = + {0x89, 0xaa, 0x5b, 0xca, 0x8, 0xec, 0xb3, 0xe7, + 0x86, 0xfb, 0x4b, 0x59, 0xf0, 0x8, 0xf5, 0x59}; + utils::key bg_key(bg_data_key); + ima_type bg = morpho::beucher_gradient(input, win_c8p()); + if (utils::md5(bg) != bg_key) + return true; + + // Internal gradient. + utils::key::value_type ig_data_key[16] = + {0xe7, 0xff, 0x90, 0x2a, 0x50, 0x44, 0x30, 0x65, + 0xeb, 0xe3, 0xf2, 0xc4, 0x6f, 0xfe, 0x65, 0x84}; + utils::key ig_key(ig_data_key); + ima_type ig = morpho::internal_gradient(input, win_c8p()); + if (utils::md5(ig) != ig_key) + return true; + + // External gradient. + utils::key::value_type eg_data_key[16] = + {0xf7, 0xb7, 0x9e, 0x74, 0xe0, 0xd1, 0xe7, 0xd8, + 0x5b, 0x0, 0xe8, 0x37, 0x57, 0xdc, 0x2c, 0x27}; + utils::key eg_key(eg_data_key); + ima_type eg = morpho::external_gradient(input, win_c8p()); + if (utils::md5(eg) != eg_key) + return true; + + return false; +} Index: olena/oln/makefile.src --- olena/oln/makefile.src (révision 216) +++ olena/oln/makefile.src (copie de travail) @@ -22,6 +22,9 @@ config/pconf.hh \ config/system.hh \ \ + convert/abstract/conversion.hh \ + convert/conversion.hh \ + convert/force.hh \ convert/value_to_point.hh \ \ core/1d/array1d.hh \ @@ -166,6 +169,7 @@ morpho/erosion.hh \ morpho/geodesic_dilation.hh \ morpho/geodesic_erosion.hh \ + morpho/gradient.hh \ morpho/lower_completion.hh \ morpho/opening.hh \ morpho/reconstruction_by_dilation.hh \ Index: olena/oln/morpho/gradient.hh --- olena/oln/morpho/gradient.hh (révision 0) +++ olena/oln/morpho/gradient.hh (révision 0) @@ -0,0 +1,104 @@ +// Copyright (C) 2001, 2002, 2004, 2005 EPITA Research and Development Laboratory +// +// 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, 59 Temple Place - Suite 330, 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 OLENA_MORPHO_GRADIENT_HH +# define OLENA_MORPHO_GRADIENT_HH + +# include <oln/morpho/dilation.hh> +# include <oln/morpho/erosion.hh> +# include <oln/level/arith.hh> +# include <oln/convert/force.hh> +# include <oln/core/ch_value_type.hh> + +namespace oln { + + namespace morpho { + + // FIXME: Document! (Get the documentation from Olena 0.10 and + // adjust it.) + + template<class C, class B, class I, class W> + typename ch_value_type<I, typename convoutput<C, B, oln_type_of(I, value)>::ret>::ret + beucher_gradient(const convert::abstract::conversion<C, B>& c, + const abstract::scalar_valued_image<I>& input, + const abstract::window<W>& win) + { + return level::minus(c, dilation(input, win), erosion(input, win)); + } + + template<class I, class W> + oln_type_of(I, concrete) + beucher_gradient(const abstract::scalar_valued_image<I>& input, + const abstract::window<W>& win) + { + return beucher_gradient(convert::force<oln_type_of(I, value)>(), + input, win); + } + + + template<class C, class B, class I, class W> + typename ch_value_type<I, typename convoutput<C, B, oln_type_of(I, value)>::ret>::ret + internal_gradient(const convert::abstract::conversion<C, B>& c, + const abstract::scalar_valued_image<I>& input, + const abstract::window<W>& win) + { + return level::minus(c, input, erosion(input, win)); + } + + template<class I, class W> + oln_type_of(I, concrete) + internal_gradient(const abstract::scalar_valued_image<I>& input, + const abstract::window<W>& win) + { + return internal_gradient(convert::force<oln_type_of(I, value)>(), + input, win); + } + + + template<class C, class B, class I, class W> + typename ch_value_type<I, typename convoutput<C, B, oln_type_of(I, value)>::ret>::ret + external_gradient(const convert::abstract::conversion<C, B>& c, + const abstract::scalar_valued_image<I>& input, + const abstract::window<W>& win) + { + return level::minus(c, dilation(input, win), input); + } + + template<class I, class W> + oln_type_of (I, concrete) + external_gradient(const abstract::scalar_valued_image<I>& input, + const abstract::window<W>& win) + { + return external_gradient(convert::force<oln_type_of(I, value)>(), + input, win); + } + + } // end of namespace oln::morpho + +} // end of namespace oln + +#endif // OLENA_MORPHO_GRADIENT_HH Index: olena/Makefile.am --- olena/Makefile.am (révision 216) +++ olena/Makefile.am (copie de travail) @@ -3,3 +3,4 @@ # OLN_SRC_SUBDIRS is set when "configure" is run. SUBDIRS = img oln $(OLN_SRC_SUBDIRS) +EXTRA_DIST = TODO Index: olena/img/Makefile.am --- olena/img/Makefile.am (révision 216) +++ olena/img/Makefile.am (copie de travail) @@ -13,6 +13,7 @@ $(srcdir)/lena.pgm.gz \ $(srcdir)/lena.ppm \ $(srcdir)/lena.ppm.gz \ + $(srcdir)/lena-small.pgm \ $(srcdir)/marker.pbm \ $(srcdir)/mask.pbm \ $(srcdir)/object.pbm \
participants (1)
-
Roland Levillain