Commit 3b0c3b4c authored by Thierry Geraud's avatar Thierry Geraud
Browse files

Add image selection about different kinds of values and update.

	* oln/core/concept/image.hh (Gray_Level_Image, Color_Image)
	(Label_Image, Binary_Image, String_Image)
	(Deformation_Field_Image, Data_Image): New.
	* oln/core/internal/max_value.hh: Fix.
	* oln/core/internal/image_selectors.hh (Image_value_kind): New. 
	* oln/morpho/dilation.hh: Fix.
	* oln/morpho/elementary_erosion.hh (elementary_erosion_): Rename as...
	(elementary_erosion_on_function_): ...this.
	(elementary_erosion_on_set_): New.
	(elementary_erosion_): Dispatch over function/set.
	(elementary_erosion): Update.
	* oln/level/local.hh (A): Rename as...
	(F): ...this.
	* oln/accumulator/max.hh,
	* oln/core/internal/min_value.hh,
	* oln/morpho/elementary_dilation.hh: New.
	* oln/value/greylevel.hh: Rename as...
	* oln/value/graylevel.hh: ...this.
	(greylevel_, greylevel): Rename as...
	(graylevel_, graylevel): ...these.
	* oln/value/default.hh (greylevel): Rename as...
	(graylevel): ...this.
	* oln/value/all.hh (include): Update.
	* oln/value/bin.hh (bin): Change from greylevel_<1> to
	graylevel_<1>.
	* oln/value/tags.hh (is_grey_level): Rename as...
	(is_gray_level): ...this.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@892 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent a3ffe3dc
2007-03-21 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Add image selection about different kinds of values and update.
* oln/core/concept/image.hh (Gray_Level_Image, Color_Image)
(Label_Image, Binary_Image, String_Image)
(Deformation_Field_Image, Data_Image): New.
* oln/core/internal/max_value.hh: Fix.
* oln/core/internal/image_selectors.hh (Image_value_kind): New.
* oln/morpho/dilation.hh: Fix.
* oln/morpho/elementary_erosion.hh (elementary_erosion_): Rename as...
(elementary_erosion_on_function_): ...this.
(elementary_erosion_on_set_): New.
(elementary_erosion_): Dispatch over function/set.
(elementary_erosion): Update.
* oln/level/local.hh (A): Rename as...
(F): ...this.
* oln/accumulator/max.hh,
* oln/core/internal/min_value.hh,
* oln/morpho/elementary_dilation.hh: New.
* oln/value/greylevel.hh: Rename as...
* oln/value/graylevel.hh: ...this.
(greylevel_, greylevel): Rename as...
(graylevel_, graylevel): ...these.
* oln/value/default.hh (greylevel): Rename as...
(graylevel): ...this.
* oln/value/all.hh (include): Update.
* oln/value/bin.hh (bin): Change from greylevel_<1> to
graylevel_<1>.
* oln/value/tags.hh (is_grey_level): Rename as...
(is_gray_level): ...this.
2007-03-21 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Handle virtual borders.
......
// 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_ACCUMULATOR_MAX_HH
# define OLN_ACCUMULATOR_MAX_HH
# include <oln/core/concept/accumulator.hh>
# include <oln/core/internal/min_value.hh>
namespace oln
{
namespace accumulator
{
template <typename T>
struct max_ : public Accumulator< max_<T> >
{
typedef T argument;
typedef T result;
max_();
void init() const;
const T& value() const;
void operator()(const T& val) const;
private:
mutable T val_;
};
# ifndef OLN_INCLUDE_ONLY
template <typename T>
max_<T>::max_()
{
this->init();
}
template <typename T>
void
max_<T>::init() const
{
this->val_ = oln_min(T);
}
template <typename T>
const T&
max_<T>::value() const
{
return this->val_;
}
template <typename T>
void
max_<T>::operator()(const T& val) const
{
if (val > this->val_)
this->val_ = val;
}
# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln::accumulator
} // end of namespace oln
#endif // ! OLN_ACCUMULATOR_MAX_HH
......@@ -351,6 +351,69 @@ namespace oln
/// Concept-class "Gray_Level_Image".
template <typename Exact>
struct Gray_Level_Image : public virtual Image<Exact>
{
protected:
Gray_Level_Image();
};
/// Concept-class "Color_Image".
template <typename Exact>
struct Color_Image : public virtual Image<Exact>
{
protected:
Color_Image();
};
/// Concept-class "Label_Image".
template <typename Exact>
struct Label_Image : public virtual Image<Exact>
{
protected:
Label_Image();
};
/// Concept-class "Binary_Image".
template <typename Exact>
struct Binary_Image : public Label_Image<Exact>
{
protected:
Binary_Image();
};
/// Concept-class "String_Image".
template <typename Exact>
struct String_Image : public Label_Image<Exact>
{
protected:
String_Image();
};
/// Concept-class "Deformation_Field_Image".
template <typename Exact>
struct Deformation_Field_Image : public virtual Image<Exact>
{
protected:
Deformation_Field_Image();
};
/// Concept-class "Data_Image".
template <typename Exact>
struct Data_Image : public virtual Image<Exact>
{
protected:
Data_Image();
};
......@@ -613,6 +676,56 @@ namespace oln
{
}
// ----------------------------------- Gray_Level_Image<Exact>
template <typename Exact>
Gray_Level_Image<Exact>::Gray_Level_Image()
{
}
// ----------------------------------- Color_Image<Exact>
template <typename Exact>
Color_Image<Exact>::Color_Image()
{
}
// ----------------------------------- Label_Image<Exact>
template <typename Exact>
Label_Image<Exact>::Label_Image()
{
}
// ----------------------------------- Binary_Image<Exact>
template <typename Exact>
Binary_Image<Exact>::Binary_Image()
{
}
// ----------------------------------- String_Image<Exact>
template <typename Exact>
String_Image<Exact>::String_Image()
{
}
// ----------------------------------- Deformation_Field_Image<Exact>
template <typename Exact>
Deformation_Field_Image<Exact>::Deformation_Field_Image()
{
}
// ----------------------------------- Data_Image<Exact>
template <typename Exact>
Data_Image<Exact>::Data_Image()
{
}
# endif // OLN_INCLUDE_ONLY
} // end of namespace oln
......
......@@ -30,6 +30,7 @@
# include <oln/core/concept/image.hh>
# include <oln/core/2d/grid2d.hh>
# include <oln/value/tags.hh>
namespace oln
......@@ -136,6 +137,58 @@ namespace oln
};
// 6. value kind
typedef selector<Image, 6> Image_value_kind;
template <typename Exact>
struct case_< Image_value_kind, Exact, 1 >
:
where_< value::is_gray_level<stc_get_type(value)> >
{
typedef Gray_Level_Image<Exact> ret;
};
template <typename Exact>
struct case_< Image_value_kind, Exact, 2 >
:
where_< value::is_binary<stc_get_type(value)> >
{
typedef Binary_Image<Exact> ret;
};
template <typename Exact>
struct case_< Image_value_kind, Exact, 3 >
:
where_< value::is_string<stc_get_type(value)> >
{
typedef String_Image<Exact> ret;
};
template <typename Exact>
struct case_< Image_value_kind, Exact, 4 >
:
where_< value::is_label<stc_get_type(value)> >
{
typedef Label_Image<Exact> ret;
};
template <typename Exact>
struct case_< Image_value_kind, Exact, 5 >
:
where_< value::is_color<stc_get_type(value)> >
{
typedef Color_Image<Exact> ret;
};
// FIXME: Deformation_Field_Image
template <typename Exact>
struct default_case_< Image_value_kind, Exact >
{
typedef Data_Image<Exact> ret;
};
} // end of namespace oln::internal
......
......@@ -25,17 +25,11 @@
// 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_
#ifndef OLN_CORE_INTERNAL_MAX_VALUE_HH
# define OLN_CORE_INTERNAL_MAX_VALUE_HH
#include <cassert>
#include <limits>
# include <limits>
namespace oln
{
# define oln_max(T) std::numeric_limits< T >::max()
#define oln_max(T) std::numeric_limits<T>::max()
}
#endif /* !OLN_CORE_INTERNAL_MAX_VALUE_HH_ */
#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_CORE_INTERNAL_MIN_VALUE_HH
# define OLN_CORE_INTERNAL_MIN_VALUE_HH
# include <limits>
# define oln_min(T) std::numeric_limits< T >::min()
# endif // ! OLN_CORE_INTERNAL_MIN_VALUE_HH
......@@ -45,9 +45,9 @@ namespace oln
const Image_with_Nbh<I>& input,
const oln_point(I)& p);
template <typename F, typename I, typename W>
typename F::result
local(const Accumulator<F>& f,
template <typename A, typename I, typename W>
typename A::result
local(const Accumulator<A>& f,
const Image<I>& input,
const oln_point(I)& p,
const Window<W>& win);
......@@ -62,9 +62,9 @@ namespace oln
template <typename A, typename I>
typename A::result
local_(const A& f,
local_(const A& f,
const Image_with_Nbh<I>& input,
const oln_point(I)& p)
const oln_point(I)& p)
{
f.init_with(input(p));
oln_niter(I) n(p, input.nbhood()); // FIXME: 2nd arg should be 'input'!
......@@ -79,12 +79,12 @@ namespace oln
// Generic version with window.
template <typename F, typename I, typename W>
typename F::result
local_(const F& f,
const Image<I>& input,
const oln_point(I)& p,
const Window<W>& win)
template <typename A, typename I, typename W>
typename A::result
local_(const A& f,
const Image<I>& input,
const oln_point(I)& p,
const Window<W>& win)
{
f.init();
oln_qiter(W) q(p, win);
......@@ -107,9 +107,9 @@ namespace oln
return impl::local_(exact(f), input, p);
}
template <typename F, typename I, typename W>
typename F::result
local(const Accumulator<F>& f,
template <typename A, typename I, typename W>
typename A::result
local(const Accumulator<A>& f,
const Image<I>& input,
const oln_point(I)& p,
const Window<W>& win)
......
#ifndef OLN_MORPHOMATH_DILATATION_HH_
# define 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.
// Facade.
#ifndef OLN_MORPHO_DILATION_HH
# define OLN_MORPHO_DILATION_HH
namespace impl
{
#include <oln/level/apply_local.hh>
#include <oln/border/fill.hh>
#include <oln/accumulator/max.hh>
/// Generic version
template <typename I, typename W>
I dilatation(const Image<I>& input)
namespace morpho
{
max_<oln_value(I)> max;
return apply(max, input);
}
}
// Fwd decl.
template <typename I, typename W>
oln_plain(I)
dilation(const Image<I>& input, const Window<W>& win);
/// Facade.
template <typename I, typename W>
I erosion(const Image<I>& input)
{
return impl::dilatation(exact(input));
}
# ifndef OLN_INCLUDE_ONLY
#endif /* !OLN_MORPHOMATH_DILATATION_HH_ */
namespace impl
{
// Generic version.
template <typename I, typename W>
oln_plain(I)
elementary_dilation_(const Image<I>& input,
const Window<W>& win)
{
border::fill(input, oln_min(oln_value(I)));
accumulator::max_<oln_value(I)> max;
return level::apply_local(max, input, win);
}
// FIXME: Add a fast version.
} // end of namespace oln::morpho::impl
// Facade.
template <typename I, typename W>
oln_plain(I)
dilation(const Image<I>& input, const Window<W>& win)
{
return impl::dilation_(exact(input), exact(win));
}
# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln::morpho
} // end of namespace oln
#endif // ! OLN_MORPHO_DILATION_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_MORPHO_ELEMENTARY_DILATION_HH
# define OLN_MORPHO_ELEMENTARY_DILATION_HH
#include <oln/level/apply_local.hh>
#include <oln/border/fill.hh>
#include <oln/accumulator/max.hh>
namespace oln
{
namespace morpho
{
// Fwd decl.
template <typename I>
oln_plain(I)
elementary_dilation(const Image_with_Nbh<I>& input);
# ifndef OLN_INCLUDE_ONLY
namespace impl
{
// Generic version.
template <typename I>
oln_plain(I)
elementary_dilation_on_function_(const Image<I>&,
const I& input)
{
border::fill(input, oln_min(oln_value(I)));
accumulator::max_<oln_value(I)> max;
return level::apply_local(max, input);
}
template <typename I>
oln_plain(I)
elementary_dilation_on_set_(const Image<I>&,
const I&)
{
oln_plain(I) tmp;
std::cerr << "morpho::impl::elementary_dilation_on_set_ is not yet impled!" << std::endl;
return tmp;
}
// FIXME: Add a fast version.
// Impl facade.