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

Update and add : apply, local canvas.

	* tests/core/Makefile.am: .
	* oln/function: New.
	* oln/function/min.hh: New.
	* oln/level/apply.hh: .
	* oln/level/local.hh: New.
	* oln/core/concept/image.hh: .
	* oln/core/concept/functions.hh: .
	* oln/core/internal/max_value.hh: New.
	* oln/morphomath: New.
	* oln/morphomath/dilatation.hh: New.
	* oln/morphomath/erosion.hh: New.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@875 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 704d1c17
2007-03-14 Ugo Jardonnet <ugo.jardonnet@lrde.epita.fr>
Update and add : apply, local canvas.
* tests/core/Makefile.am: .
* oln/function: New.
* oln/function/min.hh: New.
* oln/level/apply.hh: .
* oln/level/local.hh: New.
* oln/core/concept/image.hh: .
* oln/core/concept/functions.hh: .
* oln/core/internal/max_value.hh: New.
* oln/morphomath: New.
* oln/morphomath/dilatation.hh: New.
* oln/morphomath/erosion.hh: New.
2007-03-14 Nicolas Ballas <ballas@lrde.epita.fr>
New sparse_image class, not working yet.
......
......@@ -73,6 +73,16 @@ namespace oln
};
// Neighborhood -> Value.
template <typename Exact>
struct Accumulator : public Function<Exact>
{
protected:
Accumulator();
};
/*
// Value1 -> Value2 *and* Value2 -> Value1.
......
......@@ -132,7 +132,7 @@ namespace oln
stc_typename(plain);
bool owns_(const psite& p) const;
rvalue operator()(const psite& p) const;
rvalue operator()(const psite& p) const;
box bbox() const;
pset points() const;
......
// 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 OLN_CORE_INTERNAL_MAX_VALUE_HH_
# define OLN_CORE_INTERNAL_MAX_VALUE_HH_
#include <cassert>
#include <limits>
#include <iostream>
namespace oln
{
#define oln_max(T) std::numeric_limits< T >::max()
}
#endif /* !OLN_CORE_INTERNAL_MAX_VALUE_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 OLN_FUNCTION_MIN_HH_
# define OLN_FUNCTION_MIN_HH_
namespace oln
{
template <typename T>
struct min_ : oln::Function< min_<T> >
{
typedef T argument;
typedef void result;
min_()
{
init();
}
void init()
{
val_ = oln_max_value(T);
}
T value() const
{
return 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_ */
......@@ -41,7 +41,7 @@ namespace oln
/// Fwd decl.
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);
// /// Fwd decl.
......@@ -63,17 +63,64 @@ namespace oln
namespace impl
{
/// Generic version.
template < typename F >
struct result
{
typedef typename F::result ret;
};
template <typename R, typename A, typename I>
oln_plain_value(I, R)
apply(R (*fun)(A), const Image<I>& input)
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 //
//---------
template <typename F, typename I>
oln_plain_value(I, result<typename F>::ret)
apply(const F& fun, const Image<I>& input)
{
typedef argument<typename F>::ret A;
typedef result<typename F>::ret R;
oln_ch_value(I, R) output(input.points());
oln_piter(I) p(input.points());
for_all(p)
output(p) = fun( static_cast<A>(input(p)) );
return output;
}
// 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, R) output(input.points());
oln_piter(I) p(input.points());
for_all(p)
output(p) = fun(input(p));
return output;
typedef argument<typename F>::ret A;
typedef result<typename F>::ret R;
oln_ch_value(I, R) output(input.points());
oln_piter(I) p(input.points());
for_all(p)
output(p) = local_apply(fun, input, p);
return output;
}
......@@ -112,15 +159,41 @@ namespace oln
} // end of namespace oln::level::impl
/// Facades.
//----------------------------
/// Apply.
/// Facade.
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)
{
return impl::apply(fun, 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)
{
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)
{
return impl::apply_local(fun, exact(input));
}
// /// Facade.
// template <typename I, typename F>
// oln_plain_value(I, typename F::result_value)
......
// 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 OLN_LEVEL_LOCAL_HH_
# define OLN_LEVEL_LOCAL_HH_
namespace oln
{
namespace impl
{
// LOCAL APPLICATION ON NBH //
//----------------------------
/// Local Apply on neighborhood ( nbh included in image ).
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)
{
fun.init();
oln_niter(I) n(p, input.points());
for_all(n)
fun(input(n));
return fun.value();
}
/// Local Apply on neighborhood ( nhb has to be given ).
// ...FIXME
// LOCAL APPLICATION ON WINDOW //
//-------------------------------
/// Local Apply on window ( window included in image).
// ...FIXME
/// Local Apply on window ( window is given ).
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)
{
fun.init();
oln_qiter(W) q(p, win);
for_all(q)
fun(input(q));
return fun.value();
}
}
/// Facades.
local_apply( )
{
}
}
#endif /* !OLN_LEVEL_LOCAL_HH_ */
#ifndef OLN_MORPHOMATH_DILATATION_HH_
# define OLN_MORPHOMATH_DILATATION_HH_
// Facade.
namespace impl
{
/// Generic version
template <typename I, typename W>
I dilatation(const Image<I>& input)
{
max_<oln_value(I)> max;
return apply(max, input);
}
}
/// Facade.
template <typename I, typename W>
I erosion(const Image<I>& input)
{
return impl::dilatation(exact(input));
}
#endif /* !OLN_MORPHOMATH_DILATATION_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 OLN_MORPHOMATH_EROSION_HH_
# define OLN_MORPHOMATH_EROSION_HH_
#include <oln/fonction/min.hh>
#include <oln/level/local.hh>
namespace oln
{
namespace impl
{
/// Generic version
template <typename I, typename W>
I erosion(const Image<I>& input)
{
min_<oln_value(I)> min;
return apply(min, input);
}
}
// Facade.
template <typename I, typename W>
I erosion(const Point_Wise_Accessible_Image<I>& input)
{
return impl::erosion(exact(input));
}
}
#endif /* !OLN_MORPHOMATH_EROSION_HH_ */
......@@ -37,7 +37,6 @@ image2d_SOURCES = image2d.cc
neighb2d_SOURCES = neighb2d.cc
npoints_SOURCES = npoints.cc
window2d_SOURCES = window2d.cc
neighb2d_SOURCES = neighb2d.cc
# Methods.
at_SOURCES = at.cc
......
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