Commit da24c7e3 authored by Thierry Geraud's avatar Thierry Geraud
Browse files

Fix missing file.

	* mln/value/cast.hh: New.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@1065 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent cee613b7
2007-09-03 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Fix missing file.
* mln/value/cast.hh: New.
2007-08-31 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Augment morphology.
......
// Copyright (C) 2007 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, 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_LABELING_FOREGROUND_HH
# define MLN_LABELING_FOREGROUND_HH
/*! \file mln/labeling/foreground.hh
*
* \brief Foreground a function-object onto image pixel values.
*/
# include <mln/core/concept/image.hh>
# include <mln/core/concept/function.hh>
namespace mln
{
namespace labeling
{
/*! Foreground a function-object to the image \p input.
*
* \param[in,out] input The input image.
* \param[in] f The function-object.
*
* This routine runs: \n
* for all p of \p input, \p input(p) = \p f( \p input(p) ) \n
*
* This routine is equivalent to labeling::tranform(input, f, input)
* but it is faster since a single iterator is required.
*
* \todo Add versions for lowq images.
*/
template <typename I, typename F>
void foreground(Image<I>& input, const Function_v2v<F>& f);
# ifndef MLN_INCLUDE_ONLY
namespace impl
{
template <typename I, typename F>
void foreground_(Image<I>& input_, const F& f)
{
I& input = exact(input_);
mln_piter(I) p(input.domain());
for_all(p)
input(p) = f(input(p));
}
template <typename I, typename F>
void foreground_(Fast_Image<I>& input_, const F& f)
{
I& input = exact(input_);
mln_pixter(I) pxl(input);
for_all(pxl)
pxl.val() = f(pxl.val());
}
} // end of namespace mln::labeling::impl
// Facade.
template <typename I, typename F>
void foreground(Image<I>& input, const Function_v2v<F>& f)
{
mln_precondition(exact(input).has_data());
impl::foreground_(exact(input), exact(f));
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::labeling
} // end of namespace mln
#endif // ! MLN_LABELING_FOREGROUND_HH
// Copyright (C) 2007 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, 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_VALUE_CAST_HH
# define MLN_VALUE_CAST_HH
/*! \file mln/value/cast.hh
* \brief Definition of the mln::value::cast routine.
*/
# include <mln/core/concept/value.hh>
namespace mln
{
namespace value
{
/// Cast a value \p src from type \c Src to type \c Dest.
template <typename Dest, typename Src>
Dest cast(const Src& src);
# ifndef MLN_INCLUDE_ONLY
namespace internal
{
template <typename S>
const S&
cast_(const S& src, ...)
{
return src;
}
template <typename T, typename S>
typename S::equiv
cast_(const T&, const Value<S>& src)
{
return exact(src);
}
} // end of namespace mln::value::internal
template <typename Dest, typename Src>
Dest cast(const Src& src)
{
return internal::cast_(src, src);
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::value
} // end of namespace mln
#endif // ! MLN_VALUE_CAST_HH
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment