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

Handle low quantization and fast properties.

	* tests/transform.cc: New.
	* tests/fill.cc: New.
	* mln/core/macros.hh (mln_value_kind, mln_vset): New.
	* mln/core/trait/is_fast.hh: New.
	* mln/core/trait/all.hh: New.
	* mln/core/trait/is_lowq.hh: New.
	* mln/core/internal/image_base.hh
	(select_image_concept_): New.
	* mln/core/concept/image.hh (vset, values): New.
	Update.
	* mln/core/concept/fast_image.hh (operator[]): New.
	* mln/metal/math.hh: New.
	* mln/metal/bool.hh: New.
	* mln/metal/bexpr.hh: New.
	* mln/value/lut_vec.hh: New.
	* mln/value/int_u.hh (nbits, card): New.

	* tests/README (g++-2.95): New hints.
	* tests/pixter_dpoint2d.cc: Fix warning.
	* tests/erosion.cc: Fix doc.
	* doc/Doxyfile.in: Update.
	* mln/debug/iota.hh: New overload.
	* mln/fun/pw_value.hh (function_): Rename as...
	(select_function_): ...this.
	* mln/core/trait/pixter.hh
	(pixter, qixter, nixter): Remove; obsolete.
	* mln/core/concept/value_set.hh (viter): Likewise.
	* mln/core/concept/doc/image.hh,
	* mln/core/concept/doc/value_set.hh,
	* mln/core/concept/doc/fast_image.hh: Update.
	* mln/core/image2d_b.hh: Update.
	* mln/metal/none.hh: Fix doc.
	* mln/morpho/erosion.hh: Update.
	* mln/level/fill.hh: Add todos.
	New overload.
	* mln/level/fast_median.hh: Fix doc.
	* mln/level/transform.hh: New overload.
	* mln/value/props.hh (min): Change to var.
	* mln/value/kind.hh: Fix doc.
	* mln/value/set.hh (viter): Remove; obsolete.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@1026 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent c5e09221
2007-07-20 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Handle low quantization and fast properties.
* tests/transform.cc: New.
* tests/fill.cc: New.
* mln/core/macros.hh (mln_value_kind, mln_vset): New.
* mln/core/trait/is_fast.hh: New.
* mln/core/trait/all.hh: New.
* mln/core/trait/is_lowq.hh: New.
* mln/core/internal/image_base.hh
(select_image_concept_): New.
* mln/core/concept/image.hh (vset, values): New.
Update.
* mln/core/concept/fast_image.hh (operator[]): New.
* mln/metal/math.hh: New.
* mln/metal/bool.hh: New.
* mln/metal/bexpr.hh: New.
* mln/value/lut_vec.hh: New.
* mln/value/int_u.hh (nbits, card): New.
* tests/README (g++-2.95): New hints.
* tests/pixter_dpoint2d.cc: Fix warning.
* tests/erosion.cc: Fix doc.
* doc/Doxyfile.in: Update.
* mln/debug/iota.hh: New overload.
* mln/fun/pw_value.hh (function_): Rename as...
(select_function_): ...this.
* mln/core/trait/pixter.hh
(pixter, qixter, nixter): Remove; obsolete.
* mln/core/concept/value_set.hh (viter): Likewise.
* mln/core/concept/doc/image.hh,
* mln/core/concept/doc/value_set.hh,
* mln/core/concept/doc/fast_image.hh: Update.
* mln/core/image2d_b.hh: Update.
* mln/metal/none.hh: Fix doc.
* mln/morpho/erosion.hh: Update.
* mln/level/fill.hh: Add todos.
New overload.
* mln/level/fast_median.hh: Fix doc.
* mln/level/transform.hh: New overload.
* mln/value/props.hh (min): Change to var.
* mln/value/kind.hh: Fix doc.
* mln/value/set.hh (viter): Remove; obsolete.
2007-07-20 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Clean-up and update pixel related material.
......
......@@ -1055,6 +1055,7 @@ PREDEFINED = \
"mln_fwd_viter(T)=typename T::fwd_viter" \
"mln_bkd_viter(T)=typename T::bkd_viter" \
"mln_value(T)=typename T::value" \
"mln_vset(T)=typename T::vset" \
"mln_rvalue(T)=typename T::rvalue" \
"mln_lvalue(T)=typename T::lvalue" \
"mln_coord(T)=typename T::coord" \
......
......@@ -51,7 +51,7 @@ namespace mln
/*! \brief Give the offset corresponding to the delta-point \p
* dp.
*
* \param[in] p A delta-point.
* \param[in] dp A delta-point.
*
* \pre The image has to be initialized.
*/
......@@ -69,7 +69,7 @@ namespace mln
/*! \brief Give the point at offset \p o.
*
* \param[in] p An offset.
* \param[in] o An offset.
*
* \pre The image has to be initialized.
* \pre o < ncells()
......@@ -85,6 +85,27 @@ namespace mln
*/
const value* buffer() const;
/*! \brief Read-only access to the image value at offset \p o.
*
* \param[in] o An offset.
*
* \pre o < ncells()
*
* \return The value at \p o (not assignable).
*/
rvalue operator[](unsigned o) const;
/*! \brief Read-write access to the image value at offset \p o.
*
* \param[in] o An offset.
*
* \pre o < ncells()
*
* \return The value at \p o (assignable).
*/
lvalue operator[](unsigned o);
};
} // end of namespace mln::doc
......
......@@ -56,6 +56,11 @@ namespace mln
*/
typedef void lvalue;
/*! \brief Value set associated type.
* \invariant This type has to derive from mln::Value_Set.
*/
typedef void vset;
/*! \brief Test if the image have been initialized.
*/
bool has_data() const;
......@@ -73,13 +78,19 @@ namespace mln
*/
const pset& domain() const;
/*! \brief Read access to the image value located at \p p.
/*! \brief Give the set of values of the image.
*
* \return A reference to the value set.
*/
const vset& values() const;
/*! \brief Read-only access to the image value located at \p p.
*
* \param[in] p A point site.
*
* \pre The image has to own the site \p p.
*
* \return The value at \p p.
* \return The value at \p p (not assignable).
*/
rvalue operator()(const psite& p) const;
......@@ -89,7 +100,7 @@ namespace mln
*
* \pre The image has to own the site \p p.
*
* \return The value at \p p.
* \return The value at \p p (assignable).
*/
lvalue operator()(const psite& p);
......
......@@ -46,10 +46,6 @@ namespace mln
*/
typedef void value;
/*! \brief Viter associated type.
*/
typedef void viter;
/*! \brief Forward Viter associated type.
*/
typedef void fwd_viter;
......
......@@ -33,7 +33,6 @@
*/
# include <mln/core/concept/image.hh>
# include <mln/core/trait/pixter.hh>
namespace mln
......@@ -55,6 +54,9 @@ namespace mln
point point_at_offset(unsigned o) const;
const value* buffer() const;
rvalue operator[](unsigned o) const;
lvalue operator[](unsigned o);
*/
protected:
......@@ -69,7 +71,6 @@ namespace mln
{
typedef mln_point(E) point;
typedef mln_dpoint(E) dpoint;
typedef mln_value(E) value;
typedef mln_fwd_pixter(E) fwd_pixter;
typedef mln_bkd_pixter(E) bkd_pixter;
......@@ -80,11 +81,22 @@ namespace mln
m2 = 0;
point (E::*m3)(unsigned) const = & E::point_at_offset;
m3 = 0;
const value* (E::*m4)() const = & E::buffer;
unsigned (E::*m4)() const = & E::border;
m4 = 0;
unsigned (E::*m5)() const = & E::border;
typedef mln_value(E) value;
const value* (E::*m5)() const = & E::buffer;
m5 = 0;
typedef mln_rvalue(E) rvalue;
typedef mln_lvalue(E) lvalue;
rvalue (E::*m6)(unsigned) const = & E::operator[];
m6 = 0;
lvalue (E::*m7)(unsigned) = & E::operator[];
m7 = 0;
// FIXME: how to check that qixter are defined when W is unknown!
}
......
......@@ -33,6 +33,7 @@
*/
# include <mln/core/concept/point_set.hh>
# include <mln/core/trait/all.hh>
namespace mln
......@@ -52,8 +53,10 @@ namespace mln
typedef value;
typedef rvalue;
typedef lvalue;
typedef vset;
bool has_data() const;
const vset& values() const;
bool owns_(const psite& p) const;
const pset& domain() const;
......@@ -138,4 +141,7 @@ namespace mln
} // end of namespace mln
# include <mln/core/concept/fast_image.hh>
#endif // ! MLN_CORE_CONCEPT_IMAGE_HH
......@@ -48,7 +48,6 @@ namespace mln
{
/*
typedef value;
typedef viter;
typedef fwd_viter;
typedef bkd_viter;
......@@ -71,7 +70,6 @@ namespace mln
Value_Set<E>::Value_Set()
{
typedef mln_value(E) value;
typedef mln_viter(E) viter;
typedef mln_fwd_viter(E) fwd_viter;
typedef mln_bkd_viter(E) bkd_viter;
......
......@@ -38,6 +38,7 @@
# include <mln/core/box2d.hh>
# include <mln/border/thickness.hh>
# include <mln/value/set.hh>
# include <mln/fun/all.hh>
......@@ -50,6 +51,23 @@
namespace mln
{
// Fwd decl.
template <typename T> struct image2d_b;
namespace trait
{
template <typename T>
struct is_fast< image2d_b<T> >
{
typedef metal::true_ ret;
};
} // end of mln::trait
/*! \brief Basic 2D image class.
*
* The parameter \c T is the type of pixel values. This image class
......@@ -71,6 +89,7 @@ namespace mln
// end of warning
// FIXME:
// /// Forward pixel iterator associated to image2d
......@@ -99,6 +118,9 @@ namespace mln
typedef image2d_b<U> ret;
};
/// Value_Set associated type.
typedef mln::value::set_<T> vset;
/// Constructor without argument.
image2d_b();
......@@ -134,6 +156,9 @@ namespace mln
/// Test if this image has been initialized.
bool has_data() const;
/// Give the set of values of the image.
const vset& values() const;
/// Give the definition domain.
const box2d& domain() const;
......@@ -143,12 +168,18 @@ namespace mln
/// Give the number of cells (points including border ones).
std::size_t ncells() const;
/// Read-only access to the image value located at \p p.
/// Read-only access to the image value located at point \p p.
const T& operator()(const point2d& p) const;
/// Read-write access to the image value located at \p p.
/// Read-write access to the image value located at point \p p.
T& operator()(const point2d& p);
/// Read-only access to the image value located at offset \p o.
const T& operator[](unsigned o) const;
/// Read-write access to the image value located at offset \p o.
T& operator[](unsigned o);
/// Read-only access to the image value located at (\p row, \p col).
const T& at(int row, int col) const;
......@@ -278,6 +309,13 @@ namespace mln
return buffer_ != 0 && array_ != 0;
}
template <typename T>
const typename image2d_b<T>::vset&
image2d_b<T>::values() const
{
return vset::the();
}
template <typename T>
const box2d&
image2d_b<T>::domain() const
......@@ -326,6 +364,22 @@ namespace mln
return array_[p.row()][p.col()];
}
template <typename T>
const T&
image2d_b<T>::operator[](unsigned o) const
{
mln_precondition(o < ncells());
return *(buffer_ + o);
}
template <typename T>
T&
image2d_b<T>::operator[](unsigned o)
{
mln_precondition(o < ncells());
return *(buffer_ + o);
}
template <typename T>
const T&
image2d_b<T>::at(int row, int col) const
......@@ -380,7 +434,6 @@ namespace mln
image2d_b<T>::point_at_offset(unsigned o) const
{
mln_precondition(o < ncells());
mln_precondition(this->has_data());
point2d p = make::point2d(o / vb_.len(1) + vb_.min_row(),
o % vb_.len(1) + vb_.min_col());
mln_postcondition(& this->operator()(p) == this->buffer_ + o);
......@@ -461,6 +514,12 @@ namespace mln
typedef fwd_pixter2d_b< image2d_b<T> > ret;
};
template <typename T>
struct fwd_pixter< const image2d_b<T> >
{
typedef fwd_pixter2d_b< const image2d_b<T> > ret;
};
template <typename T>
struct bkd_pixter< image2d_b<T> >
{
......
......@@ -42,12 +42,30 @@ namespace mln
namespace internal
{
template <typename Is_fast, typename E>
struct select_image_concept_;
template <typename E>
struct select_image_concept_< metal::true_, E >
: public Fast_Image<E>
{};
template <typename E>
struct select_image_concept_< metal::false_, E >
: public Image<E>
{};
/*! \brief A base class for images.
*
* \internal
*/
template <typename S, typename E>
struct image_base_ : public Image<E>
struct image_base_ : public select_image_concept_< typename trait::is_fast<E>::ret,
E >
{
/// Point_Set associated type.
typedef S pset;
......
......@@ -105,14 +105,14 @@
// p
/// Shortcut to access the piter type associated to T.
/// Shortcut to access the type of point iterator (piter) associated to T.
# define mln_piter(T) typename T::fwd_piter
# define mln_piter_(T) T::fwd_piter
/// Shortcut to access the pset type associated to T.
/// Shortcut to access the type of point set (pset) associated to T.
# define mln_pset(T) typename T::pset
/// Shortcut to access the psite type associated to T.
/// Shortcut to access the type of point site (psite) associated to T.
# define mln_psite(T) typename T::psite
/// Shortcut to access the point type associated to T.
......@@ -145,6 +145,12 @@
/// Shortcut to access the value type associated to T.
# define mln_value(T) typename T::value
/// Shortcut to the kind of values for an image with type \c I.
# define mln_value_kind(T) typename mln::value::props< mln_value(I) >::kind
/// Shortcut to access the type of value set (vset) associated to T.
# define mln_vset(T) typename T::vset
/// Shortcut to access the viter type associated to T.
# define mln_viter(T) typename T::fwd_viter
......
......@@ -42,6 +42,7 @@ namespace mln
// FIXME: ...
} // end of namespace mln::core
} // end of namespace mln
......
// 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_CORE_TRAIT_ALL_HH
# define MLN_CORE_TRAIT_ALL_HH
/*! \file mln/core/trait/all.hh
*
* \brief File that includes all traits.
*/
namespace mln
{
/*! Namespace for image traits.
*/
namespace trait {}
}
# include <mln/core/trait/is_fast.hh>
# include <mln/core/trait/is_lowq.hh>
# include <mln/core/trait/pixter.hh>
#endif // ! MLN_CORE_TRAIT_ALL_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_CORE_TRAIT_IS_FAST_HH
# define MLN_CORE_TRAIT_IS_FAST_HH
/*! \file mln/core/trait/is_fast.hh
*
* \brief Definition of the is_fast image trait.
*/
# include <mln/metal/bool.hh>
namespace mln
{
namespace trait
{
// FIXME: Doc!
template <typename I>
struct is_fast
{
typedef metal::false_ ret;
};
} // end of namespace mln::trait
} // end of namespace mln
#endif // ! MLN_CORE_TRAIT_IS_FAST_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_CORE_TRAIT_IS_LOWQ_HH
# define MLN_CORE_TRAIT_IS_LOWQ_HH
/*! \file mln/core/trait/is_lowq.hh
*
* \brief Definition of the is_lowq image trait.
*/
# include <mln/metal/bool.hh>
# include <mln/value/props.hh>
# define mln_is_lowq(I) typename mln::trait::is_lowq< I >::ret
namespace mln
{
namespace trait
{
// FIXME: Doc!
template <typename I>
struct is_lowq
{
typedef typename metal::bool_<( mln_card(mln_value(I)) != 0 )>::type ret;
};
} // end of namespace mln::trait
} // end of namespace mln