Commit bda63844 authored by Ugo Jardonnet's avatar Ugo Jardonnet
Browse files

Update : Norme, Sanity, apply of user functors. erosion not yet usable.

	* oln/function/min.hh: .
	* oln/level/apply.hh: .
	* oln/level/local.hh: .
	* oln/core/concept/functions.hh: .
	* oln/core/internal/max_value.hh: .
	* oln/morphomath/erosion.hh: .


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@884 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 41f0aa06
2007-03-16 Ugo Jardonnet <ugo.jardonnet@lrde.epita.fr>
Update : Norme, Sanity, apply of user functors. erosion not yet usable.
* oln/function/min.hh: .
* oln/level/apply.hh: .
* oln/level/local.hh: .
* oln/core/concept/functions.hh: .
* oln/core/internal/max_value.hh: .
* oln/morphomath/erosion.hh: .
2007-03-16 Roland Levillain <roland@lrde.epita.fr>
* oln/Makefile.am (nobase_oln_HEADERS): Remove obsolete files.
......
......@@ -38,8 +38,8 @@ namespace oln
// Fwd decl.
namespace morpher {
template <typename I, typename F> class two_way;
template <typename I, typename F> class two_way_rw;
template <typename I, typename F> class two_way;
template <typename I, typename F> class two_way_rw;
}
namespace value { template <typename I, typename F> class two_way; }
......@@ -48,8 +48,8 @@ namespace oln
template <typename Exact>
struct Function : public Any<Exact>
{
protected:
Function();
protected:
Function();
};
......@@ -58,8 +58,8 @@ namespace oln
template <typename Exact>
struct Function_p2v : public Function<Exact>
{
protected:
Function_p2v();
protected:
Function_p2v();
};
......@@ -68,8 +68,8 @@ namespace oln
template <typename Exact>
struct Function_v2v : public Function<Exact>
{
protected:
Function_v2v();
protected:
Function_v2v();
};
......@@ -78,8 +78,8 @@ namespace oln
template <typename Exact>
struct Accumulator : public Function<Exact>
{
protected:
Accumulator();
protected:
Accumulator();
};
......@@ -92,12 +92,12 @@ namespace oln
{
public:
template <typename I>
oln::morpher::two_way<I, Exact>
operator()(oln::abstract::mutable_image<I>& input) const;
template <typename I>
oln::morpher::two_way<I, Exact>
operator()(oln::abstract::mutable_image<I>& input) const;
protected:
Function_v2w2v();
Function_v2w2v();
};
......@@ -108,12 +108,12 @@ namespace oln
{
public:
template <typename I>
oln::morpher::two_way_rw<I, Exact>
operator()(oln::abstract::mutable_image<I>& input) const;
template <typename I>
oln::morpher::two_way_rw<I, Exact>
operator()(oln::abstract::mutable_image<I>& input) const;
protected:
Function_rw();
Function_rw();
};
*/
......@@ -124,8 +124,8 @@ namespace oln
template <typename Exact>
struct Function_p2p : public Function<Exact>
{
protected:
Function_p2p();
protected:
Function_p2p();
};
......
......@@ -30,12 +30,11 @@
#include <cassert>
#include <limits>
#include <iostream>
namespace oln
{
#define oln_max(T) std::numeric_limits< T >::max()
#define oln_max(T) std::numeric_limits<T>::max()
}
......
// Copyright (C) 2007 EPITA Research and
// Development Laboratory
// 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
......@@ -26,43 +25,43 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef OLN_FUNCTION_MIN_HH_
# define OLN_FUNCTION_MIN_HH_
#ifndef _FUNCTION_MIN_HH
# define _FUNCTION_MIN_HH
#include <oln/core/concept/functions.hh>
#include <oln/core/internal/max_value.hh>
namespace oln
{
template <typename T>
struct min_ : oln::Function< min_<T> >
namespace function
{
typedef T argument;
typedef void result;
min_()
{
init();
}
template <typename T>
struct min_ : public oln::Accumulator< min_<T> >
{
typedef T argument;
typedef T result;
min_() { this->init(); }
void init() { val_ = oln_max(T); }
result value() const { return val_; }
void init()
{
val_ = oln_max_value(T);
}
template <typename U>
void operator()(U i) const
{
if (i < val_)
val_ = static_cast<T>(i);
}
T value() const
{
return val_;
}
private:
mutable T val_;
};
template <typename U>
void operator()(U i) const
{
if (i < val_)
val_ = static_cast<T>(i);
}
private:
mutable T val_;
};
}
}
#endif /* !OLN_FUNCTION_MIN_HH_ */
#endif // ! OLN_FUNCTION_MIN_HH
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 EPITA Research and
// Development Laboratory
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 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
......@@ -30,7 +30,9 @@
# define OLN_LEVEL_APPLY_HH
# include <oln/core/concept/image.hh>
# include <oln/core/concept/iterator.hh>
# include <oln/core/internal/f_ch_value.hh>
# include <oln/level/local.hh>
namespace oln
{
......@@ -63,63 +65,37 @@ namespace oln
namespace impl
{
template < typename F >
struct result
{
typedef typename F::result ret;
};
template < typename R (*fun)(A) >
struct result
{
typedef typename R ret;
};
template < typename F >
struct argument
{
typedef typename F::argument ret;
};
template < typename R (*fun)(A) >
struct argument
{
typedef typename A ret;
};
// APPLY //
//---------
/// apply
template <typename F, typename I>
oln_plain_value(I, result<typename F>::ret)
apply(const F& fun, const Image<I>& input)
oln_plain_value(I, typename F::result)
apply( F& f, const Image<I>& input)
{
typedef argument<typename F>::ret A;
typedef result<typename F>::ret R;
typedef typename F::result result;
typedef typename F::argument argument;
oln_ch_value(I, R) output(input.points());
oln_ch_value(I, result) output(input.points());
oln_piter(I) p(input.points());
for_all(p)
output(p) = fun( static_cast<A>(input(p)) );
output(p) = f( static_cast< argument >(input(p)) );
return output;
}
// APPLY_LOCAL //
//---------------
/// apply_local
template <typename F, typename I>
oln_plain_value(I, result<typename F>::ret)
apply_local(const F& fun, const Image<I>& input)
oln_plain_value(I, typename F::result)
apply_local(const Accumulator<F>& fun,
const Image_with_Nbh<I>& input)
{
typedef argument<typename F>::ret A;
typedef result<typename F>::ret R;
typedef typename F::result result;
typedef typename F::argument argument;
oln_ch_value(I, R) output(input.points());
oln_ch_value(I, argument) output(input.points());
oln_piter(I) p(input.points());
for_all(p)
output(p) = local_apply(fun, input, p);
output(p) = local(fun, input, p);
return output;
}
......@@ -166,30 +142,31 @@ namespace oln
template <typename R, typename A, typename I>
oln_plain_value(I, R)
apply(R (*fun)(A), const Image<I>& input)
apply(R (*fun)(A), const Image<I>& input)
{
return impl::apply(fun, exact(input));
}
template <typename F, typename I>
oln_plain_value(I, typename F::result)
apply(const F& fun, const Image<I>& input)
apply(F& f, const Image<I>& input)
{
return impl::apply(fun, exact(input));
return impl::apply(f, exact(input));
}
/// Apply local
template <typename R, typename A, typename I>
oln_plain_value(I, R)
apply_local(R (*fun)(A), const Image<I>& input)
apply_local(R (*fun)(A), const Image<I>& input)
{
return impl::apply_local(fun, exact(input));
}
template <typename F, typename I>
oln_plain_value(I, typename F::result)
apply_local(const F& fun, const Image<I>& input)
apply_local(const Accumulator<F>& fun,
const Image_with_Nbh<I>& input)
{
return impl::apply_local(fun, exact(input));
}
......
// Copyright (C) 2007 EPITA Research and
// Development Laboratory
// 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
......@@ -16,81 +15,118 @@
// 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 OLN_LEVEL_LOCAL_HH_
# define OLN_LEVEL_LOCAL_HH_
// 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 OLN_LEVEL_LOCAL_HH
# define OLN_LEVEL_LOCAL_HH
#include <oln/core/concept/image.hh>
#include <oln/core/concept/point.hh>
#include <oln/core/concept/functions.hh>
#include <oln/core/concept/window.hh>
#include <oln/core/concept/iterator.hh> // bizarre
#include <oln/core/equipment.hh>
namespace oln
{
namespace impl
namespace level
{
// LOCAL APPLICATION ON NBH //
//----------------------------
template <typename A, typename I>
typename A::result
local(const Accumulator<A>& f,
const Image_with_Nbh<I>& input,
const oln_point(I)& p);
/// Local Apply on neighborhood ( nbh included in image ).
template <typename F, typename I, typename W>
typename F::result
local(const Accumulator<F>& f,
const Image<I>& input,
const oln_point(I)& p,
const Window<W>& win);
template <typename R, typename A, typename I>
typename A::result
local_apply(const Accumulator< A >& fun,
const Image_with_Nbh< I >& input,
const oln_point( I )& p)
# ifndef OLN_INCLUDE_ONLY
namespace impl
{
fun.init();
oln_niter(I) n(p, input.points());
for_all(n)
fun(input(n));
return fun.value();
}
/// Local Apply on neighborhood (nbh included in image).
template <typename A, typename I>
typename A::result
local(const Accumulator<A>& f,
const Image_with_Nbh<I>& input,
const oln_point(I)& p)
{
f.init();
oln_niter(I) n(p, input.points());
for_all(n)
f(input(n));
return f.value();
}
/// Local Apply on neighborhood (nhb given as argument).
// ...FIXME
/// Local Apply on neighborhood ( nhb has to be given ).
// ...FIXME
/// Local Apply on window (window included in image).
// ...FIXME
// LOCAL APPLICATION ON WINDOW //
//-------------------------------
/// Local Apply on window (window is given).
/// Local Apply on window ( window included in image).
template <typename F, typename I, typename W>
typename F::result
local(const Accumulator<F>& f,
const Image<I>& input,
const oln_point(I)& p,
const Window<W>& win)
{
f.init();
oln_qiter(W) q(p, win);
for_all(q)
f(input(q));
// ...FIXME
return f.value();
}
}
/// Facades.
/// Local Apply on window ( window is given ).
template <typename A, typename I>
typename A::result
local(const Accumulator<A>& f,
const Image_with_Nbh<I>& input,
const oln_point( I )& p)
{
return impl::local(f, input, p);
}
template <typename F, typename I, typename W>
typename F::result
local_apply(const Accumulator<F>& fun,
const Image<I>& input,
const oln_point(I)& p,
const Window<W>& win)
local(const Accumulator<F>& f,
const Image<I>& input,
const oln_point(I)& p,
const Window<W>& win)
{
fun.init();
oln_qiter(W) q(p, win);
for_all(q)
fun(input(q));
return fun.value();
return impl::local(f, input, p, win);
}
}
/// Facades.
#endif // ! OLN_INCLUDE_ONLY
local_apply( )
{
}
}
#endif /* !OLN_LEVEL_LOCAL_HH_ */
#endif // ! OLN_LEVEL_LOCAL_HH
......@@ -26,34 +26,41 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef OLN_MORPHOMATH_EROSION_HH_
# define OLN_MORPHOMATH_EROSION_HH_
#ifndef OLN_MORPHO_EROSION_HH
# define OLN_MORPHO_EROSION_HH
#include <oln/fonction/min.hh>
#include <oln/level/local.hh>
#include <oln/function/min.hh>
namespace oln
{
namespace impl
{
/// Generic version
namespace morpho
{
template <typename I, typename W>
I erosion(const Image<I>& input)
namespace impl
{
min_<oln_value(I)> min;
return apply(min, input);
/// Generic version
template <typename I>
I erosion(Image_with_Nbh<I>& input)
{
function::min_<oln_value(I)> min;
return ::oln::level::apply_local(min, input);
}
}
}
// Facade.
// Facade.
template <typename I, typename W>
I erosion(const Point_Wise_Accessible_Image<I>& input)
{
return impl::erosion(exact(input));
}
template <typename I>
I erosion(Image_with_Nbh<I>& input)
{
return impl::erosion(exact(input));
}
} // end of namespace
}
#endif /* !OLN_MORPHOMATH_EROSION_HH_ */
#endif // ! OLN_MORPHO_EROSION_HH
Markdown is supported
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