Commit 16705db8 authored by Thierry Geraud's avatar Thierry Geraud
Browse files

Add routines to deal with images of accumulators.

	* mln/accu/image: New directory.
	* mln/accu/image/init.hh: New.
	* mln/accu/image/take.hh: New.
	* mln/accu/image/set_value.hh: New.
	* mln/accu/image/all.hh: New.
	* mln/accu/image/take_as_init.hh: New.
	* mln/accu/image/to_result.hh: New.
	* mln/accu/all.hh: Update.
	* tests/accu/image: New.
	* tests/accu/image/to_result.cc: New.
	* tests/accu/image/init.cc: New.
	* tests/accu/image/take.cc: New.
	* tests/accu/image/Makefile.am: New.
	* tests/accu/image/set_value.cc: New.
	* tests/accu/image/take_as_init.cc: New.
	* tests/accu/Makefile.am: Update.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@3532 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 85af2a47
2009-03-15 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Add routines to deal with images of accumulators.
* mln/accu/image: New directory.
* mln/accu/image/init.hh: New.
* mln/accu/image/take.hh: New.
* mln/accu/image/set_value.hh: New.
* mln/accu/image/all.hh: New.
* mln/accu/image/take_as_init.hh: New.
* mln/accu/image/to_result.hh: New.
* mln/accu/all.hh: Update.
* tests/accu/image: New.
* tests/accu/image/to_result.cc: New.
* tests/accu/image/init.cc: New.
* tests/accu/image/take.cc: New.
* tests/accu/image/Makefile.am: New.
* tests/accu/image/set_value.cc: New.
* tests/accu/image/take_as_init.cc: New.
* tests/accu/Makefile.am: Update.
2009-03-14 Edwin Carlinet <carlinet@lrde.epita.fr>
 
Disambiguate component tree iterators.
// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
// (LRDE)
// Copyright (C) 2007, 2008, 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
......@@ -93,5 +93,9 @@ namespace mln
# include <mln/accu/transform_line.hh>
# include <mln/accu/transform_snake.hh>
// Sub-directories
# include <mln/accu/image/all.hh>
#endif // ! MLN_ACCU_ALL_HH
// 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_ACCU_IMAGE_ALL_HH
# define MLN_ACCU_IMAGE_ALL_HH
/// \file mln/accu/image/all.hh
///
/// File that includes all accumulator image routines.
namespace mln
{
/// Namespace of accumulators.
namespace accu
{
/// Namespace of accumulator image routines.
namespace image {}
}
}
# include <mln/accu/image/init.hh>
# include <mln/accu/image/set_value.hh>
# include <mln/accu/image/take_as_init.hh>
# include <mln/accu/image/take.hh>
# include <mln/accu/image/to_result.hh>
#endif // ! MLN_ACCU_IMAGE_ALL_HH
// 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_ACCU_IMAGE_INIT_HH
# define MLN_ACCU_IMAGE_INIT_HH
/// \file mln/accu/image/init.hh
///
/// Initialize an image of accumulators.
# include <mln/core/concept/accumulator.hh>
# include <mln/core/concept/image.hh>
namespace mln
{
namespace accu
{
namespace image
{
template <typename I>
void
init(Image<I>& input);
# ifndef MLN_INCLUDE_ONLY
namespace impl
{
// Generic version.
namespace generic
{
template <typename I>
void
init(Image<I>& input_)
{
trace::entering("accu::impl::image::generic::init");
I& input = exact(input_);
mln_precondition(input.is_valid());
mln_piter(I) p(input.domain());
for_all(p)
input(p).init();
trace::exiting("accu::impl::image::generic::init");
}
} // end of namespace mln::accu::image::impl::generic
// Fastest version.
template <typename I>
void
init_fastest(Image<I>& input_)
{
trace::entering("accu::impl::image::init_fastest");
I& input = exact(input_);
mln_precondition(input.is_valid());
mln_pixter(I) px(input);
for_all(px)
px.val().init();
trace::exiting("accu::impl::image::init_fastest");
}
} // end of namespace mln::accu::image::impl
// Dispatch.
namespace internal
{
template <typename I>
void
init_dispatch(trait::image::speed::any,
Image<I>& input)
{
impl::generic::init(input);
}
template <typename I>
void
init_dispatch(trait::image::speed::fastest,
Image<I>& input)
{
impl::init_fastest(input);
}
template <typename I>
void
init_dispatch(Image<I>& input)
{
init_dispatch(mln_trait_image_speed(I)(),
input);
}
} // end of namespace mln::accu::image::internal
// Facade.
template <typename I>
void
init(Image<I>& input)
{
trace::entering("accu::image::init");
mlc_is_a(mln_value(I), Accumulator)::check();
mln_precondition(exact(input).is_valid());
internal::init_dispatch(input);
trace::exiting("accu::image::init");
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::accu::image
} // end of namespace mln::accu
} // end of namespace mln
#endif // ! MLN_ACCU_IMAGE_INIT_HH
// 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_ACCU_IMAGE_SET_VALUE_HH
# define MLN_ACCU_IMAGE_SET_VALUE_HH
/// \file mln/accu/image/set_value.hh
///
/// Set the values of an image of accumulators.
# include <mln/core/concept/accumulator.hh>
# include <mln/core/concept/image.hh>
namespace mln
{
namespace accu
{
namespace image
{
template <typename I>
void
set_value(Image<I>& input,
const mln_deduce(I, value, result)& res);
# ifndef MLN_INCLUDE_ONLY
namespace impl
{
// Generic version.
namespace generic
{
template <typename I>
void
set_value(Image<I>& input_,
const mln_deduce(I, value, result)& res)
{
trace::entering("accu::impl::image::generic::set_value");
I& input = exact(input_);
mln_precondition(input.is_valid());
mln_piter(I) p(input.domain());
for_all(p)
input(p).set_value(res);
trace::exiting("accu::impl::image::generic::set_value");
}
} // end of namespace mln::accu::image::impl::generic
// Fastest version.
template <typename I>
void
set_value_fastest(Image<I>& input_,
const mln_deduce(I, value, result)& res)
{
trace::entering("accu::impl::image::set_value_fastest");
I& input = exact(input_);
mln_precondition(input.is_valid());
mln_pixter(I) px(input);
for_all(px)
px.val().set_value(res);
trace::exiting("accu::impl::image::set_value_fastest");
}
} // end of namespace mln::accu::image::impl
// Dispatch.
namespace internal
{
template <typename I, typename V>
void
set_value_dispatch(trait::image::speed::any,
Image<I>& input, const V& res)
{
impl::generic::set_value(input, res);
}
template <typename I, typename V>
void
set_value_dispatch(trait::image::speed::fastest,
Image<I>& input, const V& res)
{
impl::set_value_fastest(input, res);
}
template <typename I, typename V>
void
set_value_dispatch(Image<I>& input, const V& res)
{
set_value_dispatch(mln_trait_image_speed(I)(),
input, res);
}
} // end of namespace mln::accu::image::internal
// Facade.
template <typename I>
void
set_value(Image<I>& input,
const mln_deduce(I, value, result)& res)
{
trace::entering("accu::image::set_value");
mlc_is_a(mln_value(I), Accumulator)::check();
mln_precondition(exact(input).is_valid());
internal::set_value_dispatch(input, res);
trace::exiting("accu::image::set_value");
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::accu::image
} // end of namespace mln::accu
} // end of namespace mln
#endif // ! MLN_ACCU_IMAGE_SET_VALUE_HH
// 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_ACCU_IMAGE_TAKE_HH
# define MLN_ACCU_IMAGE_TAKE_HH
/// \file mln/accu/image/take.hh
///
/// Update an image of accumulators by taking the contents of another
/// image.
# include <mln/core/concept/accumulator.hh>
# include <mln/core/concept/image.hh>
namespace mln
{
namespace accu
{
namespace image
{
template <typename I, typename J>
void
take(Image<I>& input, const Image<J>& arg);
# ifndef MLN_INCLUDE_ONLY
namespace impl
{
// Generic version.
namespace generic
{
template <typename I, typename J>
void
take(Image<I>& input_, const Image<J>& arg_)
{
trace::entering("accu::impl::image::generic::take");
I& input = exact(input_);
const J& arg = exact(arg_);
mln_precondition(input.is_valid());
mln_precondition(arg.is_valid());
mln_precondition(arg.domain() <= input.domain());
mln_piter(J) p(arg.domain());
for_all(p)
input(p).take(arg(p));
trace::exiting("accu::impl::image::generic::take");
}
} // end of namespace mln::accu::image::impl::generic
// Fastest version.
template <typename I, typename J>
void
take_fastest(Image<I>& input_, const Image<J>& arg_)
{
trace::entering("accu::impl::image::take_fastest");
I& input = exact(input_);
const J& arg = exact(arg_);
mln_precondition(input.is_valid());
mln_precondition(arg.is_valid());
mln_precondition(arg.domain() == input.domain());
mln_pixter(I) p_in(input);
mln_pixter(const J) p_arg(arg);
for_all_2(p_in, p_arg)
p_in.val().take( p_arg.val() );
trace::exiting("accu::impl::image::take_fastest");
}
} // end of namespace mln::accu::image::impl
// Dispatch.
namespace internal
{
template <typename I, typename J>
void
take_dispatch(trait::image::speed::any,
trait::image::speed::any,
Image<I>& input, const Image<J>& arg)
{
impl::generic::take(input, arg);
}
template <typename I, typename J>
void
take_dispatch(trait::image::speed::fastest,
trait::image::speed::fastest,
Image<I>& input, const Image<J>& arg)
{
if (exact(arg).domain() == exact(input).domain())
impl::take_fastest(input, arg);
else
impl::generic::take(input, arg);
}
template <typename I, typename J>
void
take_dispatch(Image<I>& input, const Image<J>& arg)
{
take_dispatch(mln_trait_image_speed(I)(),
mln_trait_image_speed(J)(),
input, arg);
}
} // end of namespace mln::accu::image::internal
// Facade.
template <typename I, typename J>
void
take(Image<I>& input_, const Image<J>& arg_)
{
trace::entering("accu::image::take");
mlc_is_a(mln_value(I), Accumulator)::check();
mlc_converts_to(mln_value(J),
mln_deduce(I, value, argument))::check();
I& input = exact(input_);
const J& arg = exact(arg_);
mln_precondition(input.is_valid());
mln_precondition(arg.is_valid());
mln_precondition(arg.domain() <= input.domain());
internal::take_dispatch(input, arg);
trace::exiting("accu::image::take");
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::accu::image
} // end of namespace mln::accu
} // end of namespace mln
#endif // ! MLN_ACCU_IMAGE_TAKE_HH
// 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