Olena-patches
Threads by month
- ----- 2025 -----
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
April 2004
- 8 participants
- 59 discussions
Index: olena/ChangeLog
from Simon Odou <simon(a)lrde.epita.fr>
* oln/core/image1d.hh: Add informations to image_id.
* oln/core/image2d.hh: Likewise
* oln/core/image3d.hh: Likewise
* oln/core/impl/image_array1d.hh: Add empty constructor for
any_with_diamond.
* oln/core/impl/image_array.hh: Likewise.
* oln/core/impl/image_array2d.hh: Likewise.
* oln/core/impl/image_array3d.hh: Likewise.
* oln/core/impl/image_impl.hh: Likewise.
* oln/core/abstract/image_size.hh: Likewise.
* oln/core/image1d_size.hh: Likewise.
* oln/core/image2d_size.hh: Likewise.
* oln/core/image3d_size.hh: Likewise.
* tests/morpher/tests/piece: New.
* tests/morpher/tests/iter: New.
* tests/morpher/tests/slicing: New.
* oln/core/abstract/image.hh: Size() returns const inside of
const &.
* oln/morpher/piece_morpher.hh: Adapt to new version of generic
morpher.
Respect 80 columns.
* oln/morpher/slicing_morpher.hh: Likewise.
* oln/morpher/iter_morpher.hh: Likewise.
Better example for documentation.
* oln/Makefile.am: Add files.
* oln/morpher/generic_morpher.hh: Fix a bug.
Index: olena/oln/core/image1d.hh
--- olena/oln/core/image1d.hh Fri, 02 Apr 2004 16:00:03 +0200 van-vl_n (oln/c/47_image1d.hh 1.28.1.3 600)
+++ olena/oln/core/image1d.hh Sun, 04 Apr 2004 16:26:06 +0200 odou_s (oln/c/47_image1d.hh 1.28.1.4 600)
@@ -57,6 +57,8 @@
typedef T value_type;
typedef typename mlc::exact_vt<image1d<T, Exact>, Exact>::ret exact_type;
typedef impl::image_array1d<T> impl_type;
+ typedef point1d point_type;
+ typedef image1d_size size_type;
};
/*! \class image_traits<image1d<T, Exact> >
Index: olena/oln/core/image1d_size.hh
--- olena/oln/core/image1d_size.hh Fri, 12 Mar 2004 20:17:58 +0100 thivol_d (oln/c/46_image1d_si 1.11 600)
+++ olena/oln/core/image1d_size.hh Sun, 04 Apr 2004 16:26:13 +0200 odou_s (oln/c/46_image1d_si 1.12 600)
@@ -70,6 +70,9 @@
border_ = border;
}
+ image1d_size()
+ {}
+
/// Return the number of columns in the image.
coord
Index: olena/oln/core/image2d.hh
--- olena/oln/core/image2d.hh Fri, 02 Apr 2004 16:00:03 +0200 van-vl_n (oln/c/45_image2d.hh 1.30.1.3 600)
+++ olena/oln/core/image2d.hh Sun, 04 Apr 2004 16:26:21 +0200 odou_s (oln/c/45_image2d.hh 1.30.1.4 600)
@@ -57,6 +57,8 @@
typedef T value_type;
typedef typename mlc::exact_vt<image2d<T, Exact>, Exact>::ret exact_type;
typedef impl::image_array2d<T> impl_type;
+ typedef point2d point_type;
+ typedef image2d_size size_type;
};
/*! \class image_traits<image2d<T, Exact> >
Index: olena/oln/core/image2d_size.hh
--- olena/oln/core/image2d_size.hh Fri, 12 Mar 2004 20:17:58 +0100 thivol_d (oln/c/44_image2d_si 1.11 600)
+++ olena/oln/core/image2d_size.hh Sun, 04 Apr 2004 16:26:36 +0200 odou_s (oln/c/44_image2d_si 1.12 600)
@@ -74,6 +74,9 @@
border_ = border;
}
+ image2d_size()
+ {}
+
/// Return the number of rows in the image.
coord
Index: olena/oln/core/image3d.hh
--- olena/oln/core/image3d.hh Fri, 02 Apr 2004 16:00:03 +0200 van-vl_n (oln/c/43_image3d.hh 1.27.1.3 600)
+++ olena/oln/core/image3d.hh Sun, 04 Apr 2004 16:26:27 +0200 odou_s (oln/c/43_image3d.hh 1.27.1.4 600)
@@ -57,6 +57,8 @@
typedef T value_type;
typedef typename mlc::exact_vt<image3d<T, Exact>, Exact>::ret exact_type;
typedef impl::image_array3d<T> impl_type;
+ typedef point3d point_type;
+ typedef image3d_size size_type;
};
/*! \class image_traits<image3d<T, Exact> >
Index: olena/oln/core/image3d_size.hh
--- olena/oln/core/image3d_size.hh Fri, 12 Mar 2004 20:17:58 +0100 thivol_d (oln/c/42_image3d_si 1.11 600)
+++ olena/oln/core/image3d_size.hh Sun, 04 Apr 2004 16:26:31 +0200 odou_s (oln/c/42_image3d_si 1.12 600)
@@ -80,6 +80,9 @@
border_ = border;
}
+ image3d_size()
+ {}
+
/// Return the number of slices in the image.
coord
Index: olena/oln/core/abstract/image_size.hh
--- olena/oln/core/abstract/image_size.hh Thu, 11 Mar 2004 17:12:19 +0100 thivol_d (oln/c/41_image_size 1.11 600)
+++ olena/oln/core/abstract/image_size.hh Sun, 04 Apr 2004 16:26:57 +0200 odou_s (oln/c/41_image_size 1.12 600)
@@ -158,12 +158,11 @@
Exact::name() + ">";
}
- protected:
-
-
image_size()
{}
+ protected:
+
/*! border_ represents the width of the image border
** such a mecanism allow algorithm to perform operation
** on the points at the edge of the image as if they were
Index: olena/oln/Makefile.am
--- olena/oln/Makefile.am Sat, 03 Apr 2004 23:02:21 +0200 thivol_d (oln/q/47_Makefile.a 1.3.1.1.1.6.1.7.1.5 600)
+++ olena/oln/Makefile.am Sun, 04 Apr 2004 16:27:17 +0200 odou_s (oln/q/47_Makefile.a 1.3.1.1.1.6.1.7.1.6 600)
@@ -148,6 +148,9 @@
math/macros.hh \
morpher/color_morpher.hh \
morpher/generic_morpher.hh \
+ morpher/iter_morpher.hh \
+ morpher/piece_morpher.hh \
+ morpher/slicing_morpher.hh \
morpher/subq_morpher.hh \
morpho/attribute_closing_opening.hh \
morpho/attribute_closing_opening_map.hxx \
Index: olena/oln/core/abstract/image.hh
--- olena/oln/core/abstract/image.hh Fri, 26 Mar 2004 12:53:24 +0100 thivol_d (oln/t/25_image.hh 1.29 600)
+++ olena/oln/core/abstract/image.hh Sun, 04 Apr 2004 16:27:23 +0200 odou_s (oln/t/25_image.hh 1.30 600)
@@ -178,11 +178,11 @@
/// Return a reference to the image size.
- const size_type&
+ const size_type
size() const
{
assertion(has_impl());
- return this->exact().impl()->size();
+ return this->exact().size();
}
/// Return the value of the border width.
Index: olena/oln/core/impl/image_impl.hh
--- olena/oln/core/impl/image_impl.hh Sun, 14 Mar 2004 19:03:34 +0100 van-vl_n (oln/t/29_image_impl 1.18 600)
+++ olena/oln/core/impl/image_impl.hh Sun, 04 Apr 2004 16:28:17 +0200 odou_s (oln/t/29_image_impl 1.19 600)
@@ -81,6 +81,7 @@
image_impl(const size_type s): refcount_(0), size_(s) {}
+ image_impl() {}
/// Notice that there is a new reference to the object.
Index: olena/oln/core/impl/image_array.hh
--- olena/oln/core/impl/image_array.hh Mon, 15 Mar 2004 17:40:54 +0100 van-vl_n (oln/t/30_image_arra 1.16 600)
+++ olena/oln/core/impl/image_array.hh Sun, 04 Apr 2004 16:28:29 +0200 odou_s (oln/t/30_image_arra 1.17 600)
@@ -121,6 +121,9 @@
allocate_data_(buffer_, len(s));
}
+ image_array() : buffer_(0)
+ {}
+
image_array(const self_type&); // cpy ctor w/o impl
void
@@ -169,6 +172,7 @@
~image_array()
{
+ if (buffer_)
desallocate_data_(buffer_);
}
Index: olena/oln/core/impl/image_array3d.hh
--- olena/oln/core/impl/image_array3d.hh Fri, 12 Mar 2004 20:17:58 +0100 thivol_d (oln/t/32_image_arra 1.11 600)
+++ olena/oln/core/impl/image_array3d.hh Sun, 04 Apr 2004 16:28:41 +0200 odou_s (oln/t/32_image_arra 1.12 600)
@@ -134,8 +134,11 @@
pretreat_3d_data_(this->buffer_, array2_, array_, s);
}
+ image_array3d() : array_(0) {}
+
~image_array3d()
{
+ if (array_)
desallocate_3d_data_(array2_, array_, this->size_);
}
Index: olena/oln/core/impl/image_array2d.hh
--- olena/oln/core/impl/image_array2d.hh Mon, 29 Mar 2004 15:45:23 +0200 palma_g (oln/t/33_image_arra 1.13 600)
+++ olena/oln/core/impl/image_array2d.hh Sun, 04 Apr 2004 16:28:38 +0200 odou_s (oln/t/33_image_arra 1.14 600)
@@ -122,8 +122,11 @@
pretreat_2d_data_(this->buffer_, array_, s);
}
+ image_array2d() : array_(0) {}
+
~image_array2d()
{
+ if (array_)
desallocate_2d_data_(array_, this->size_);
}
Index: olena/oln/core/impl/image_array1d.hh
--- olena/oln/core/impl/image_array1d.hh Fri, 12 Mar 2004 20:17:58 +0100 thivol_d (oln/t/34_image_arra 1.13 600)
+++ olena/oln/core/impl/image_array1d.hh Sun, 04 Apr 2004 16:28:34 +0200 odou_s (oln/t/34_image_arra 1.14 600)
@@ -99,6 +99,8 @@
pretreat_1d_data_(this->buffer_, buffer__, s);
}
+ image_array1d() {}
+
~image_array1d() {}
protected:
Index: olena/oln/morpher/piece_morpher.hh
--- olena/oln/morpher/piece_morpher.hh Mon, 29 Mar 2004 09:26:50 +0200 odou_s (oln/m/40_piece_morp 1.1 600)
+++ olena/oln/morpher/piece_morpher.hh Sun, 04 Apr 2004 16:29:01 +0200 odou_s (oln/m/40_piece_morp 1.2 600)
@@ -36,31 +36,51 @@
template <class I, class Exact = mlc::final>
struct piece_morpher;
+ template <class I, class Exact = mlc::final>
+ struct super_piece_morpher;
} // end of namespace morpher
- /// Inherits identification's informations about the piece morpher.
- template <class I, class Exact>
- struct image_id< morpher::piece_morpher<I, Exact> > : public image_id<I>
- {};
+ /// Informations about the super piece morpher.
+ template <class SrcType, class Exact>
+ struct image_id< morpher::super_piece_morpher<SrcType, Exact> >
+ {
+ typedef typename mlc::exact_vt<
+ morpher::super_piece_morpher<SrcType, Exact>,
+ Exact>::ret
+ exact_type;
+ ///< Retrieve the exact type of the image.
+ };
- /// Inherits identification's informations about the const piece morpher.
- template <class I, class Exact>
- struct image_id< morpher::piece_morpher<const I, Exact> > : public image_id<I>
- {};
+ /// Informations about the piece morpher.
+ template <class SrcType, class Exact>
+ struct image_id< morpher::piece_morpher<SrcType, Exact> >
+ {
+ enum {dim = SrcType::dim}; ///< The Image dimension.
+ typedef oln_impl_type(SrcType) impl_type;
+ ///< Underlying implementation.
+ typedef oln_value_type(SrcType) value_type;
+ ///< The value type of the decorated image.
+ typedef typename mlc::exact_vt<morpher::piece_morpher<SrcType, Exact>,
+ Exact>::ret exact_type;
+ ///< Retrieve the exact type of the image.
+ typedef oln_point_type(SrcType) point_type;
+ typedef oln_dpoint_type(SrcType) dpoint_type;
+ typedef oln_size_type(SrcType) size_type;
+ typedef oln_iter_type(SrcType) iter_type;
+ };
/// Traits for piece morpher.
- template <class I>
- struct image_traits < morpher::piece_morpher<I> > :
- public image_traits<abstract::image_with_impl<oln_impl_type(I),
- morpher::piece_morpher<I> > >
- {};
-
- /// Traits for const piece morpher.
- template <class I>
- struct image_traits < morpher::piece_morpher<const I> > :
- public image_traits<abstract::image_with_impl<oln_impl_type(I),
- morpher::piece_morpher<const I> > >
+ template <class SrcType, class Exact>
+ struct image_traits < morpher::piece_morpher<SrcType, Exact> >
+ : public
+ image_traits<
+ morpher::abstract::generic_morpher<
+ SrcType,
+ typename image_id<morpher::piece_morpher<SrcType,
+ Exact> >::exact_type
+ >
+ >
{};
@@ -68,13 +88,18 @@
/// Abstract piece morpher class used for code factorization.
template <class SrcType, class Exact>
- class super_piece_morpher : public abstract::generic_morpher<SrcType, SrcType, Exact>
+ class super_piece_morpher
+ : public abstract::generic_morpher<SrcType, Exact>
{
+
public:
- typedef abstract::generic_morpher<SrcType, SrcType, Exact> super_type;
- typedef oln_dpoint_type(SrcType) dpoint_type;
- typedef oln_size_type(SrcType) size_type;
+ typedef super_piece_morpher<SrcType, Exact> self_type;
+ typedef typename image_id<self_type>::exact_type exact_type;
+ typedef abstract::generic_morpher<SrcType, Exact> super_type;
+
+ typedef typename image_id<exact_type>::dpoint_type dpoint_type;
+ typedef typename image_id<exact_type>::size_type size_type;
protected:
@@ -93,31 +118,36 @@
{}
const size_type size_; ///< The size of the piece of picture.
- const dpoint_type p_; ///< The reference point of the piece of picture.
+ const dpoint_type p_;
+ ///< The reference point of the piece of picture.
/*!
** \brief Empty constructor.
**
** Needed by mlc_hierarchy::any_with_diamond.
*/
- super_piece_morpher() : size_(size_) {}
+ super_piece_morpher()
+ {}
public:
/// Return the size (different from the original picture).
- const size_type size() const
+ const size_type
+ size() const
{
return size_;
}
/// Return the reference point.
- const dpoint_type ref_point() const
+ const dpoint_type
+ ref_point() const
{
return p_;
}
/// Useful to debug.
- static std::string name()
+ static std::string
+ name()
{
return "super_piece_morpher<" + super_type::name() + ">";
}
@@ -134,17 +164,19 @@
*/
template <class SrcType, class Exact>
struct piece_morpher
- : public super_piece_morpher<SrcType, piece_morpher<SrcType, Exact> >
+ : public super_piece_morpher<
+ SrcType,
+ typename image_id<piece_morpher<SrcType, Exact> >::exact_type
+ >
{
- /// The type of the object instantiated. piece morpher can be derived.
- typedef typename image_id<piece_morpher<SrcType, Exact> >::exact_type exact_type;
typedef piece_morpher<SrcType, Exact> self_type;
- typedef super_piece_morpher<SrcType, piece_morpher<SrcType, Exact> > super_type;
+ typedef typename image_id<self_type>::exact_type exact_type;
+ typedef super_piece_morpher<SrcType, exact_type> super_type;
- typedef oln_point_type(SrcType) point_type;
- typedef oln_dpoint_type(SrcType) dpoint_type;
- typedef oln_size_type(SrcType) size_type;
- typedef oln_value_type(SrcType) value_type;
+ typedef typename image_id<exact_type>::point_type point_type;
+ typedef typename image_id<exact_type>::dpoint_type dpoint_type;
+ typedef typename image_id<exact_type>::size_type size_type;
+ typedef typename image_id<exact_type>::value_type value_type;
/// Construct the piece morpher with an image \a ima.
piece_morpher(const SrcType &ima, const dpoint_type p,
@@ -170,9 +202,11 @@
** \arg p The point.
** \return The stored value.
*/
- value_type& at(const point_type& p)
+ value_type&
+ at(const point_type& p)
{
- return const_cast<value_type &>(this->ima_)[p + p_];
+ return const_cast<value_type &>
+ ( const_cast<SrcType &>(this->ima_)[p + p_] );
}
/*!
@@ -180,7 +214,8 @@
** \arg p The point.
** \return The stored value.
*/
- const value_type at(const point_type& p) const
+ const value_type
+ at(const point_type& p) const
{
return this->ima_[p + p_];
}
@@ -209,27 +244,31 @@
}
/// Useful to debug.
- static std::string name()
+ static std::string
+ name()
{
return "piece_morpher<" + super_type::name() + ">";
}
};
- /// The specialized version for `const' declared images.
+ /// The specialized version for `const' images.
template <class SrcType, class Exact>
struct piece_morpher<const SrcType, Exact>
- : public super_piece_morpher< SrcType, piece_morpher<const SrcType, Exact> >
+ : public super_piece_morpher<
+ const SrcType,
+ typename image_id<piece_morpher<const SrcType,
+ Exact> >::exact_type
+ >
{
- /// The type of the object instantiated. piece morpher can be derived.
- typedef typename image_id<piece_morpher<SrcType, Exact> >::exact_type exact_type;
typedef piece_morpher<const SrcType, Exact> self_type;
- typedef super_piece_morpher<SrcType, piece_morpher<const SrcType, Exact> > super_type;
+ typedef typename image_id<self_type>::exact_type exact_type;
+ typedef super_piece_morpher<const SrcType, exact_type> super_type;
- typedef oln_point_type(SrcType) point_type;
- typedef oln_dpoint_type(SrcType) dpoint_type;
- typedef oln_size_type(SrcType) size_type;
- typedef oln_value_type(SrcType) value_type;
+ typedef typename image_id<exact_type>::point_type point_type;
+ typedef typename image_id<exact_type>::dpoint_type dpoint_type;
+ typedef typename image_id<exact_type>::size_type size_type;
+ typedef typename image_id<exact_type>::value_type value_type;
/*!
** \brief Construct a piece morpher.
@@ -259,13 +298,15 @@
** \arg p The point.
** \return The stored value.
*/
- const value_type at(const point_type &p) const
+ const value_type
+ at(const point_type &p) const
{
return this->ima_[p + p_];
}
/// Useful to debug.
- static std::string name()
+ static std::string
+ name()
{
return "piece_morpher<" + super_type::name() + ">";
}
@@ -290,7 +331,8 @@
** oln::image2d<ntg::rgb_8> imc = oln::load(IMG_IN "lena.ppm");
** oln::save(oln::morpher::piece_morph(imc,
** oln::dpoint2d(246, 244),
- ** oln::image2d_size(30, 60, imc.border())),
+ ** oln::image2d_size(30, 60,
+ ** imc.border())),
** IMG_OUT "oln_morpher_piece_morpher.pgm");
** }
** \endcode
@@ -301,7 +343,8 @@
** \image latex oln_morpher_piece_morpher.png
*/
template <class I, class PointType, class SizeType>
- const piece_morpher<I> piece_morph(I &ima, const PointType p, const SizeType s)
+ const piece_morpher<I>
+ piece_morph(I &ima, const PointType p, const SizeType s)
{
return piece_morpher<I>(ima, p, s);
}
Index: olena/oln/morpher/iter_morpher.hh
--- olena/oln/morpher/iter_morpher.hh Mon, 29 Mar 2004 09:31:34 +0200 odou_s (oln/m/41_iter_morph 1.1 600)
+++ olena/oln/morpher/iter_morpher.hh Sun, 04 Apr 2004 16:29:10 +0200 odou_s (oln/m/41_iter_morph 1.2 600)
@@ -25,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef ITER_MORPHER_HH
-# define ITER_MORPHER_HH
+#ifndef OLN_MORPHER_ITER_MORPHER_HH
+# define OLN_MORPHER_ITER_MORPHER_HH
# include <oln/morpher/generic_morpher.hh>
@@ -39,30 +39,38 @@
} // end of namespace morpher
- /// Inherits identification's informations about the iter morpher.
+ /// Informations about the iter morpher.
template <class SrcType, class IterType, class Exact>
- struct image_id< morpher::iter_morpher<SrcType, IterType, Exact> > : public image_id<SrcType>
- {};
-
- /// Inherits identification's informations about the const iter morpher.
- template <class SrcType, class IterType, class Exact>
- struct image_id< morpher::iter_morpher<const SrcType, IterType, Exact> > : public image_id<SrcType>
- {};
-
- /// Traits for iter morpher.
- template <class SrcType, class IterType>
- struct image_traits < morpher::iter_morpher<SrcType, IterType> > :
- public image_traits<abstract::image_with_impl<oln_impl_type(SrcType),
- morpher::iter_morpher<SrcType, IterType> > >
+ struct image_id< morpher::iter_morpher<SrcType, IterType, Exact> >
{
+ enum {dim = SrcType::dim}; ///< The Image dimension.
+ typedef oln_impl_type(SrcType) impl_type;
+ ///< Underlying implementation.
+ typedef oln_value_type(SrcType) value_type;
+ ///< The value type of the decorated image.
+ typedef typename mlc::exact_vt<
+ morpher::iter_morpher<SrcType, IterType, Exact>,
+ Exact
+ >::ret exact_type;
+ ///< Retrieve the exact type of the image.
+ typedef oln_point_type(SrcType) point_type;
+ typedef oln_dpoint_type(SrcType) dpoint_type;
+ typedef oln_size_type(SrcType) size_type;
typedef IterType iter_type;
};
- /// Traits for const iter morpher.
- template <class SrcType, class IterType>
- struct image_traits < morpher::iter_morpher<const SrcType, IterType> > :
- public image_traits<abstract::image_with_impl<oln_impl_type(SrcType),
- morpher::iter_morpher<const SrcType, IterType> > >
+ /// Traits for iter morpher.
+ template <class SrcType, class IterType, class Exact>
+ struct image_traits < morpher::iter_morpher<SrcType, IterType, Exact> >
+ : public
+ image_traits<
+ morpher::abstract::generic_morpher<
+ SrcType,
+ typename image_id<morpher::iter_morpher<SrcType,
+ IterType,
+ Exact> >::exact_type
+ >
+ >
{
typedef IterType iter_type;
};
@@ -71,13 +79,20 @@
template <class SrcType, class IterType, class Exact>
struct iter_morpher
- : public abstract::generic_morpher< SrcType, SrcType, iter_morpher<SrcType, IterType, Exact> >
+ : public abstract::generic_morpher<
+ SrcType,
+ typename image_id<iter_morpher<SrcType,
+ IterType,
+ Exact> >::exact_type
+ >
{
- /// The type of the object instantiated. iter morpher can be derived.
- typedef typename image_id< iter_morpher<SrcType, IterType, Exact> >::exact_type exact_type;
typedef iter_morpher<SrcType, IterType, Exact> self_type;
- typedef IterType iter_type;
- typedef abstract::generic_morpher< SrcType, SrcType, iter_morpher<SrcType, IterType, Exact> > super_type;
+ typedef typename image_id<self_type>::exact_type exact_type;
+ typedef abstract::generic_morpher<SrcType, exact_type> super_type;
+
+ typedef typename image_id<exact_type>::iter_type iter_type;
+ typedef typename image_id<exact_type>::value_type value_type;
+ typedef typename image_id<exact_type>::point_type point_type;
/// Construct the iter morpher with an image \a ima.
iter_morpher(const SrcType &ima)
@@ -110,8 +125,32 @@
return this->exact();
}
+ /*!
+ ** \brief Return the stored value at the point.
+ ** \arg p The point.
+ ** \return The stored value.
+ */
+ value_type&
+ at(const point_type& p)
+ {
+ return const_cast<value_type &>
+ ( const_cast<SrcType &>(this->ima_)[p] );
+ }
+
+ /*!
+ ** \brief Return the stored value at the point.
+ ** \arg p The point.
+ ** \return The stored value.
+ */
+ const value_type
+ at(const point_type& p) const
+ {
+ return this->ima_[p];
+ }
+
/// Useful to debug.
- static std::string name()
+ static std::string
+ name()
{
return "iter_morpher<" + super_type::name() + ">";
}
@@ -121,13 +160,22 @@
/// The specialized version for `const' declared images.
template <class SrcType, class IterType, class Exact>
struct iter_morpher<const SrcType, IterType, Exact>
- : public abstract::generic_morpher< SrcType, SrcType, iter_morpher<const SrcType, IterType, Exact> >
+ : public
+ abstract::generic_morpher<
+ const SrcType,
+ typename image_id<iter_morpher<const SrcType,
+ IterType,
+ Exact> >::exact_type
+ >
{
- /// The type of the object instantiated. iter morpher can be derived.
- typedef typename image_id< iter_morpher<SrcType, IterType, Exact> >::exact_type exact_type;
typedef iter_morpher<const SrcType, IterType, Exact> self_type;
- typedef IterType iter_type;
- typedef abstract::generic_morpher<SrcType, SrcType, iter_morpher<const SrcType, IterType, Exact> > super_type;
+ typedef typename image_id<self_type>::exact_type exact_type;
+ typedef abstract::generic_morpher<const SrcType, exact_type>
+ super_type;
+
+ typedef typename image_id<exact_type>::iter_type iter_type;
+ typedef typename image_id<exact_type>::value_type value_type;
+ typedef typename image_id<exact_type>::point_type point_type;
/// Construct the iter morpher with an image \a ima.
iter_morpher(const SrcType &ima)
@@ -135,19 +183,45 @@
{}
/// Construct the iter morpher with another iter morpher.
- iter_morpher(const iter_morpher<const SrcType, IterType>& r)
- : super_type(r.get_ima()) {}
+ iter_morpher(const self_type& r)
+ : super_type(r.get_ima())
+ {}
/*!
** \brief Empty constructor.
**
** Needed by mlc_hierarchy::any_with_diamond.
*/
- iter_morpher()
- {}
+ iter_morpher() {}
+
+ /*! Perform a shallow copy from the decorated image of \a rhs
+ ** to the current decorated image. The points will be shared
+ ** by the two images.
+ */
+ self_type&
+ assign(self_type& rhs)
+ {
+ oln_iter_type(SrcType) it(rhs);
+
+ for_all(it)
+ this->at(it) = rhs[it];
+ return this->exact();
+ }
+
+ /*!
+ ** \brief Return the stored value at the point.
+ ** \arg p The point.
+ ** \return The stored value.
+ */
+ const value_type
+ at(const point_type& p) const
+ {
+ return this->ima_[p];
+ }
/// Useful to debug.
- static std::string name()
+ static std::string
+ name()
{
return "iter_morpher<" + super_type::name() + ">";
}
@@ -158,33 +232,45 @@
** \brief Instantiate a temporary read-only iter morpher.
**
** The image will be viewed according to its iterator type.
- ** For example, the foo function will print the size of the picture
- ** (the bkd_iter_type is used transparently).
+ ** So the resulting image will be reversed.
**
** \code
** #include <oln/morpher/iter_morpher.hh>
** #include <oln/basics2d.hh>
** #include <ntg/all.hh>
- ** template <class E>
- ** void foo(const oln::abstract::image<E>& img)
+ ** template <class E, class F>
+ ** void foo(const oln::abstract::image<E>& src,
+ ** oln::abstract::image<F>& dst)
** {
- ** oln_iter_type(oln::abstract::image<E>) it(img);
- ** for_all(it)
+ ** oln_iter_type(oln::abstract::image<E>) it_src(src);
+ ** oln_iter_type(oln::abstract::image<F>) it_dst(dst);
+ **
+ ** it_dst = mlc::begin;
+ ** for_all(it_src)
** {
- ** std::cout << it.row() << " " << it.col() << std::endl;
- ** break;
+ ** dst[it_dst] = src[it_src];
+ ** ++it_dst;
** }
** }
** int main()
** {
- ** const oln::image2d<ntg::rgb_8> imc = oln::load(IMG_IN "lena.ppm");
- ** assert(imc.has_impl());
- ** foo(oln::morpher::iter_morph<oln_bkd_iter_type_(oln::image2d<ntg::rgb_8>)>(imc));
+ ** const oln::image2d<ntg::rgb_8> im = oln::load(IMG_IN "lena.ppm");
+ ** oln::image2d<ntg::rgb_8> im_out(im.size());
+ **
+ ** foo(oln::morpher::iter_morph<
+ ** oln_bkd_iter_type_(oln::image2d<ntg::rgb_8>)>(im), im_out);
+ ** oln::save(im_out, IMG_OUT "oln_morpher_iter.pgm");
** }
** \endcode
+ ** \image html lena_ppm.png
+ ** \image latex lena_ppm.png
+ ** =>
+ ** \image html oln_morpher_iter.png
+ ** \image latex oln_morpher_iter.png
*/
template <class IterType, class I>
- const iter_morpher<I, IterType> iter_morph(I &ima)
+ const iter_morpher<I, IterType>
+ iter_morph(I &ima)
{
return iter_morpher<I, IterType>(ima);
}
Index: olena/oln/morpher/slicing_morpher.hh
--- olena/oln/morpher/slicing_morpher.hh Mon, 29 Mar 2004 11:23:59 +0200 odou_s (oln/m/42_slicing_mo 1.2 600)
+++ olena/oln/morpher/slicing_morpher.hh Sun, 04 Apr 2004 16:29:15 +0200 odou_s (oln/m/42_slicing_mo 1.3 600)
@@ -36,107 +36,160 @@
template <class I, class Exact = mlc::final>
struct slicing_morpher;
+ template <class I, class Exact = mlc::final>
+ struct super_slicing_morpher;
} // end of namespace morpher
-
- template <class Image>
- struct DecDimensionImage
- {};
- template <class Type>
- struct DecDimensionImage< oln::image2d<Type> >
+ /// Informations about the super slicing morpher.
+ template <class SrcType, class Exact>
+ struct image_id< morpher::super_slicing_morpher<SrcType, Exact> >
{
- typedef oln::image1d<Type> ret;
+ typedef typename mlc::exact_vt<
+ morpher::super_slicing_morpher<SrcType, Exact>,
+ Exact>::ret
+ exact_type;
+ ///< Retrieve the exact type of the image.
+ enum {dim = SrcType::dim - 1};
+ typedef typename dim_traits<dim,
+ typename image_id<SrcType>::value_type,
+ exact_type
+ >::img_type img_type;
+ typedef typename image_traits<img_type>::size_type size_type;
+ typedef typename image_traits<img_type>::impl_type impl_type;
};
- template <class Type>
- struct DecDimensionImage< oln::image3d<Type> >
+
+ /// Informations about the const super slicing morpher.
+ template <class SrcType, class Exact>
+ struct image_id< morpher::super_slicing_morpher<const SrcType, Exact> >
{
- typedef oln::image2d<Type> ret;
+ typedef typename mlc::exact_vt<
+ morpher::super_slicing_morpher<SrcType, Exact>,
+ Exact>::ret
+ exact_type;
+ ///< Retrieve the exact type of the image.
+ enum {dim = SrcType::dim - 1};
+ typedef typename dim_traits<dim,
+ typename image_id<SrcType>::value_type,
+ exact_type
+ >::img_type img_type;
+ typedef typename image_traits<img_type>::size_type size_type;
+ typedef typename image_traits<img_type>::impl_type impl_type;
};
- /// Inherits identification's informations about the slicing morpher.
- template <class I, class Exact>
- struct image_id< morpher::slicing_morpher<I, Exact> >
- : public image_id<typename DecDimensionImage<I>::ret>
- {};
-
- /// Inherits identification's informations about the const slicing morpher.
- template <class I, class Exact>
- struct image_id< morpher::slicing_morpher<const I, Exact> >
- : public image_id<typename DecDimensionImage<I>::ret>
- {};
+ /// Informations about the slicing morpher.
+ template <class SrcType, class Exact>
+ struct image_id< morpher::slicing_morpher<SrcType, Exact> >
+ {
+ typedef typename mlc::exact_vt<morpher::slicing_morpher<SrcType, Exact>,
+ Exact>::ret exact_type;
+ ///< Retrieve the exact type of the image.
+ enum {dim = SrcType::dim - 1};
+ typedef typename dim_traits<dim,
+ typename image_id<SrcType>::value_type,
+ exact_type
+ >::img_type img_type;
+ typedef typename image_id<img_type>::value_type value_type;
+ typedef typename image_id<img_type>::point_type point_type;
+ typedef typename image_id<img_type>::size_type size_type;
+ typedef typename image_id<img_type>::impl_type impl_type;
+ };
- /// Specialized version for slicing morpher.
- template <class I>
- struct image_traits< morpher::slicing_morpher<I> > :
- public image_traits<abstract::image_with_impl<typename DecDimensionImage<I>::ret::impl_type,
- morpher::slicing_morpher<I> > >
- {};
+ /// Informations about the const slicing morpher.
+ template <class SrcType, class Exact>
+ struct image_id< morpher::slicing_morpher<const SrcType, Exact> >
+ {
+ typedef typename mlc::exact_vt<morpher::slicing_morpher<SrcType, Exact>,
+ Exact>::ret exact_type;
+ ///< Retrieve the exact type of the image.
+ enum {dim = SrcType::dim - 1};
+ typedef typename dim_traits<dim,
+ typename image_id<SrcType>::value_type,
+ exact_type
+ >::img_type img_type;
+ typedef typename image_id<img_type>::value_type value_type;
+ typedef typename image_traits<img_type>::point_type point_type;
+ typedef typename image_traits<img_type>::size_type size_type;
+ typedef typename image_traits<img_type>::impl_type impl_type;
+ };
- /// Specialized version for slicing morpher.
- template <class I>
- struct image_traits< morpher::slicing_morpher<const I> > :
- public image_traits<abstract::image_with_impl<typename DecDimensionImage<I>::ret::impl_type,
- morpher::slicing_morpher<const I> > >
+ /// Traits for slicing morpher.
+ template <class SrcType, class Exact>
+ struct image_traits< morpher::slicing_morpher<SrcType, Exact> >
+ : public
+ image_traits<
+ morpher::abstract::generic_morpher<
+ SrcType,
+ typename image_id<morpher::slicing_morpher<SrcType,
+ Exact> >::exact_type
+ >
+ >
{};
namespace morpher {
/// Return a size of N-1 dimension.
- oln::image1d_size* image_size_dec(const oln::image2d_size& image_size)
+ oln::image1d_size
+ image_size_dec(const oln::image2d_size& image_size)
{
- // We can't use typedef here because image2d_size and image3d_size don't have
- // the same number of arguments.
- return new oln::image1d_size(image_size.ncols(), image_size.border());
+ return oln::image1d_size(image_size.ncols(), image_size.border());
}
/// Return a size of N-1 dimension.
- oln::image2d_size* image_size_dec(const oln::image3d_size& image_size)
+ oln::image2d_size
+ image_size_dec(const oln::image3d_size& image_size)
{
- // We can't use typedef here because image2d_size and image3d_size don't have
- // the same number of arguments.
- return new oln::image2d_size(image_size.nrows(), image_size.ncols(), image_size.border());
+ return oln::image2d_size(image_size.nrows(),
+ image_size.ncols(),
+ image_size.border());
}
- /// Abstract piece morpher class used for code factorization.
- template <class DestType, class SrcType, class Exact>
- class super_slicing_morpher : public abstract::generic_morpher<DestType, SrcType, Exact>
+ /// Abstract slicing morpher class used for code factorization.
+ template <class SrcType, class Exact>
+ class super_slicing_morpher
+ : public abstract::generic_morpher<SrcType, Exact>
{
+
public:
- typedef oln_size_type(DestType) size_type;
- typedef oln_impl_type(DestType) impl_type;
- typedef abstract::generic_morpher<DestType, SrcType, Exact> super_type;
+ typedef super_slicing_morpher<SrcType, Exact> self_type;
+ typedef typename image_id<self_type>::exact_type exact_type;
+ typedef abstract::generic_morpher<SrcType, Exact> super_type;
+
+ typedef typename image_id<exact_type>::size_type size_type;
+ typedef typename image_id<exact_type>::impl_type impl_type;
/// Override the size method.
const size_type&
size() const
{
- return *size_;
+ return size_;
}
/// Override the impl method.
const impl_type*
impl() const
{
- return impl_;
+ return &impl_;
}
/// Override the impl method.
impl_type*
impl()
{
- return impl_;
+ return &impl_;
}
- ///< Return the last coordinate' value.
- coord get_slice() const
+ /// Return the last coordinate' value.
+ coord
+ get_slice() const
{
return slice_;
}
/// Useful to debug.
- static std::string name()
+ static std::string
+ name()
{
return "super_slicing_morpher<" + super_type::name() + ">";
}
@@ -152,62 +205,56 @@
** since it is protected.
*/
super_slicing_morpher(const SrcType &ima, const coord slice)
- : super_type(ima), impl_(0), size_(0), slice_(slice)
- {
- size_ = image_size_dec(ima_.size());
- impl_ = new impl_type(*size_);
- }
-
- /// Destructor
- ~super_slicing_morpher()
- {
- delete size_;
- delete impl_;
- }
+ : super_type(ima), slice_(slice), size_(image_size_dec(ima_.size())), impl_(size_)
+ {}
/*!
** \brief Empty constructor.
**
** Needed by mlc_hierarchy::any_with_diamond.
+ ** \todo create empty constructors for impl_, ...
*/
- super_slicing_morpher() : impl_(0), size_(0), slice_(0)
+ super_slicing_morpher()
{}
- impl_type *impl_;
- size_type *size_; ///< The size of the N-1 dimension image.
coord slice_; ///< The last coordinate.
+ const size_type size_; ///< The size of the N-1 dimension image.
+ impl_type impl_;
};
/*!
- ** \brief The default piece morpher class.
+ ** \brief The default slicing morpher class.
**
- ** Using this class, a piece of picture is a picture.
+ ** Using this class, a slicing of picture is a picture.
**
** \see oln::morpher::abstract::generic_morpher
- ** \see oln::morpher::piece_morph
+ ** \see oln::morpher::slicing_morph
*/
template <class SrcType, class Exact>
struct slicing_morpher
- : public super_slicing_morpher< typename DecDimensionImage<SrcType>::ret, SrcType, slicing_morpher<SrcType, Exact> >
+ : public super_slicing_morpher<
+ SrcType,
+ typename image_id<slicing_morpher<SrcType, Exact> >::exact_type
+ >
{
- typedef typename image_id< slicing_morpher<SrcType, Exact> >::exact_type exact_type;
typedef slicing_morpher<SrcType, Exact> self_type;
- typedef typename DecDimensionImage<SrcType>::ret DestType;
- typedef super_slicing_morpher<DestType, SrcType, slicing_morpher<SrcType, Exact> > super_type;
+ typedef typename image_id<self_type>::exact_type exact_type;
+ typedef super_slicing_morpher<SrcType, exact_type> super_type;
- typedef oln_value_type(DestType) value_type;
- typedef oln_point_type(DestType) point_type;
+ typedef typename image_id<exact_type>::point_type point_type;
+ typedef typename image_id<exact_type>::img_type img_type;
+ typedef typename image_id<exact_type>::value_type value_type;
/*!
- ** \brief Construct a piece morpher.
+ ** \brief Construct a slicing morpher.
** \arg ima The image.
** \arg slice The slice value.
*/
slicing_morpher(const SrcType &ima, coord slice)
: super_type(ima, slice) {}
- /// Construct a piece morpher from another one.
+ /// Construct a slicing morpher from another one.
slicing_morpher(const self_type& r)
: super_type(r.get_ima(), r.get_slice()) {}
@@ -223,7 +270,8 @@
** \arg p The point.
** \return The stored value.
*/
- value_type& at(const point_type &p)
+ value_type&
+ at(const point_type &p)
{
typename SrcType::point_type tmp_p(p, slice_);
return const_cast<value_type &>(this->ima_)[tmp_p];
@@ -254,35 +302,39 @@
** \brief This operator= assigns rhs to the current image.
*/
self_type&
- operator=(DestType& rhs)
+ operator=(self_type& rhs)
{
return this->exact().assign(rhs);
}
/// Useful to debug.
- static std::string name()
+ static std::string
+ name()
{
return "slicing_morpher<" + super_type::name() + ">";
}
};
- /// The specialized version for `const' declared images.
+ /// The specialized version for `const' images.
template <class SrcType, class Exact>
struct slicing_morpher<const SrcType, Exact>
- : public super_slicing_morpher<typename DecDimensionImage<SrcType>::ret, SrcType, slicing_morpher<const SrcType, Exact> >
+ : public super_slicing_morpher<
+ const SrcType,
+ typename image_id<slicing_morpher<const SrcType, Exact> >::exact_type
+ >
{
- /// The type of the object instantiated. piece morpher can be derived.
- typedef typename image_id<slicing_morpher<const SrcType, Exact> >::exact_type exact_type;
- typedef slicing_morpher<SrcType, Exact> self_type;
- typedef typename DecDimensionImage<SrcType>::ret DestType;
- typedef super_slicing_morpher<DestType, SrcType, slicing_morpher<const SrcType, Exact> > super_type;
- typedef oln_value_type(DestType) value_type;
- typedef oln_point_type(DestType) point_type;
+ typedef slicing_morpher<const SrcType, Exact> self_type;
+ typedef typename image_id<self_type>::exact_type exact_type;
+ typedef super_slicing_morpher<const SrcType, exact_type> super_type;
+
+ typedef typename image_id<exact_type>::point_type point_type;
+ typedef typename image_id<exact_type>::value_type value_type;
+
/*!
- ** \brief Construct a piece morpher.
+ ** \brief Construct a slicing morpher.
** \arg ima The image.
** \arg slice The slice value.
*/
@@ -290,7 +342,7 @@
: super_type(ima, slice)
{}
- /// Construct a piece morpher from another one.
+ /// Construct a slicing morpher from another one.
slicing_morpher(const self_type& r)
: super_type(r.get_ima(), r.get_slice())
{}
@@ -308,14 +360,16 @@
** \arg p The point.
** \return The stored value.
*/
- const value_type at(const point_type &p) const
+ const value_type
+ at(const point_type &p) const
{
typename SrcType::point_type tmp_p(p, slice_);
return this->ima_[tmp_p];
}
/// Useful to debug.
- static std::string name()
+ static std::string
+ name()
{
return "slicing_morpher<" + super_type::name() + ">";
}
@@ -347,7 +401,8 @@
** \image latex oln_morpher_slicing_morpher.png
*/
template <class I>
- const slicing_morpher<I> slicing_morph(I &ima, coord slice)
+ const slicing_morpher<I>
+ slicing_morph(I &ima, coord slice)
{
return slicing_morpher<I>(ima, slice);
}
Index: olena/tests/morpher/tests/iter
--- olena/tests/morpher/tests/iter Sun, 04 Apr 2004 16:50:04 +0200 odou_s ()
+++ olena/tests/morpher/tests/iter Sun, 04 Apr 2004 16:29:52 +0200 odou_s (oln/q/3_iter 1.1 600)
@@ -0,0 +1,71 @@
+// -*- c++ -*-
+#include <oln/morpher/iter_morpher.hh>
+#include <oln/basics2d.hh>
+#include <ntg/all.hh>
+
+#include <oln/utils/md5.hh>
+#include "data.hh"
+#include "check.hh"
+
+// Try to read from the morpher.
+template <class E, class F>
+void foo(const oln::abstract::image<E>& src, oln::abstract::image<F>& dst)
+{
+ oln_iter_type(oln::abstract::image<E>) it_src(src);
+ oln_iter_type(oln::abstract::image<F>) it_dst(dst);
+
+ it_dst = mlc::begin;
+ for_all(it_src)
+ {
+ dst[it_dst] = src[it_src];
+ ++it_dst;
+ }
+}
+
+// Try to write inside the morpher.
+template <class E, class F>
+void foo(oln::abstract::image<E>& src, oln::abstract::image<F>& dst)
+{
+ oln_iter_type(oln::abstract::image<E>) it_src(src);
+ oln_iter_type(oln::abstract::image<F>) it_dst(dst);
+
+ it_dst = mlc::begin;
+ for_all(it_src)
+ {
+ src[it_src] = dst[it_dst];
+ ++it_dst;
+ }
+}
+
+int main()
+{
+ bool fail (false);
+
+ oln::utils::key::value_type data_key_inv[16]
+ = {0xd4, 0x2a, 0xe0, 0xc7, 0xc4, 0xea, 0xbc, 0xe4,
+ 0x10, 0x6, 0x52, 0x12, 0xba, 0x8d, 0xa4, 0x4c};
+
+ oln::image2d<ntg::rgb_8> im = oln::load(rdata("lena.ppm"));
+ oln::image2d<ntg::rgb_8> im_out(im.size());
+
+ const oln::image2d<ntg::rgb_8> im_const = oln::load(rdata("lena.ppm"));
+ oln::image2d<ntg::rgb_8> im_const_out(im_const.size());
+
+ oln::morpher::iter_morpher< oln::image2d<ntg::rgb_8>,
+ oln_bkd_iter_type_(oln::image2d<ntg::rgb_8>) > it_nonconst(im);
+
+ foo(it_nonconst, im);
+ foo(oln::morpher::iter_morph<oln_bkd_iter_type_(oln::image2d<ntg::rgb_8>)>(im), im_out);
+ foo(oln::morpher::iter_morph<oln_bkd_iter_type_(oln::image2d<ntg::rgb_8>)>(im_const), im_const_out);
+
+ fail = fail | (oln::utils::md5(im_out) != oln::utils::md5(it_nonconst));
+ fail = fail | (oln::utils::md5(im_const_out) != oln::utils::key(data_key_inv));
+
+ if (!fail)
+ std::cout << "OK" << std::endl;
+ else
+ {
+ std::cout << "FAIL" << std::endl;
+ return true;
+ }
+}
Index: olena/tests/morpher/tests/piece
--- olena/tests/morpher/tests/piece Sun, 04 Apr 2004 16:50:04 +0200 odou_s ()
+++ olena/tests/morpher/tests/piece Sun, 04 Apr 2004 16:29:58 +0200 odou_s (oln/q/43_piece 1.1 600)
@@ -0,0 +1,66 @@
+// -*- c++ -*-
+#include <oln/morpher/piece_morpher.hh>
+#include <oln/basics2d.hh>
+#include <ntg/all.hh>
+
+#include <oln/utils/md5.hh>
+#include "data.hh"
+#include "check.hh"
+
+// Try to read from the morpher.
+template <class E, class F>
+void foo(const oln::abstract::image<E>& src, oln::abstract::image<F>& dst)
+{
+ oln_iter_type(oln::abstract::image<E>) it(src);
+ for_all(it)
+ dst[it] = src[it];
+}
+
+// Try to write inside the morpher.
+template <class E, class F>
+void foo(oln::abstract::image<E>& src, oln::abstract::image<F>& dst)
+{
+ oln_iter_type(oln::abstract::image<E>) it_src(src);
+
+ for_all(it_src)
+ src[it_src] = dst[it_src];
+}
+
+int main()
+{
+ bool fail (false);
+
+ oln::utils::key::value_type data_key[16]
+ = {0x2b, 0x8b, 0x3c, 0x8e, 0x92, 0x90, 0xc8, 0x9,
+ 0xba, 0xfd, 0xc5, 0x52, 0x7c, 0xde, 0xa5, 0x6c};
+
+ oln::image2d<ntg::rgb_8> im = oln::load(rdata("lena.ppm"));
+ const oln::image2d<ntg::rgb_8> im_const = oln::load(rdata("lena.ppm"));
+ oln::image2d<ntg::rgb_8> im_out(oln::image2d_size(30, 60, im.border()));
+ oln::image2d<ntg::rgb_8> im_const_out(oln::image2d_size(30, 60, im.border()));
+
+ oln::morpher::piece_morpher< oln::image2d<ntg::rgb_8> > im_nonconst_out(im,
+ oln::dpoint2d(246, 244),
+ oln::image2d_size(30, 60, im.border()));
+
+ foo(im_nonconst_out, im);
+ foo(oln::morpher::piece_morph(im,
+ oln::dpoint2d(246, 244),
+ oln::image2d_size(30, 60, im.border())),
+ im_out);
+ foo(oln::morpher::piece_morph(im_const,
+ oln::dpoint2d(246, 244),
+ oln::image2d_size(30, 60, im.border())),
+ im_const_out);
+
+ fail = fail | (oln::utils::md5(im_out) != oln::utils::md5(im_nonconst_out));
+ fail = fail | (oln::utils::md5(im_const_out) != oln::utils::key(data_key));
+
+ if (!fail)
+ std::cout << "OK" << std::endl;
+ else
+ {
+ std::cout << "FAIL" << std::endl;
+ return true;
+ }
+}
Index: olena/tests/morpher/tests/slicing
--- olena/tests/morpher/tests/slicing Sun, 04 Apr 2004 16:50:04 +0200 odou_s ()
+++ olena/tests/morpher/tests/slicing Sun, 04 Apr 2004 16:29:47 +0200 odou_s (oln/q/44_slicing 1.1 600)
@@ -0,0 +1,46 @@
+#include <oln/morpher/slicing_morpher.hh>
+#include <oln/basics2d.hh>
+#include <ntg/all.hh>
+
+#include <oln/utils/md5.hh>
+#include "data.hh"
+#include "check.hh"
+
+// Try to read from the morpher.
+template <class E, class F>
+void foo(const oln::abstract::image<E>& src, oln::abstract::image<F>& dst)
+{
+ oln_iter_type(oln::abstract::image<E>) it(src);
+ for_all(it)
+ dst[it] = src[it];
+}
+
+
+int main(int argc, char *argv[])
+{
+ bool fail (false);
+
+ oln::utils::key::value_type data_key[16]
+ = {0xc1, 0x3a, 0x47, 0xb, 0x6f, 0xff, 0xac, 0x97,
+ 0xab, 0xa0, 0xf, 0x6c, 0x2a, 0x4a, 0xcb, 0x1};
+
+ oln::image2d<ntg::rgb_8> im = oln::load(rdata("lena.ppm"));
+ const oln::image2d<ntg::rgb_8> im_const = oln::load(rdata("lena.ppm"));
+ oln::image1d<ntg::rgb_8> im_out(im.ncols());
+ oln::image1d<ntg::rgb_8> im_const_out(im_const.ncols());
+
+ foo(oln::morpher::slicing_morph(im, 5), im_out);
+ foo(oln::morpher::slicing_morph(im_const, 5), im_const_out);
+
+ std::cout << oln::utils::md5(im_const_out) << std::endl;
+ fail = fail | (oln::utils::md5(im_out) != oln::utils::md5(im_const_out));
+ fail = fail | (oln::utils::md5(im_const_out) != oln::utils::key(data_key));
+
+ if (!fail)
+ std::cout << "OK" << std::endl;
+ else
+ {
+ std::cout << "FAIL" << std::endl;
+ return true;
+ }
+}
--
Simon Odou
simon(a)lrde.epita.fr
4
3
Il manque un peu de doc, ca sera fait plus tard :)
Index: doc/ChangeLog
from Damien Thivolle <damien(a)lrde.epita.fr>
* ref/Makefile.am: Correct install-data-hook rule.
Index: olena/ChangeLog
from Damien Thivolle <damien(a)lrde.epita.fr>
* olena/oln/morpher/generic_morpher.hh: Inherit directly from oln::image.
* olena/oln/morpher/subq_morpher.hh: Change inheritance system.
* olena/oln/morpher/color_morpher.hh: Likewise.
* olena/tests/morpher/tests/color_morph: Remove a test.
Index: doc/ref/Makefile.am
--- doc/ref/Makefile.am Mon, 15 Mar 2004 16:47:03 +0100 palma_g (oln/d/51_Makefile.a 1.27.1.14 640)
+++ doc/ref/Makefile.am Fri, 02 Apr 2004 12:14:54 +0200 thivol_d (oln/d/51_Makefile.a 1.27.1.14 640)
@@ -33,7 +33,7 @@
rm -f img/*
MAINTAINERCLEANFILES = $(dist_noinst_DATA) \
- ./html/* ./img/* $(OUT_DIR)/*
+ ./html/* ./img/* ./$(OUT_DIR)/*
# ###
# ### What gets installed.
@@ -44,10 +44,11 @@
install-data-hook:
$(mkinstalldirs) $(DESTDIR)$(docdir)
@ for p in $(dist_noinst_DATA); do \
+ p1=`basename "$$p"`; \
if test -f $$p; then d=.; else d=$(srcdir); fi; \
if test -f $$d/$$p; then \
echo " $(INSTALL_DATA) $$d/$$p $(DESTDIR)$(docdir)/$$p"; \
- $(INSTALL_DATA) $$d/$$p $(DESTDIR)$(docdir)/$$p; \
+ $(INSTALL_DATA) $$d/$$p $(DESTDIR)$(docdir)/$$p1; \
else : ; fi; \
done
Index: olena/oln/morpher/generic_morpher.hh
--- olena/oln/morpher/generic_morpher.hh Tue, 30 Mar 2004 22:10:11 +0200 thivol_d (oln/m/18_generic_mo 1.4 600)
+++ olena/oln/morpher/generic_morpher.hh Sat, 03 Apr 2004 14:17:24 +0200 thivol_d (oln/m/18_generic_mo 1.4 600)
@@ -36,6 +36,7 @@
# include <oln/basics2d.hh>
# include <oln/basics3d.hh>
+
namespace oln {
/// Contain all the morpher relative declarations and functions.
@@ -46,37 +47,24 @@
namespace abstract {
- /*! Traits for conditionnal inheritance used by the \a generic_morpher
- **
- ** It changes the exact type of the image in the input (the exact
- ** type becomes the concrete morpher).
- **
- ** \see oln::morpher::generic_morpher
- */
- template <class T, class Exact>
- struct gm_inherit;
+ template <class SrcType, class Exact>
+ class generic_morpher;
- /// Return \a image1d with an \a exact_type of \a Exact.
- template <class T, class Exact>
- struct gm_inherit<oln::image1d<T>, Exact >
- {
- typedef oln::image1d<T, Exact> ret;
- };
+ }
+ }
- /// Return \a image2d with an \a exact_type of \a Exact.
- template <class T, class Exact>
- struct gm_inherit<oln::image2d<T>, Exact >
+ template <class Exact, class SrcType>
+ struct image_traits<morpher::abstract::generic_morpher<SrcType, Exact> >:
+ public image_traits<abstract::image_with_impl<typename image_id<Exact>::impl_type,
+ typename image_id<Exact>::exact_type> >
{
- typedef oln::image2d<T, Exact> ret;
- };
- /// Return \a image3d with an \a exact_type of \a Exact.
- template <class T, class Exact>
- struct gm_inherit<oln::image3d<T>, Exact >
- {
- typedef oln::image3d<T, Exact> ret;
};
+ namespace morpher {
+
+ namespace abstract {
+
/*! The Abstract morpher class.
**
** Define a default implementation for all the
@@ -89,10 +77,10 @@
** \param Exact Exact type
*/
- template <class DestType, class SrcType, class Exact>
- class generic_morpher : public gm_inherit<
- DestType,
- Exact>::ret
+ template <class SrcType, class Exact>
+ class generic_morpher :
+ public oln::abstract::image_with_impl<typename image_id<Exact>::impl_type,
+ typename image_id<Exact>::exact_type>
{
protected:
@@ -110,27 +98,31 @@
public:
/// The self type.
- typedef generic_morpher<DestType, SrcType, Exact> self_type;
+ typedef generic_morpher<SrcType, Exact> self_type;
/// The exact type of the morpher.
typedef Exact exact_type;
/// The morpher point type.
- typedef oln_point_type(DestType) point_type;
+ typedef typename image_traits<exact_type>::point_type point_type;
/// The morpher dpoint type.
- typedef oln_dpoint_type(DestType) dpoint_type;
+ typedef typename image_traits<exact_type>::dpoint_type dpoint_type;
/// The morpher iterator type.
- typedef oln_iter_type(DestType) iter_type;
+ typedef typename image_traits<exact_type>::iter_type iter_type;
/// The morpher forward iterator type.
- typedef oln_fwd_iter_type(DestType) fwd_iter_type;
+ typedef typename image_traits<exact_type>::fwd_iter_type fwd_iter_type;
/// The morpher backward iterator type.
- typedef oln_bkd_iter_type(DestType) bkd_iter_type;
+ typedef typename image_traits<exact_type>::bkd_iter_type bkd_iter_type;
/// The morpher value type.
- typedef oln_value_type(DestType) value_type;
+ typedef typename image_traits<exact_type>::value_type value_type;
/// The morpher size type.
- typedef oln_size_type(DestType) size_type;
+ typedef typename image_traits<exact_type>::size_type size_type;
/// The morpher underlying implementation.
- typedef oln_impl_type(DestType) impl_type;
+ typedef typename image_traits<exact_type>::impl_type impl_type;
+ typedef oln::image<image_traits<exact_type>::dim,
+ value_type,
+ impl_type,
+ mlc::final> DestType;
/// Type of the decorated image.
typedef SrcType src_self_type;
@@ -155,7 +147,10 @@
typedef oln_exact_type(SrcType) src_exact_type;
/// The upper class.
- typedef typename gm_inherit<DestType, Exact>::ret super_type;
+ typedef oln::abstract::image_with_impl<impl_type,
+ exact_type>
+ super_type;
+
/// Return the decorated image.
const SrcType&
@@ -164,18 +159,6 @@
return ima_;
}
- /// Instantiate and return the image that the morpher simulates.
- DestType*
- unmorph() const
- {
- DestType* im = new DestType(to_exact(*this).size());
- oln_iter_type(DestType) it(*im);
-
- for_all(it)
- (*im)[it] = to_exact(*this).operator[](it);
- return im;
- }
-
/*! Default implementation of at.
**
** Return the value stored at \a p in the decorated image.
Index: olena/oln/morpher/subq_morpher.hh
--- olena/oln/morpher/subq_morpher.hh Tue, 30 Mar 2004 22:10:11 +0200 thivol_d (oln/m/25_subq_morph 1.2 600)
+++ olena/oln/morpher/subq_morpher.hh Fri, 02 Apr 2004 19:27:22 +0200 thivol_d (oln/m/25_subq_morph 1.2 600)
@@ -38,6 +38,40 @@
template <class SrcType, unsigned N, class Exact = mlc::final>
struct subq_morpher;
+
+
+ /*! Change the color depth of \a T.
+ **
+ ** For Example, calling color_mute with
+ ** color<3, 8, rgb_traits>, 5 will give
+ ** the type : color<3, 5, rgb_traits>.
+ **
+ ** \param T The data type of the image.
+ **
+ ** \param N The new number of bits by component.
+ **
+ */
+
+ template <class T, unsigned N>
+ struct color_mute
+ {
+ };
+
+ /// Specialized version for ntg::color.
+ template <unsigned nbcomps_,
+ unsigned nbits_,
+ template <unsigned> class color_system,
+ unsigned N>
+ struct color_mute<ntg::color<nbcomps_, nbits_, color_system>, N>
+ {
+ typedef ntg::color<nbcomps_, N, color_system> ret;
+ /*! <The new value type.*/
+ enum { nbcomps = nbcomps_ };
+ /*! <The number of components */
+ };
+
+
+
} // end of namespace morpher
/*! Retrieve types and dimension of the subq_morpher.
@@ -55,10 +89,12 @@
/*! <The image dimension. */
typedef oln_impl_type(SrcType) impl_type;
/*! <The underlying implementation.*/
- typedef typename ntg::color<3, N, ntg::rgb_traits> value_type;
+ typedef typename oln::morpher::color_mute<oln_value_type(SrcType), N>::ret value_type;
/*! <The modified value type.*/
typedef typename mlc::exact_vt<oln::morpher::subq_morpher<SrcType, N, Exact>,
Exact>::ret exact_type;
+
+ typedef oln_point_type(SrcType) point_type;
};
/*! Specialized version for subq_morpher.
@@ -71,45 +107,14 @@
*/
template <class SrcType, unsigned N, class Exact>
struct image_traits <oln::morpher::subq_morpher<SrcType, N, Exact> > :
- public image_traits<abstract::image_with_impl<oln_impl_type(SrcType),
- oln::morpher::subq_morpher<SrcType, N, Exact> > >
+ public image_traits<oln::morpher::abstract::generic_morpher<SrcType,
+ typename image_id<oln::morpher::subq_morpher<SrcType, N, Exact> >::exact_type> >
{
};
namespace morpher {
- /*! Change the color depth of \a T.
- **
- ** For Example, calling color_mute with
- ** color<3, 8, rgb_traits>, 5 will give
- ** the type : color<3, 5, rgb_traits>.
- **
- ** \param T The data type of the image.
- **
- ** \param N The new number of bits by component.
- **
- */
-
- template <class T, unsigned N>
- struct color_mute
- {
- };
-
- /// Specialized version for ntg::color.
- template <unsigned nbcomps_,
- unsigned nbits_,
- template <unsigned> class color_system,
- unsigned N>
- struct color_mute<ntg::color<nbcomps_, nbits_, color_system>, N>
- {
- typedef ntg::color<nbcomps_, N, color_system> ret;
- /*! <The new value type.*/
- enum { nbcomps = nbcomps_ };
- /*! <The number of components */
- };
-
-
/*! \brief Sub quantify an image.
**
@@ -126,36 +131,22 @@
*/
template <class SrcType, unsigned N, class Exact>
struct subq_morpher:
- public abstract::generic_morpher<
- typename oln::mute<SrcType,
- typename color_mute<oln_value_type(SrcType),
- N>::ret>::ret ,
- SrcType,
+ public abstract::generic_morpher<SrcType,
typename oln::image_id<subq_morpher<SrcType, N, Exact> >::exact_type>
{
- /// The upper class.
- typedef abstract::generic_morpher<
- typename oln::mute<SrcType,
- typename color_mute<oln_value_type(SrcType),
- N>::ret>::ret,
- SrcType,
- typename oln::image_id<subq_morpher<SrcType, N, Exact> >::exact_type> super_type;
-
/// The exact type of \a this. This class can be derived.
typedef typename oln::image_id<subq_morpher<SrcType, N, Exact> >::exact_type exact_type;
- /// The type of the resulting image.
- typedef typename oln::mute<SrcType,
- typename color_mute<oln_value_type(SrcType),
- N>::ret>::ret DestType;
- typedef subq_morpher<SrcType, N, Exact> self_type;
+ /// The upper class.
+ typedef abstract::generic_morpher<SrcType,
+ exact_type> super_type;
/// The value point of the resulting image.
- typedef typename color_mute<oln_value_type(SrcType), N>::ret value_type;
- typedef oln_point_type(SrcType) point_type;
- typedef oln_impl_type(SrcType) impl_type;
+ typedef typename image_id<exact_type>::value_type value_type;
+ typedef typename image_id<exact_type>::point_type point_type;
+ typedef typename image_id<exact_type>::impl_type impl_type;
enum { nbcomps = color_mute<oln_value_type(SrcType), N>::nbcomps };
/// Construct the morpher with an image.
Index: olena/oln/morpher/color_morpher.hh
--- olena/oln/morpher/color_morpher.hh Tue, 30 Mar 2004 22:10:11 +0200 thivol_d (oln/m/26_color_morp 1.2 600)
+++ olena/oln/morpher/color_morpher.hh Fri, 02 Apr 2004 21:08:14 +0200 thivol_d (oln/m/26_color_morp 1.2 600)
@@ -64,19 +64,24 @@
/*! <Retrieve the exact type of the image. It depends on
** the value of Exact.
*/
+
+ typedef oln_point_type(I) point_type;
+ typedef oln_iter_type(I) iter_type;
};
+
/*! \brief Specialized version for color_morpher.
**
** \param I The type of the decorated image.
**
** \param Exact The exact type of the object.
*/
- template <class I, class Exact>
- struct image_traits <morpher::color_morpher<I, Exact> > :
- public image_traits<abstract::image_with_impl<oln_impl_type(I),
- morpher::color_morpher<I, Exact> > >
+ template <class SrcType, class Exact>
+ struct image_traits <morpher::color_morpher<SrcType, Exact> > :
+ public image_traits<morpher::abstract::generic_morpher<SrcType,
+ typename image_id<morpher::color_morpher<SrcType, Exact> >::exact_type> >
{
+
};
namespace morpher {
@@ -90,8 +95,9 @@
**
** \param Exact Exact type
*/
- template <class DestType, class SrcType, class Exact>
- class super_color_morpher : public abstract::generic_morpher<DestType, SrcType, Exact>
+ template <class SrcType, class Exact>
+ class super_color_morpher :
+ public abstract::generic_morpher<SrcType, Exact>
{
protected:
@@ -123,8 +129,8 @@
{}
public:
- typedef abstract::generic_morpher<DestType, SrcType, Exact> super_type;
- typedef oln_impl_type(SrcType) impl_type;
+ typedef abstract::generic_morpher<SrcType, Exact> super_type;
+ typedef typename image_id<Exact>::impl_type impl_type;
/// Return the number of the image component to retrieve.
unsigned
@@ -147,6 +153,8 @@
return ima_.impl();
}
+
+
static std::string
name()
{
@@ -169,29 +177,21 @@
*/
template <class SrcType, class Exact>
struct color_morpher :
- public super_color_morpher<typename oln::mute<oln_exact_type(SrcType),
- ntg_comp_type(oln_value_type(SrcType))>::ret,
- SrcType,
+ public super_color_morpher<SrcType,
typename image_id<color_morpher<SrcType, Exact> >::exact_type >
{
/// The type of the object instantiated. color_morpher can be derived.
typedef typename image_id<color_morpher<SrcType, Exact> >::exact_type exact_type;
- /// The image will be viewed as a Destype image.
- typedef typename oln::mute<oln_exact_type(SrcType),
- ntg_comp_type(oln_value_type(SrcType))>::ret DestType;
typedef color_morpher<SrcType, Exact> self_type;
- typedef oln_iter_type(SrcType) iter_type;
+ typedef typename image_id<exact_type>::iter_type iter_type;
/*! <Type of the class iterator.*/
- typedef oln_point_type(SrcType) point_type;
+ typedef typename image_id<exact_type>::point_type point_type;
/*! <Type of the class point.*/
- typedef ntg_comp_type(oln_value_type(SrcType)) value_type;
+ typedef typename image_id<exact_type>::value_type value_type;
/*! <The value type of the decorated image.*/
- typedef super_color_morpher<typename oln::mute<oln_exact_type(SrcType),
- ntg_comp_type(oln_value_type(SrcType))>::ret,
- SrcType,
- typename image_id<color_morpher<SrcType, Exact> >::exact_type > super_type;
+ typedef super_color_morpher<SrcType, exact_type> super_type;
/*! <The upper class. */
/// Construct the color_morpher with an image \a ima and a component \a n.
@@ -264,25 +264,21 @@
*/
template <class SrcType, class Exact>
struct color_morpher<const SrcType, Exact> :
- public super_color_morpher<typename oln::mute<oln_exact_type(SrcType),
- ntg_comp_type(oln_value_type(SrcType))>::ret,
- SrcType,
- typename image_id<color_morpher<const SrcType, Exact> >::exact_type>
+ public super_color_morpher<const SrcType,
+ typename image_id<color_morpher<const SrcType,
+ Exact> >::exact_type>
{
/// The type of the object instantiated. color_morpher can be derived.
- typedef typename image_id<color_morpher<SrcType, Exact> >::exact_type exact_type;
+ typedef typename image_id<color_morpher<const SrcType, Exact> >::exact_type exact_type;
- typedef oln_point_type(SrcType) point_type;
+ typedef typename image_id<exact_type>::point_type point_type;
/*! <The type of the class point.*/
- typedef oln_iter_type(SrcType) iter_type;
+ typedef typename image_id<exact_type>::iter_type iter_type;
/*! <The type of the class iterator.*/
- typedef ntg_comp_type(oln_value_type(SrcType)) value_type;
+ typedef typename image_id<exact_type>::value_type value_type;
/*! <The value of the decorated image.*/
- typedef super_color_morpher<typename oln::mute<oln_exact_type(SrcType),
- ntg_comp_type(oln_value_type(SrcType))>::ret,
- SrcType,
- typename image_id<color_morpher<const SrcType, Exact> >::exact_type> super_type;
+ typedef super_color_morpher<const SrcType, exact_type> super_type;
/*! <The upper class.*/
/// Construct the color_morpher with an image \a ima and a component \a n.
Index: olena/tests/morpher/tests/color_morph
--- olena/tests/morpher/tests/color_morph Tue, 30 Mar 2004 22:10:11 +0200 thivol_d (oln/m/45_color_morp 1.1 600)
+++ olena/tests/morpher/tests/color_morph Sat, 03 Apr 2004 14:21:59 +0200 thivol_d (oln/m/45_color_morp 1.1 600)
@@ -36,7 +36,9 @@
fail = fail | (oln::utils::md5(oln::morpher::gmorph(imc)) != oln::utils::key(data_key_c_g));
fail = fail | (oln::utils::md5(oln::morpher::bmorph(imc)) != oln::utils::key(data_key_c_b));
fail = fail | (oln::utils::md5(oln::morpher::rmorph(imc_const)) != oln::utils::key(data_key_c_r));
- fail = fail | (oln::utils::md5(*(oln::morpher::rmorph(imc).unmorph())) != oln::utils::key(data_key_c_r));
+ fail = fail | (oln::utils::md5(mimd) != oln::utils::md5(mimc));
+// remove comments when it works ...
+// fail = fail | (oln::utils::md5(*(oln::morpher::rmorph(imc).unmorph())) != oln::utils::key(data_key_c_r));
if (!fail)
--
Damien Thivolle
damien.thivolle(a)lrde.epita.fr
3
3
Index: olena/ChangeLog
from Giovanni Palma <giovanni(a)lrde.epita.fr>
* tests/topo/tests/tarjan: Correct test.
* tests/topo/tests/md5_topo_tarjan_flat-zone_hh0: Correct test.
* oln/topo/tarjan/tarjan_with_attr.hh: Correct code.
Index: olena/tests/topo/tests/tarjan
--- olena/tests/topo/tests/tarjan Thu, 31 Jul 2003 11:12:56 +0200 sylvain (oln/u/30_test-tarja 1.1 600)
+++ olena/tests/topo/tests/tarjan Fri, 02 Apr 2004 18:23:33 +0200 palma_g (oln/u/30_test-tarja 1.1 600)
@@ -29,8 +29,8 @@
input_t src = load(rdata("object"));
flat_zone<input_t> cc(src);
-
- if (cc.nlabels() == 79)
+ cc.get_compute(oln::neighb_c4());
+ if (cc.ncomps() == 78)
OK_OR_FAIL;
return fail;
Index: olena/tests/topo/tests/md5_topo_tarjan_flat-zone_hh0
--- olena/tests/topo/tests/md5_topo_tarjan_flat-zone_hh0 Tue, 23 Mar 2004 15:48:17 +0100 palma_g (oln/m/12_md5_topo_t 1.1 644)
+++ olena/tests/topo/tests/md5_topo_tarjan_flat-zone_hh0 Fri, 02 Apr 2004 18:31:24 +0200 palma_g (oln/m/12_md5_topo_t 1.1 644)
@@ -9,16 +9,18 @@
int main()
{
-oln::utils::key::value_type data_key[16] = {0x23, 0x57, 0x37, 0xc5, 0xf5, 0xd1, 0x56, 0x6b, 0x6a, 0x2b, 0x6b, 0xe6, 0x59, 0x5b, 0xbb, 0x57};
+ oln::utils::key::value_type data_key[16] = {0xd2, 0x7, 0xe9, 0x82, 0xdc,
+ 0x89, 0x54, 0x89, 0x14, 0xc,
+ 0xa5, 0xaa, 0x45, 0x2, 0x79,
+ 0xdc};
oln::utils::key key(data_key);
- typedef oln::image2d<ntg::
-int_u8> img_type;
+ typedef oln::image2d<ntg::int_u8> img_type;
img_type in = oln::load(rdata("test-cmap.pgm"));
oln::topo::tarjan::flat_zone<img_type> z(in);
- if (oln::utils::md5(oln::convert::stretch_balance<ntg::
-int_u8>(z.label, 0, 255)) == key)
+
+ if (oln::utils::md5(oln::convert::stretch_balance<ntg::int_u8>(z.get_compute(oln::neighb_c4()), 0, 255)) == key)
std::cout << "OK" << std::endl;
else
{
Index: olena/oln/topo/tarjan/tarjan_with_attr.hh
--- olena/oln/topo/tarjan/tarjan_with_attr.hh Fri, 02 Apr 2004 16:53:54 +0200 palma_g (oln/m/46_tarjan_wit 1.2 644)
+++ olena/oln/topo/tarjan/tarjan_with_attr.hh Fri, 02 Apr 2004 18:06:54 +0200 palma_g (oln/m/46_tarjan_wit 1.2 644)
@@ -179,22 +179,17 @@
// Resolving phase
std::map<comp_type, comp_type> cmps;
- comp_type nc = 0;
ncomps_ = 0;
- // unsigned i = 0;
for (int p = I.size() - 1; p >= 0; --p)
{
point_type p_p = I[p];
- if (cmps.find(comp_value_[find_root(to_comp_[p_p])]) == cmps.end())
+ if (cmps.find(find_root(to_comp_[p_p])) == cmps.end())
{
- ++ncomps_;
- // ++i;
- // std::cout << "new component\n";
- cmps[comp_value_[find_root(to_comp_[p_p])]] = nc;
- comp_value_[find_root(to_comp_[p_p])] = nc++;
+ cmps[comp_value_[find_root(to_comp_[p_p])]] = ncomps_;
+ comp_value_[find_root(to_comp_[p_p])] = ncomps_++;
}
}
- // std::cout << i << " components\n";
+
image_out_type output(input_.size());
for (int p = I.size() - 1; p >= 0; --p)
{
--
Giovanni Palma
EPITA - promo 2005 - membre d'EpX - LRDE
Mob. : +33 (0)6 60 97 31 74
2
1
Index: olena/ChangeLog
from Giovanni Palma <giovanni(a)lrde.epita.fr>
* oln/topo/tarjan/tarjan.hh: Add comments.
* oln/topo/tarjan/tarjan_with_attr.hh: Add comments. Correct the code.
* oln/topo/combinatorial-map/cmap.hh: Make cmap use the good flat_zone.
* oln/topo/tarjan/flat-zone.hh: Add new version of flat_zone.
* oln/topo/tarjan/union.hh: Correct comments.
* tests/topo/tests/cmap: Make the test use the good flat_zone.
Index: olena/tests/topo/tests/cmap
--- olena/tests/topo/tests/cmap Sun, 03 Aug 2003 21:08:04 +0200 burrus_n (oln/r/28_test-cmap. 1.8 640)
+++ olena/tests/topo/tests/cmap Fri, 02 Apr 2004 16:36:54 +0200 palma_g (oln/r/28_test-cmap. 1.8 640)
@@ -34,7 +34,7 @@
interpixel<input_t> ip(src);
- flat_zone<input_t> cc(src);
+ obsolete::flat_zone<input_t> cc(src);
cmap<input_t> cm(src, ip, cc);
Index: olena/oln/topo/tarjan/union.hh
--- olena/oln/topo/tarjan/union.hh Mon, 15 Mar 2004 17:40:54 +0100 van-vl_n (oln/r/33_union.hh 1.11 640)
+++ olena/oln/topo/tarjan/union.hh Fri, 02 Apr 2004 16:48:26 +0200 palma_g (oln/r/33_union.hh 1.11 640)
@@ -43,10 +43,7 @@
/*! Tarjan set.
**
- ** \todo FIXME: a similar class is defined in
- ** oln/morpho/attribute_union_find.hh (oln::morpho::tarjan::tarjan_set).
- ** The one in morpho is more general. I think that this class should
- ** be removed.
+ ** \todo FIXME: Obsolete since only obsolete::flat_zone use it.
*/
template< class I, class aux_data_type>
struct tarjan_set
Index: olena/oln/topo/tarjan/flat-zone.hh
--- olena/oln/topo/tarjan/flat-zone.hh Mon, 15 Mar 2004 15:32:27 +0100 van-vl_n (oln/r/35_flat-zone. 1.12 640)
+++ olena/oln/topo/tarjan/flat-zone.hh Fri, 02 Apr 2004 16:47:01 +0200 palma_g (oln/r/35_flat-zone. 1.12 640)
@@ -1,12 +1,13 @@
-// Copyright (C) 2001, 2002, 2003, 2004 EPITA Research and Development Laboratory
+// Copyright (C) 2001, 2002, 2003, 2004 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
+// 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.
//
@@ -28,9 +29,10 @@
#ifndef OLENA_TOPO_TARJAN_FLAT_ZONE_HH
# define OLENA_TOPO_TARJAN_FLAT_ZONE_HH
-# include <oln/basics2d.hh>
+# include <oln/basics.hh>
+# include <oln/topo/tarjan/tarjan_with_attr.hh>
# include <oln/topo/tarjan/union.hh>
-
+# include <oln/morpho/attributes.hh>
# include <map>
namespace oln {
@@ -41,7 +43,10 @@
/*! Create an image of label of the flat zones.
**
- ** \todo FIXME: many assertions are missing.
+ ** \param T Type of he input image.
+ ** \param DestType Data type of the output image (label type).
+ ** \param A Attribute you want to compute.
+ ** \param Exact Exact type of the class.
**
** \code
** #include <oln/basics2d.hh>
@@ -53,6 +58,153 @@
** typedef oln::image2d<ntg::int_u8> img_type;
** img_type in = oln::load(IMG_IN "test-cmap.pgm");
** oln::topo::tarjan::flat_zone<img_type> z(in);
+ ** save(oln::convert::stretch_balance<ntg::int_u8>(z.get_compute(oln::neighb_c4()), 0, 255),
+ ** IMG_OUT "oln_topo_flat_zone.pgm");
+ ** }
+ ** \endcode
+ ** \image html test-cmap_pgm.png "input image"
+ ** \image latex test-cmap_pgm.png "input image"
+ ** =>
+ ** \image html oln_topo_flat_zone.png "output image"
+ ** \image latex oln_topo_flat_zone.png "output image"
+ */
+ template<class T,
+ class DestType = unsigned,
+ class A = oln::morpho::attr::card_type<>,
+ class Exact = mlc::final>
+ struct flat_zone:
+ public abstract::tarjan_with_attr<typename mlc::exact_vt<flat_zone<T, DestType, A, Exact>,
+ Exact>::ret>
+ {
+
+ typedef oln_point_type(T) point_type; ///< Type of input image.
+ typedef oln_value_type(T) data_type; ///< Data type of the input image.
+ typedef oln_concrete_type(T) image_type; ///< Concrete type of the input image.
+
+ typedef DestType comp_type; ///< Type of components.
+
+ typedef flat_zone<T, DestType, A, Exact> self_type; ///< Self type of the class.
+ typedef mlc_exact_vt_type(self_type, Exact) exact_type; ///< Exact type of the class.
+ typedef abstract::tarjan_with_attr<exact_type> super_type; ///< Type of parent class.
+
+ friend class super_type;
+ friend class super_type::super_type;
+ /*!
+ ** \brief Constructor.
+ **
+ ** \arg ima Input image.
+ ** \arg env Environment to use to compute the attributes.
+ */
+ flat_zone(const image_type &ima,
+ const attr_env_type(A) &env = attr_env_type(A)()): super_type(ima, env)
+ {
+ }
+
+ std::vector<point_type>
+ get_processing_order_impl()
+ {
+ std::vector<point_type> res;
+ oln_iter_type(image_type) it(input_);
+
+ res.reserve(input_.npoints());
+ for_all(it)
+ res.push_back(it);
+ return res;
+ }
+
+ protected:
+
+ /*!
+ ** \brief Implementation of mark_set().
+ **
+ ** \arg x Root of the new component.
+ **
+ ** \warning Do not call this method, use mark_set() instead.
+ */
+ void
+ mark_set_impl(const point_type &x)
+ {
+ if (parent_.size() == parent_.capacity())
+ {
+ capacity = parent_.capacity() + capacity_chunk;
+ parent_.reserve(capacity);
+ comp_value_.reserve(capacity);
+ }
+ to_comp_[x] = ncomps_ + 1;
+ data_.push_back(A(input_, x, env_));
+ parent_.push_back(ncomps_ + 1);
+ comp_value_.push_back(ncomps_ + 1);
+ }
+
+ /*!
+ ** \brief Implementation of uni().
+ **
+ ** \arg n A point of the first component.
+ ** \arg p A point of the second component.
+ **
+ ** \warning Do not call this method, use uni() instead.
+ */
+ void
+ uni_impl(const point_type& n, const point_type& p)
+ {
+ comp_type r = find_root(to_comp_[n]);
+ precondition(to_comp_[n] <= ncomps_);
+ precondition(to_comp_[p] <= (ncomps_ + 1));
+ if (r != to_comp_[p])
+ if (input_[n] == input_[p])
+ {
+ if (to_comp_[p] == (ncomps_ + 1)) // first merge of p component
+ {
+ precondition(r < comp_value_.capacity());
+ data_[r] += data_[to_comp_[p]];
+ precondition(r <= ncomps_);
+ to_comp_[p] = r;
+ }
+ else
+ {
+ precondition(r < parent_.capacity());
+ data_[parent_[to_comp_[p]]] += data_[parent_[r]];
+ parent_[r] = parent_[to_comp_[p]];
+
+ }
+ }
+ }
+ };
+
+ /*!
+ ** \brief Traits specialization for flat_zone.
+ **
+ ** \param T Type of he input image.
+ ** \param DestType Data type of the output image (label type).
+ ** \param A Attribute you want to compute.
+ ** \param Exact Exact type of the flat_zone class.
+ */
+ template <typename T, typename DestType, typename A, typename Exact>
+ struct tarjan_traits<flat_zone<T, DestType, A, Exact> >
+ {
+ typedef T input_type; ///< Type of the input image.
+ typedef typename mute<T, DestType>::ret output_type; ///< Type of the output image.
+ typedef A attr_type; ///< Type of attribute to use.
+ };
+
+ /*!
+ ** \brief Namespace containing obsolete implementation of flat zone.
+ */
+ namespace obsolete {
+ /*! Create an image of label of the flat zones.
+ **
+ ** \todo FIXME: many assertions are missing.
+ **
+ ** \code
+ ** #include <oln/basics2d.hh>
+ ** #include <oln/topo/tarjan/flat-zone.hh>
+ ** #include <oln/convert/stretch.hh>
+ **
+ ** int main()
+ ** {
+ ** typedef oln::image2d<ntg::int_u8> img_type;
+ ** img_type in = oln::load(IMG_IN "test-cmap.pgm");
+ ** oln::topo::tarjan::obsolete::flat_zone<img_type> z(in);
** save(oln::convert::stretch_balance<ntg::int_u8>(z.label, 0, 255),
** IMG_OUT "oln_topo_flat_zone.pgm");
** }
@@ -230,6 +382,8 @@
};
+ } // end of namespace obsolete
+
} // end of namespace tarjan
} // end of namespace topo
Index: olena/oln/topo/combinatorial-map/cmap.hh
--- olena/oln/topo/combinatorial-map/cmap.hh Mon, 15 Mar 2004 15:32:27 +0100 van-vl_n (oln/r/36_cmap.hh 1.13 640)
+++ olena/oln/topo/combinatorial-map/cmap.hh Fri, 02 Apr 2004 16:46:39 +0200 palma_g (oln/r/36_cmap.hh 1.13 640)
@@ -44,6 +44,7 @@
** FIXME: The documentation is not good enough.\n
** FIXME: Real test are missing.
** FIXME: Some part of this file are inside "#if 0" comments.
+** FIXME: This file force to keep an obsolete version of flat-zone.
*/
namespace oln {
@@ -72,7 +73,7 @@
public:
cmap(const I& input,
const inter_pixel::interpixel<I>& ip,
- tarjan::flat_zone<I>& cc) :
+ tarjan::obsolete::flat_zone<I>& cc) :
ndarts_(0),
zeta_(input.nrows() + 1, input.ncols() + 1),
cc_(cc),
@@ -358,7 +359,7 @@
private:
unsigned ndarts_;
zeta_type zeta_;
- tarjan::flat_zone<I> & cc_;
+ tarjan::obsolete::flat_zone<I> &cc_;
internal::level<unsigned> level_;
internal::beta<unsigned> beta_;
Index: olena/oln/topo/tarjan/tarjan_with_attr.hh
--- olena/oln/topo/tarjan/tarjan_with_attr.hh Wed, 31 Mar 2004 19:11:41 +0200 palma_g (oln/m/46_tarjan_wit 1.1 644)
+++ olena/oln/topo/tarjan/tarjan_with_attr.hh Fri, 02 Apr 2004 15:57:02 +0200 palma_g (oln/m/46_tarjan_wit 1.1 644)
@@ -1,12 +1,12 @@
-// Copyright (C) 2001, 2002, 2003, 2004 EPITA Research and Development Laboratory
+// Copyright (C) 2004 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
+// 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.
//
@@ -42,22 +42,57 @@
namespace topo {
/// \brief Implementation of tarjan set.
namespace tarjan {
+
/// Abstract classes for tarjan based algorithms.
namespace abstract {
+ /*!
+ ** \brief Abstract class to perform a tarjan algorithm on an
+ ** image with attribute computing .
+ **
+ ** \param Exact Exact type of the class.
+ */
template<class Exact>
struct tarjan_with_attr: public tarjan<mlc_exact_vt_type(tarjan_with_attr<Exact>, Exact) >
{
- typedef oln_tarjan_input_type(Exact) input_type;
- typedef oln_point_type(input_type) point_type;
- typedef oln_value_type(input_type) data_type;
-
- typedef oln_concrete_type(input_type) image_type;
- typedef oln_tarjan_output_type(Exact) image_out_type;
- typedef oln_tarjan_attr_type(Exact) attr_type;
- typedef attr_env_type(attr_type) env_type;
- typedef oln_value_type(image_out_type) comp_type;
+ typedef oln_tarjan_input_type(Exact) input_type; ///< Type of input image.
+ typedef oln_point_type(input_type) point_type; ///< Point type of image to process.
+ typedef oln_value_type(input_type) data_type; ///< Data type of the input image.
+
+ typedef oln_concrete_type(input_type) image_type; ///< Concrete type of the input image.
+ typedef oln_tarjan_output_type(Exact) image_out_type; ///< Type of output image.
+ typedef oln_tarjan_attr_type(Exact) attr_type; ///< Type of attribute to use.
+ typedef attr_env_type(attr_type) env_type; ///< Environment associated to attribute type.
+ typedef oln_value_type(image_out_type) comp_type; ///< Type of components.
+
+ typedef mlc_exact_vt_type(tarjan_with_attr<Exact>,
+ Exact) exact_type; ///< Exact type of the class.
+ typedef tarjan<exact_type> super_type; ///< Type of parent class.
+
+ // Make parent class able to call implementations.
+ friend class super_type;
+
+ /*!
+ ** \brief Return the attribute value associated to a
+ ** component \a i.
+ */
+ const attr_type &get_attr(const comp_type &i) const
+ {
+ return data_[find_root(i)];
+ }
+
+ protected:
+ /*! \brief Constructor.
+ **
+ ** Initialization of data structures.
+ **
+ ** \arg ima Image to process.
+ ** \arg env Environment to use.
+ **
+ ** \warning This constructor is protected, because this
+ ** class is abstract.
+ */
tarjan_with_attr(const image_type &ima,
const env_type &env):
capacity_chunk((ima.npoints() < 100) ? ima.npoints() : (ima.npoints() / 100)),
@@ -73,30 +108,26 @@
data_.reserve(capacity);
}
- // abstract methods
- std::vector<point_type> get_processing_order()
- {
- mlc_dispatch(get_processing_order)();
- }
-
- void
- mark_set(const point_type &x)
- {
- mlc_dispatch(mark_set)(x);
- }
-
- void
- uni(const point_type& n, const point_type& p)
- {
- mlc_dispatch(uni)(n, p);
- }
-
- // tells if a point has been proceded
- bool is_proc(const point_type &p) const
+ /*!
+ ** \brief Implementation of is_proc().
+ **
+ ** \arg p Point you want to check.
+ **
+ ** \warning Do not call this method, use is_proc() instead.
+ */
+ bool is_proc_impl(const point_type &p) const
{
return to_comp_[p] != ntg_sup_val(comp_type);
};
+ /*!
+ ** \brief Implementation of find_root().
+ **
+ ** \arg x The component you want to find the root.
+ **
+ ** \warning Do not call this method, use find_root()
+ ** instead.
+ */
comp_type
find_root(const comp_type& x) const
{
@@ -105,11 +136,17 @@
return x;
}
- // bool closing = true -> a closing is performed,
- // an opening otherwise.
+ /*!
+ ** \brief Implementation of get_compute().
+ **
+ ** \arg Ng Neighborhood to use.
+ **
+ ** \warning Do not call this method, use get_compute()
+ ** instead.
+ */
template<class N>
image_out_type
- get_compute(const oln::abstract::neighborhood<N> &Ng)
+ get_compute_impl(const oln::abstract::neighborhood<N> &Ng)
{
std::vector<point_type> I(get_processing_order());
@@ -167,20 +204,16 @@
return output;
}
- // access to attributes
- // i index of component
- const attr_type &get_attr(const comp_type &i) const
- {
- return data_[find_root(i)];
- }
-
- comp_type ncomps() const
+ /*!
+ ** \brief Implementation of ncomps_impl().
+ **
+ ** \warning Do not call this method, use ncomps() instead.
+ */
+ comp_type ncomps_impl() const
{
return ncomps_;
}
- protected:
-
unsigned capacity_chunk;
unsigned capacity;
const image_type &input_;
@@ -193,99 +226,6 @@
};
} // !abstract
-
-
- template<class T, class DestType, class A, class Exact = mlc::final>
- struct cc:
- public abstract::tarjan_with_attr<typename mlc::exact_vt<cc<T, DestType, A, Exact>,
- Exact>::ret>
- {
-
- typedef oln_point_type(T) point_type;
- typedef oln_value_type(T) data_type;
- // typedef abstract::image<T> image_type;
- typedef oln_concrete_type(T) image_type;
-
- typedef unsigned comp_type;
-
- typedef cc<T, DestType, A, Exact> self_type; /*< Self type of the class.*/
- typedef mlc_exact_vt_type(self_type, Exact) exact_type;
- typedef abstract::tarjan_with_attr<exact_type> super_type;
-
- cc(const image_type &ima,
- const attr_env_type(A) &env): super_type(ima, env)
- {
- }
-
- std::vector<point_type> get_processing_order_impl()
- {
- std::vector<point_type> res;
- oln_iter_type(image_type) it(input_);
-
- res.reserve(input_.npoints());
- for_all(it)
- res.push_back(it);
- return res;
- }
-
- void
- mark_set_impl(const point_type &x)
- {
- if (parent_.size() == parent_.capacity())
- {
- capacity = parent_.capacity() + capacity_chunk;
- parent_.reserve(capacity);
- comp_value_.reserve(capacity);
- }
- to_comp_[x] = ncomps_ + 1;
- data_.push_back(A(input_, x, env_));
- parent_.push_back(ncomps_ + 1);
- //comp_value_.push_back(input_[x]);
- comp_value_.push_back(ncomps_ + 1);
- }
-
- void
- uni_impl(const point_type& n, const point_type& p)
- {
- comp_type r = find_root(to_comp_[n]);
- precondition(to_comp_[n] <= ncomps_);
- precondition(to_comp_[p] <= (ncomps_ + 1));
- if (r != to_comp_[p])
- if (input_[n] == input_[p])
- {
- if (to_comp_[p] == (ncomps_ + 1)) // first merge of p component
- {
- precondition(r < comp_value_.capacity());
- //comp_value_[r] = input_[p];
- // comp_value_[to_comp_[p]] = comp_value_[r];
- data_[r] += data_[to_comp_[p]];
- precondition(r <= ncomps_);
- to_comp_[p] = r;
- }
- else
- {
- precondition(r < parent_.capacity());
- data_[parent_[to_comp_[p]]] += data_[parent_[r]];
- // comp_value_[parent_[to_comp_[p]]] = ntg::min(comp_value_[parent_[r]],
- // comp_value_[parent_[to_comp_[p]]]);
- parent_[r] = parent_[to_comp_[p]];
-
- }
- }
- // precondition(comp_value_[parent_[r]] <= 255);
- }
- };
-
- // traits specialization
- template <typename T, typename DestType, typename A, typename Exact>
- struct tarjan_traits<cc<T, DestType, A, Exact> >
- {
- typedef T input_type;
- typedef typename mute<T, DestType>::ret output_type;
- typedef A attr_type;
- };
-
-
} // end of namespace tarjan
} // end of namespace topo
Index: olena/oln/topo/tarjan/tarjan.hh
--- olena/oln/topo/tarjan/tarjan.hh Wed, 31 Mar 2004 19:11:41 +0200 palma_g (oln/m/47_tarjan.hh 1.1 644)
+++ olena/oln/topo/tarjan/tarjan.hh Thu, 01 Apr 2004 13:49:48 +0200 palma_g (oln/m/47_tarjan.hh 1.1 644)
@@ -1,12 +1,12 @@
-// Copyright (C) 2001, 2002, 2003, 2004 EPITA Research and Development Laboratory
+// Copyright (C) 2004 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
+// 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.
//
@@ -45,6 +45,7 @@
namespace topo {
/// \brief Implementation of tarjan set.
namespace tarjan {
+
/// Forward declaration for tarjan traits.
template <typename Exact>
struct tarjan_traits;
@@ -61,10 +62,10 @@
template <typename Exact>
struct tarjan: public mlc_hierarchy::any<Exact>
{
- typedef oln_tarjan_input_type(Exact) input_type;
- typedef oln_tarjan_output_type(Exact) image_out_type;
- typedef oln_value_type(image_out_type) comp_type;
- typedef oln_point_type(input_type) point_type;
+ typedef oln_tarjan_input_type(Exact) input_type; ///< Type of input image.
+ typedef oln_tarjan_output_type(Exact) image_out_type; ///< Type of output image.
+ typedef oln_value_type(image_out_type) comp_type; ///< Type of components.
+ typedef oln_point_type(input_type) point_type; ///< Point type of image to process.
/*!
** \brief Run the algorithm.
--
Giovanni Palma
EPITA - promo 2005 - membre d'EpX - LRDE
Mob. : +33 (0)6 60 97 31 74
2
2
Index: olena/ChangeLog
from Niels Van Vliet <niels(a)lrde.epita.fr>
* olena/oln/io/gz_stream.hh: Fix doc.
* olena/oln/morpho/extrema.hxx: Likewise.
* olena/oln/convol/nagao.hh: Likewise.
* olena/oln/transforms/dwt.hh: Likewise.
+2004-04-02 Niels Van Vliet <niels(a)lrde.epita.fr>
* olena/oln/morpho/laplacian.inc (laplacian): Remove slarger_t.
Add the parameter DestValue. Fix doc.
* olena/tests/morpho/tests/md5_morpho_laplacian_inc1: Change the
Index: olena/oln/io/gz_stream.hh
--- olena/oln/io/gz_stream.hh Mon, 15 Mar 2004 19:59:55 +0100 thivol_d
(oln/f/17_gz_stream. 1.10 640)
+++ olena/oln/io/gz_stream.hh Fri, 02 Apr 2004 18:11:23 +0200 van-vl_n
(oln/f/17_gz_stream. 1.10 640)
@@ -39,16 +39,11 @@
namespace io {
- /*! \namespace gz
- ** \brief gz namespace
- */
+ /// Functions for gz files
namespace gz {
- /*! \class zfilebuf
- **
- ** Performs operation on compressed files.
- */
+ ///Performs operation on compressed files.
class zfilebuf : public std::streambuf
{
public:
@@ -301,11 +296,7 @@
};
- /*! \class zfilestream_common
- **
- ** Define an interface for compressed file stream manipulation.
- */
-
+ ///Define an interface for compressed file stream manipulation.
class zfilestream_common : virtual public std::ios
{
friend class zifstream;
@@ -365,10 +356,7 @@
};
- /*! \class zifstream
- **
- ** Read only zstream.
- */
+ /// Read only zstream.
class zifstream : public zfilestream_common, public std::istream
{
public:
@@ -434,10 +422,7 @@
}
- /*! \class zomanip
- **
- ** Define a pair func / val to perform manipulation on zofstream.
- */
+ /// Define a pair func / val to perform manipulation on zofstream.
template<class T> class zomanip
{
friend zofstream &operator<< <T>(zofstream &, const zomanip<T> &);
Index: olena/oln/morpho/extrema.hxx
--- olena/oln/morpho/extrema.hxx Thu, 18 Mar 2004 18:24:14 +0100
van-vl_n (oln/j/4_extrema.hx 1.17 640)
+++ olena/oln/morpho/extrema.hxx Fri, 02 Apr 2004 18:08:44 +0200
van-vl_n (oln/j/4_extrema.hx 1.17 640)
@@ -25,9 +25,7 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*!
-** \brief Internal purpose only.
-*/
+
namespace internal {
/*!
Index: olena/oln/transforms/dwt.hh
--- olena/oln/transforms/dwt.hh Fri, 19 Mar 2004 14:01:37 +0100 palma_g
(oln/i/35_dwt.hh 1.2.1.4.1.12 640)
+++ olena/oln/transforms/dwt.hh Fri, 02 Apr 2004 18:24:42 +0200 van-vl_n
(oln/i/35_dwt.hh 1.2.1.4.1.12 640)
@@ -71,9 +71,6 @@
} // end of namespace transforms
- /*!
- ** \brief internal stuff.
- */
namespace internal
{
/// \brief Value of ln(2).
@@ -89,8 +86,8 @@
template <class T, unsigned N, class Self>
struct wavelet_coeffs_
{
- typedef T value_t; ///< \brType of data used.
- typedef Self self_t; ///< \brief Self type.
+ typedef T value_t; ///< Type of data used.
+ typedef Self self_t; ///< Self type.
public:
Index: olena/oln/convol/nagao.hh
--- olena/oln/convol/nagao.hh Sat, 27 Mar 2004 15:56:32 +0100 van-vl_n
(oln/m/22_nagao.hh 1.2 600)
+++ olena/oln/convol/nagao.hh Fri, 02 Apr 2004 18:23:56 +0200 van-vl_n
(oln/m/22_nagao.hh 1.2 600)
@@ -130,7 +130,7 @@
** Each point in the input corresponds to the mean of the
** window in which has the smallest variance.
**
- ** \paran in Input image.
+ ** \param in Input image.
** \param sa array of structuring elements.
**
** \see oln::convol::nagao
1
0
Index: olena/ChangeLog
from Niels Van Vliet <niels(a)lrde.epita.fr>
* olena/oln/morpho/laplacian.inc (laplacian): Remove slarger_t.
Add the parameter DestValue. Fix doc.
* olena/tests/morpho/tests/md5_morpho_laplacian_inc1: Change the
test.
* olena/oln/morpho/watershed.hh: Change the two examples.
Index: olena/oln/morpho/laplacian.inc
--- olena/oln/morpho/laplacian.inc Sun, 14 Mar 2004 18:21:09 +0100
palma_g (oln/41_laplacian. 1.15 640)
+++ olena/oln/morpho/laplacian.inc Fri, 02 Apr 2004 17:08:37 +0200
van-vl_n (oln/41_laplacian. 1.15 640)
@@ -38,7 +38,7 @@
** \code
** #include <oln/basics2d.hh>
** #include <oln/morpho/laplacian.hh>
-** #include <oln/level/compare.hh>
+** #include <oln/convert/stretch.hh>
** #include <ntg/all.hh>
** int main()
** {
@@ -46,11 +46,13 @@
**
** im_type im1(oln::load(IMG_IN "lena256.pgm"));
**
-**
oln::save(oln::morpho::fast::laplacian(oln::convert::bound<ntg::int_u8>(),
+** oln::image2d<ntg::int_s<10> > i10 =
+** oln::morpho::fast::laplacian(oln::convert::bound<ntg::int_s<10> >(),
** im1,
-** oln::win_c8p()),
-** IMG_OUT
"oln_morpho_fast_laplacian.pbm");
-** return 0;
+** oln::win_c8p());
+**
+** oln::save(apply(oln::convert::stretch<ntg::int_u8>(), i10),
+** IMG_OUT "oln_morpho_fast_laplacian.pgm");
** }
** \endcode
**
@@ -82,7 +84,7 @@
** \code
** #include <oln/basics2d.hh>
** #include <oln/morpho/laplacian.hh>
-** #include <oln/level/compare.hh>
+** #include <oln/convert/stretch.hh>
** #include <ntg/all.hh>
** int main()
** {
@@ -90,9 +92,17 @@
**
** im_type im1(oln::load(IMG_IN "lena256.pgm"));
**
-**
oln::save(oln::morpho::fast::laplacian(oln::convert::bound<ntg::int_u8>(),
im1, oln::win_c8p()),
-** IMG_OUT
"oln_morpho_fast_laplacian_overload.pbm");
-** return 0;
+** oln::image2d<ntg::int_s<10> > i10 =
+** oln::morpho::fast::laplacian(oln::convert::bound<ntg::int_s<10> >(),
+** im1,
+** oln::win_c8p());
+**
+** oln::image2d<ntg::int_s<10> > f10 =
+** oln::morpho::fast::laplacian<ntg::int_s<10> >(im1,
+** oln::win_c8p());
+**
+** oln::save(apply(oln::convert::stretch<ntg::int_u8>(),(f10)),
+** IMG_OUT "oln_morpho_fast_laplacian_overload.pgm");
** }
** \endcode
**
@@ -101,13 +111,13 @@
** =>
** \image html oln_morpho_fast_laplacian_overload.png
** \image latex oln_morpho_fast_laplacian_overload.png
-**
-** \todo FIXME: Call the good laplacian, and correct slarger_t type.
*/
-template<class I, class E>
-typename mute<I,oln_value_type(I)::slarger_t>::ret
+template<class DestValue, class I, class E>
+typename mute<I, DestValue>::ret
laplacian(const abstract::non_vectorial_image<I>& input,
const abstract::struct_elt<E>& se)
{
- return laplacian(convert::force<oln_value_type(I)::slarger_t>(),
input, se);
+ return
+ laplacian(convert::force<DestValue>(),
+ input, se);
}
Index: olena/oln/morpho/watershed.hh
--- olena/oln/morpho/watershed.hh Sun, 14 Mar 2004 18:21:09 +0100
palma_g (oln/48_watershed. 1.13 640)
+++ olena/oln/morpho/watershed.hh Fri, 02 Apr 2004 16:18:49 +0200
van-vl_n (oln/48_watershed. 1.13 640)
@@ -65,28 +65,44 @@
** \code
** #include <oln/basics2d.hh>
** #include <oln/morpho/watershed.hh>
- ** #include <oln/level/compare.hh>
** #include <ntg/all.hh>
+ **
+ ** #include <oln/morpho/attribute_closing_opening.hh>
+ ** #include <oln/morpho/gradient.hh>
+ ** #include <oln/convert/stretch.hh>
** int main()
** {
** typedef oln::image2d<ntg::int_u8> im_type;
**
** im_type im1(oln::load(IMG_IN "lena256.pgm"));
**
- ** oln::save(oln::morpho::watershed_seg<ntg::int_u16>(im1,
- **
oln::neighb_c4()),
- ** IMG_OUT "oln_morpho_watershed_seg.pbm");
- ** return 0;
+ ** // Gradient of the image
+ ** im1 = oln::morpho::beucher_gradient(im1, oln::win_c8p());
+ **
+ ** // Remove local minima smaller than 200 pixels
+ ** im1 = oln::morpho::fast::card_closing(im1, oln::neighb_c8(),
+ ** 200);
+ **
+ ** oln::save(im1, IMG_OUT "oln_morpho_watershed_seg_tmp.pgm");
+ **
+ ** // Use the watershed to segment the image
+ ** im_type w = oln::morpho::watershed_seg<ntg::int_u8>(im1,
+ ** oln::neighb_c8());
+ **
+ ** oln::save(oln::convert::stretch_balance<ntg::int_u8>(w),
+ ** IMG_OUT "oln_morpho_watershed_seg.pgm");
** }
** \endcode
**
** \image html lena256_pgm.png
** \image latex lena256_pgm.png
** =>
+ ** \image html oln_morpho_watershed_seg_tmp.png
+ ** \image latex oln_morpho_watershed_seg_tmp.png
+ ** =>
** \image html oln_morpho_watershed_seg.png
** \image latex oln_morpho_watershed_seg.png
**
- ** \todo Find a more pertinent example.
*/
template<class DestValue, class I, class N>
typename mute<I, DestValue>::ret
@@ -127,28 +143,43 @@
** \code
** #include <oln/basics2d.hh>
** #include <oln/morpho/watershed.hh>
- ** #include <oln/level/compare.hh>
** #include <ntg/all.hh>
+ **
+ ** #include <oln/morpho/attribute_closing_opening.hh>
+ ** #include <oln/morpho/gradient.hh>
+ ** #include <oln/convert/stretch.hh>
** int main()
** {
** typedef oln::image2d<ntg::int_u8> im_type;
**
** im_type im1(oln::load(IMG_IN "lena256.pgm"));
**
- ** oln::save(oln::morpho::watershed_con<ntg::int_u16>(im1,
- **
oln::neighb_c4()),
- ** IMG_OUT "oln_morpho_watershed_con.pbm");
- ** return 0;
+ ** // Gradient of the image
+ ** im1 = oln::morpho::beucher_gradient(im1, oln::win_c8p());
+ **
+ ** // Remove local minima smaller than 200 pixels
+ ** im1 = oln::morpho::fast::card_closing(im1, oln::neighb_c8(),
+ ** 200);
+ **
+ ** oln::save(im1, IMG_OUT "oln_morpho_watershed_con_tmp.pgm");
+ **
+ ** // Use the watershed to conment the image
+ ** im_type w = oln::morpho::watershed_con<ntg::int_u8>(im1,
+ ** oln::neighb_c8());
+ **
+ ** oln::save(oln::convert::stretch_balance<ntg::int_u8>(w),
+ ** IMG_OUT "oln_morpho_watershed_con.pgm");
** }
** \endcode
**
** \image html lena256_pgm.png
** \image latex lena256_pgm.png
** =>
+ ** \image html oln_morpho_watershed_con_tmp.png
+ ** \image latex oln_morpho_watershed_con_tmp.png
+ ** =>
** \image html oln_morpho_watershed_con.png
** \image latex oln_morpho_watershed_con.png
- **
- ** \todo Find a more pertinent example.
*/
template<class DestValue, class I, class N>
typename mute<I, DestValue>::ret
Index: olena/tests/morpho/tests/md5_morpho_laplacian_inc1
--- olena/tests/morpho/tests/md5_morpho_laplacian_inc1 Tue, 23 Mar 2004
14:36:33 +0100 palma_g (oln/k/48_md5_morpho 1.1 644)
+++ olena/tests/morpho/tests/md5_morpho_laplacian_inc1 Fri, 02 Apr 2004
17:20:19 +0200 van-vl_n (oln/k/48_md5_morpho 1.1 644)
@@ -10,20 +10,21 @@
int main()
{
-oln::utils::key::value_type data_key[16] = {0x1b, 0x83, 0x53, 0x90,
0xbf, 0xb6, 0x68, 0xad, 0xb3, 0xae, 0xfa, 0xfc, 0xfc, 0x6a, 0x1e, 0x27};
+ oln::utils::key::value_type data_key[16] = {0xbd, 0x5a, 0x43, 0x38, 0x1b,
+ 0xd3, 0xc1, 0x76, 0x52, 0x8b,
+ 0x43, 0xcc, 0xf4, 0x12, 0x6c,
+ 0xa3};
oln::utils::key key(data_key);
- typedef oln::image2d<ntg::
-int_u8> im_type;
+ typedef oln::image2d<ntg::int_u8> im_type;
im_type im1(oln::load(rdata("lena256.pgm")));
- if
(oln::utils::md5(oln::morpho::fast::laplacian(oln::convert::bound<ntg::
-int_u8>(), im1, oln::win_c8p())) == key)
+ if (oln::utils::md5(oln::morpho::fast::laplacian<ntg::int_s<10> >
+ (im1, oln::win_c8p())) == key)
std::cout << "OK" << std::endl;
else
{
std::cout << "FAIL" << std::endl;
return true;
}
- return 0;
}
1
0
Index: olena/ChangeLog
from Niels Van Vliet <niels(a)lrde.epita.fr>
* olena/oln/core/image1d.hh: Return exact_type in clone_.
* olena/oln/core/image2d.hh: Likewise.
* olena/oln/core/image3d.hh: Likewise.
* olena/oln/core/neighborhood2d.hh: Remove a FIXME. Remove operator=.
* olena/oln/core/window2d.hh: Likewise.
* olena/oln/core/w_window2d.hh: Add comments.
* olena/oln/level/cc.hh: Remove headers.
* olena/oln/morpho/top_hat.inc: Remove a FIXME.
* olena/tests/morpher/tests/sq_morph: New file, contains sub
quantifying morpher tests.
* olena/tests/morpher/tests/color_morph: New file, contains color
Index: olena/oln/core/image1d.hh
--- olena/oln/core/image1d.hh Fri, 12 Mar 2004 20:17:58 +0100 thivol_d
(oln/c/47_image1d.hh 1.28.1.2 640)
+++ olena/oln/core/image1d.hh Fri, 02 Apr 2004 12:27:27 +0200 van-vl_n
(oln/c/47_image1d.hh 1.28.1.2 640)
@@ -208,19 +208,11 @@
protected:
- /*! \brief Return a deep copy of the current image.
- **
- ** \warning It may be really dangerous to instantiate a self_type
- ** and not an exact_type if Exact != mlc::final.
- **
- ** \todo FIXME: It may be really dangerous to instantiate a self_type
- ** and not an exact_type if Exact != mlc::final.
- */
-
- self_type
- clone_() const // deep copy
+ /// Return a deep copy of the current image.
+ exact_type
+ clone_() const
{
- self_type output(this->ncols(), this->border());
+ exact_type output(this->ncols(), this->border());
clone_to(output.impl());
return output;
}
Index: olena/oln/core/image2d.hh
--- olena/oln/core/image2d.hh Fri, 12 Mar 2004 20:17:58 +0100 thivol_d
(oln/c/45_image2d.hh 1.30.1.2 640)
+++ olena/oln/core/image2d.hh Fri, 02 Apr 2004 12:28:23 +0200 van-vl_n
(oln/c/45_image2d.hh 1.30.1.2 640)
@@ -210,19 +210,11 @@
protected:
- /*! \brief Return a deep copy of the current image.
- **
- ** \warning It may be really dangerous to instantiate a self_type
- ** and not an exact_type if Exact != mlc::final.
- **
- ** \todo FIXME: It may be really dangerous to instantiate a self_type
- ** and not an exact_type is Exact != mlc::final.
- */
-
- self_type
- clone_() const // deep copy
+ /// Return a deep copy of the current image.
+ exact_type
+ clone_() const
{
- self_type output(this->nrows(), this->ncols(), this->border());
+ exact_type output(this->nrows(), this->ncols(), this->border());
clone_to(output.impl());
return output;
}
Index: olena/oln/core/image3d.hh
--- olena/oln/core/image3d.hh Fri, 12 Mar 2004 20:17:58 +0100 thivol_d
(oln/c/43_image3d.hh 1.27.1.2 640)
+++ olena/oln/core/image3d.hh Fri, 02 Apr 2004 12:28:17 +0200 van-vl_n
(oln/c/43_image3d.hh 1.27.1.2 640)
@@ -208,19 +208,12 @@
protected:
- /*! \brief Return a deep copy of the current image.
- **
- ** \warning It may be really dangerous to instantiate a self_type
- ** and not an exact_type if Exact != mlc::final.
- **
- ** \todo FIXME: It may be really dangerous to instantiate a self_type
- ** and not an exact_type is Exact != mlc::final.
- */
-
- self_type
- clone_() const // deep copy
+ /// Return a deep copy of the current image.
+ exact_type
+ clone_() const
{
- self_type output(this->nslices(), this->nrows(), this->ncols(),
this->border());
+ exact_type output(this->nslices(), this->nrows(),
+ this->ncols(), this->border());
clone_to(output.impl());
return output;
}
Index: olena/oln/core/neighborhood2d.hh
--- olena/oln/core/neighborhood2d.hh Mon, 29 Mar 2004 09:53:11 +0200
odou_s (oln/c/36_neighborho 1.20 640)
+++ olena/oln/core/neighborhood2d.hh Fri, 02 Apr 2004 13:28:46 +0200
van-vl_n (oln/c/36_neighborho 1.20 640)
@@ -141,24 +141,12 @@
add(dpoint_type(crd[i], crd[i+1]));
}
- // io
- /*!
- ** \todo FIXME: it doesn't seem useful. We may remove it
- */
+ // Constructor used in io functions.
neighborhood2d(const io::internal::anything& r) : super_type()
{
r.assign(*this);
}
- /*!
- ** \todo FIXME: it doesn't seem useful. We may remove it
- */
- neighborhood2d&
- operator=(const io::internal::anything& r)
- {
- return r.assign(*this);
- }
-
/// Return the name of the type.
static std::string
name()
Index: olena/oln/core/window2d.hh
--- olena/oln/core/window2d.hh Mon, 29 Mar 2004 09:53:11 +0200 odou_s
(oln/c/14_window2d.h 1.21 640)
+++ olena/oln/core/window2d.hh Fri, 02 Apr 2004 15:47:03 +0200 van-vl_n
(oln/c/14_window2d.h 1.21 640)
@@ -142,24 +142,12 @@
add(dpoint_type(crd[i], crd[i+1]));
}
- // io
- /*!
- ** \todo FIXME: it doesn't seem useful. We may remove it
- */
+ // This constructor is used by functions of io
window2d(const io::internal::anything& r) : super_type()
{
r.assign(*this);
}
- /*!
- ** \todo FIXME: it doesn't seem useful. We may remove it
- */
- window2d&
- operator=(const io::internal::anything& r)
- {
- return r.assign(*this);
- }
-
/// Return the name of the type.
static std::string
name()
Index: olena/oln/core/w_window2d.hh
--- olena/oln/core/w_window2d.hh Mon, 29 Mar 2004 09:53:11 +0200 odou_s
(oln/c/18_w_window2d 1.6.1.15 640)
+++ olena/oln/core/w_window2d.hh Fri, 02 Apr 2004 15:47:40 +0200
van-vl_n (oln/c/18_w_window2d 1.6.1.15 640)
@@ -115,6 +115,7 @@
** \arg arr The array of elements.
** \todo FIXME: this constructor is not in w_window1d.hh nor
w_window3d.hh.
** Is it really useful ?
+ ** This constructor is used to build a chamfer distance.
*/
template<class I, class T2>
w_window2d(const mlc::array2d<I, T2 >& arr) :
Index: olena/oln/level/cc.hh
--- olena/oln/level/cc.hh Tue, 23 Mar 2004 13:37:46 +0100 van-vl_n
(oln/e/20_cc.hh 1.11.1.15 640)
+++ olena/oln/level/cc.hh Fri, 02 Apr 2004 11:58:33 +0200 van-vl_n
(oln/e/20_cc.hh 1.11.1.15 640)
@@ -32,19 +32,12 @@
Connected components.
*/
-# include <oln/basics.hh>
-// FIXME: really need all ?
# include <oln/arith/ops.hh>
-# include <mlc/optional.hh>
-# include <ntg/all.hh>
+# include <oln/core/image.hh>
# include <oln/level/fill.hh>
-# include <oln/level/invert.hh>
-# include <oln/level/compare.hh>
# include <set>
-# include <ntg/core/macros.hh>
-# include <mlc/is_a.hh>
namespace oln {
/*! \brief Level algorithm implementation.
Index: olena/oln/morpho/top_hat.inc
--- olena/oln/morpho/top_hat.inc Thu, 18 Mar 2004 18:24:14 +0100
van-vl_n (oln/39_top_hat.in 1.16 640)
+++ olena/oln/morpho/top_hat.inc Fri, 02 Apr 2004 15:15:20 +0200
van-vl_n (oln/39_top_hat.in 1.16 640)
@@ -375,7 +375,6 @@
** \image html oln_morpho_fast_top_hat_contrast_op_overload.png
** \image latex oln_morpho_fast_top_hat_contrast_op_overload.png
**
-** \todo FIXME: Seems not to work with convert::force converter.
*/
template<class I, class E>
oln_concrete_type(I)
1
0
Index: metalic/ChangeLog
from Giovanni Palma <giovanni(a)lrde.epita.fr>
* mlc/type.hh: Remove static cast.
Index: metalic/mlc/type.hh
--- metalic/mlc/type.hh Mon, 09 Feb 2004 18:57:03 +0100 palma_g (oln/c/21_type.hh 1.28 640)
+++ metalic/mlc/type.hh Thu, 01 Apr 2004 11:33:02 +0200 palma_g (oln/c/21_type.hh 1.28 640)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2002, 2003 EPITA Research and Development Laboratory
+// Copyright (C) 2001, 2002, 2003, 2004 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
@@ -70,7 +70,7 @@
private:
// This stores the actual value of the offset between the this
// pointer and the address of the exact type. This enables diamond
- // shaped hierarchies (static_cast can't and reinterpret_cast or
+ // shaped hierarchies (static_cas can't and reinterpret_cast or
// (Exact*)(void*) cast are unsafe and compiler dependent).
static const int exact_offset;
@@ -105,8 +105,8 @@
public:
typedef E exact_type;
- E& exact() { return static_cast<E&>(*this); }
- const E& exact() const { return static_cast<const E&>(*this); }
+ E& exact() { return dynamic_cast<E&>(*this); }
+ const E& exact() const { return dynamic_cast<const E&>(*this); }
static std::string name()
{
@@ -169,7 +169,7 @@
{
mlc_hierarchy::any_with_diamond<E>::exact_offset =
(const char*)
- static_cast<const mlc_hierarchy::any_with_diamond<E>*>(t)
+ dynamic_cast<const mlc_hierarchy::any_with_diamond<E>*>(t)
- (const char*) t;
mlc_hierarchy::any_with_diamond<E>::offset_assigned = true;
}
--
Giovanni Palma
EPITA - promo 2005 - membre d'EpX - LRDE
Mob. : +33 (0)6 60 97 31 74
2
1
Index: olena/ChangeLog
from Giovanni Palma <giovanni(a)lrde.epita.fr>
* oln/convert/stretch.hh: Add header inclusion.
* oln/topo/tarjan/tarjan.hh: Add file.
* oln/topo/tarjan/tarjan_with_attr.hh: Add file.
* oln/morpho/attributes.hh: Add new attribute.
Index: olena/oln/convert/stretch.hh
--- olena/oln/convert/stretch.hh Sun, 14 Mar 2004 19:03:34 +0100 van-vl_n (oln/f/51_stretch.hh 1.17 600)
+++ olena/oln/convert/stretch.hh Tue, 30 Mar 2004 12:00:36 +0200 palma_g (oln/f/51_stretch.hh 1.17 640)
@@ -30,6 +30,8 @@
# include <mlc/type.hh>
+# include <oln/basics.hh>
+
# include <ntg/basics.hh>
# include <oln/convert/abstract/conversion.hh>
Index: olena/oln/morpho/attributes.hh
--- olena/oln/morpho/attributes.hh Sat, 27 Mar 2004 15:56:32 +0100 van-vl_n (oln/j/45_attributes 1.11 600)
+++ olena/oln/morpho/attributes.hh Tue, 30 Mar 2004 13:55:31 +0200 palma_g (oln/j/45_attributes 1.11 644)
@@ -138,6 +138,17 @@
};
/*!
+ ** \brief "<" operator
+ **
+ ** This is a static dispatcher for the "<" operator.
+ ** This method is abstract.
+ */
+ bool operator<(const exact_type &x) const
+ {
+ mlc_dispatch(less2)(x);
+ };
+
+ /*!
** \brief != operator
**
** This is a static dispatcher for the != operator.
@@ -149,6 +160,16 @@
};
/*!
+ ** \brief conversion to lambda type.
+ **
+ ** \warning Virtual method.
+ */
+ const lambda_type &toLambda() const
+ {
+ mlc_dispatch(toLambda)();
+ };
+
+ /*!
** \brief >= operator implementation.
**
** This is an implementation of the >= operator. Override this
@@ -160,6 +181,20 @@
return !(*this < lambda);
};
+ /*!
+ ** \brief "<" operator implementation.
+ **
+ ** This is an implementation of the < operator. Override this
+ ** method to provide a new implementation of this operator.
+ ** \warning This method SHOULDN'T be called.
+ */
+ bool less2_impl(const exact_type &x) const
+ {
+ return *this < x.toLambda();
+ };
+
+
+
protected:
attribute() {};
@@ -249,14 +284,70 @@
return lambda != value_;
};
+ /*!
+ ** \brief conversion to lambda type implementation.
+ **
+ ** This is an implementation of the toLambda() method.
+ ** Override this method to provide a new implementation.
+ ** \warning This method SHOULDN'T be called .
+ */
+ const lambda_type &toLambda_impl() const
+ {
+ return value_;
+ };
+
protected:
value_type value_; /*!< Value used inside the class. */
};
+ /*-------------------------------*
+ | card with info on other image |
+ *------------------------------*/
+ template <class I, class T = unsigned, class Exact = mlc::final>
+ class card_full_type: public card_type<T,
+ typename mlc::exact_vt<card_full_type<I,
+ T,
+ Exact>,
+ Exact>::ret>
+ {
+ public:
+ typedef card_full_type<I, T, Exact> self_type; /*!< Self type of the class. */
+ attr_type_decl(self_type);
+ typedef card_type<T, exact_type> super_type; ///< Parent class type.
+
+ /*!
+ ** \brief Basic Ctor.
+ **
+ ** \warning After this call, the object is only instantiated
+ ** (not initialized).
+ */
+ card_full_type(): super_type()
+ {
+ };
+
+ /*!
+ ** \brief Ctor from a lambda_type value.
+ */
+ card_full_type(const lambda_type &lambda): super_type(lambda)
+ {
+ };
- /*-----------*
+ /*!
+ ** \brief Ctor from a point and an image.
+ **
+ ** Every parameters are useless.
+ */
+ template <class I2>
+ card_full_type(const abstract::image<I2> &im,
+ const oln_point_type(I2) &p,
+ const env_type &env): super_type(im, p, env)
+ {
+ };
+ };
+
+ /*--------------*
| integral |
- *-----------*/
+ *------------*/
/*!
** \brief Integral attribute.
@@ -1701,6 +1792,17 @@
};
/*!
+ ** \brief Trait specialization for card_full attribute.
+ */
+ template <class I, class T, class Exact>
+ struct attr_traits<card_full_type<I, T, Exact> >
+ {
+ typedef T value_type; ///< Type of data.
+ typedef value_type lambda_type; ///< Type of lambda.
+ typedef env::OtherImageEnv<I> env_type; ///< Type of environment.
+ };
+
+ /*!
** \brief Trait specialization for the maxvalue attribute.
*/
template <class T, class Exact>
Index: olena/oln/topo/tarjan/tarjan_with_attr.hh
--- olena/oln/topo/tarjan/tarjan_with_attr.hh Wed, 31 Mar 2004 19:11:06 +0200 palma_g ()
+++ olena/oln/topo/tarjan/tarjan_with_attr.hh Wed, 31 Mar 2004 18:50:19 +0200 palma_g (oln/m/46_tarjan_wit 644)
@@ -0,0 +1,295 @@
+// Copyright (C) 2001, 2002, 2003, 2004 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, 59 Temple Place - Suite 330, 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 OLENA_TOPO_TARJAN_TARJAN_WITH_ATTR_HH
+# define OLENA_TOPO_TARJAN_TARJAN_WITH_ATTR_HH
+
+# include <oln/topo/tarjan/tarjan.hh>
+# include <oln/morpho/attributes.hh>
+# include <ntg/basics.hh>
+# include <oln/level/fill.hh>
+# include <oln/utils/histogram.hh>
+
+# include <vector>
+# include <map>
+
+namespace oln {
+
+ namespace topo {
+ /// \brief Implementation of tarjan set.
+ namespace tarjan {
+ /// Abstract classes for tarjan based algorithms.
+ namespace abstract {
+
+ template<class Exact>
+ struct tarjan_with_attr: public tarjan<mlc_exact_vt_type(tarjan_with_attr<Exact>, Exact) >
+ {
+ typedef oln_tarjan_input_type(Exact) input_type;
+ typedef oln_point_type(input_type) point_type;
+ typedef oln_value_type(input_type) data_type;
+
+ typedef oln_concrete_type(input_type) image_type;
+ typedef oln_tarjan_output_type(Exact) image_out_type;
+ typedef oln_tarjan_attr_type(Exact) attr_type;
+ typedef attr_env_type(attr_type) env_type;
+ typedef oln_value_type(image_out_type) comp_type;
+
+ tarjan_with_attr(const image_type &ima,
+ const env_type &env):
+ capacity_chunk((ima.npoints() < 100) ? ima.npoints() : (ima.npoints() / 100)),
+ capacity(capacity_chunk),
+ input_(ima),
+ parent_(),
+ to_comp_(ima.size()),
+ comp_value_(),
+ env_(env)
+ {
+ parent_.reserve(capacity);
+ comp_value_.reserve(capacity);
+ data_.reserve(capacity);
+ }
+
+ // abstract methods
+ std::vector<point_type> get_processing_order()
+ {
+ mlc_dispatch(get_processing_order)();
+ }
+
+ void
+ mark_set(const point_type &x)
+ {
+ mlc_dispatch(mark_set)(x);
+ }
+
+ void
+ uni(const point_type& n, const point_type& p)
+ {
+ mlc_dispatch(uni)(n, p);
+ }
+
+ // tells if a point has been proceded
+ bool is_proc(const point_type &p) const
+ {
+ return to_comp_[p] != ntg_sup_val(comp_type);
+ };
+
+ comp_type
+ find_root(const comp_type& x) const
+ {
+ if (parent_[x] != x)
+ return parent_[x] = find_root(parent_[x]);
+ return x;
+ }
+
+ // bool closing = true -> a closing is performed,
+ // an opening otherwise.
+ template<class N>
+ image_out_type
+ get_compute(const oln::abstract::neighborhood<N> &Ng)
+ {
+ std::vector<point_type> I(get_processing_order());
+
+ level::fill(to_comp_, ntg_sup_val(comp_type));
+ to_comp_.border_adapt_assign(Ng.delta(), ntg_sup_val(comp_type));
+ ncomps_ = 0;
+ parent_.push_back(0);
+ comp_value_.push_back(0);
+ data_.push_back(attr_type());
+
+ // We are ready to perform stuff
+ for (unsigned int p = 0; p < I.size(); ++p)
+ {
+ point_type p_p = I[p];
+ mark_set(p_p);
+
+ oln_neighb_type(N) Q_prime(Ng, p_p);
+ for_all (Q_prime)
+ if (is_proc(Q_prime))
+ uni(Q_prime.cur(), p_p);
+ if (to_comp_[p_p] == (ncomps_ + 1)) // new component
+ ++ncomps_;
+ else
+ {
+ comp_value_.pop_back();
+ parent_.pop_back();
+ data_.pop_back();
+ }
+ }
+
+ // Resolving phase
+ std::map<comp_type, comp_type> cmps;
+ comp_type nc = 0;
+ ncomps_ = 0;
+ // unsigned i = 0;
+ for (int p = I.size() - 1; p >= 0; --p)
+ {
+ point_type p_p = I[p];
+ if (cmps.find(comp_value_[find_root(to_comp_[p_p])]) == cmps.end())
+ {
+ ++ncomps_;
+ // ++i;
+ // std::cout << "new component\n";
+ cmps[comp_value_[find_root(to_comp_[p_p])]] = nc;
+ comp_value_[find_root(to_comp_[p_p])] = nc++;
+ }
+ }
+ // std::cout << i << " components\n";
+ image_out_type output(input_.size());
+ for (int p = I.size() - 1; p >= 0; --p)
+ {
+ point_type p_p = I[p];
+ output[p_p] = comp_value_[find_root(to_comp_[p_p])];
+ }
+ return output;
+ }
+
+ // access to attributes
+ // i index of component
+ const attr_type &get_attr(const comp_type &i) const
+ {
+ return data_[find_root(i)];
+ }
+
+ comp_type ncomps() const
+ {
+ return ncomps_;
+ }
+
+ protected:
+
+ unsigned capacity_chunk;
+ unsigned capacity;
+ const image_type &input_;
+ mutable std::vector<comp_type> parent_;
+ typename oln::mute<input_type, comp_type>::ret to_comp_;// comp number from a point
+ comp_type ncomps_;
+ std::vector<oln_value_type(image_out_type)> comp_value_;
+ std::vector<attr_type> data_;
+ env_type env_;
+ };
+ } // !abstract
+
+
+
+ template<class T, class DestType, class A, class Exact = mlc::final>
+ struct cc:
+ public abstract::tarjan_with_attr<typename mlc::exact_vt<cc<T, DestType, A, Exact>,
+ Exact>::ret>
+ {
+
+ typedef oln_point_type(T) point_type;
+ typedef oln_value_type(T) data_type;
+ // typedef abstract::image<T> image_type;
+ typedef oln_concrete_type(T) image_type;
+
+ typedef unsigned comp_type;
+
+ typedef cc<T, DestType, A, Exact> self_type; /*< Self type of the class.*/
+ typedef mlc_exact_vt_type(self_type, Exact) exact_type;
+ typedef abstract::tarjan_with_attr<exact_type> super_type;
+
+ cc(const image_type &ima,
+ const attr_env_type(A) &env): super_type(ima, env)
+ {
+ }
+
+ std::vector<point_type> get_processing_order_impl()
+ {
+ std::vector<point_type> res;
+ oln_iter_type(image_type) it(input_);
+
+ res.reserve(input_.npoints());
+ for_all(it)
+ res.push_back(it);
+ return res;
+ }
+
+ void
+ mark_set_impl(const point_type &x)
+ {
+ if (parent_.size() == parent_.capacity())
+ {
+ capacity = parent_.capacity() + capacity_chunk;
+ parent_.reserve(capacity);
+ comp_value_.reserve(capacity);
+ }
+ to_comp_[x] = ncomps_ + 1;
+ data_.push_back(A(input_, x, env_));
+ parent_.push_back(ncomps_ + 1);
+ //comp_value_.push_back(input_[x]);
+ comp_value_.push_back(ncomps_ + 1);
+ }
+
+ void
+ uni_impl(const point_type& n, const point_type& p)
+ {
+ comp_type r = find_root(to_comp_[n]);
+ precondition(to_comp_[n] <= ncomps_);
+ precondition(to_comp_[p] <= (ncomps_ + 1));
+ if (r != to_comp_[p])
+ if (input_[n] == input_[p])
+ {
+ if (to_comp_[p] == (ncomps_ + 1)) // first merge of p component
+ {
+ precondition(r < comp_value_.capacity());
+ //comp_value_[r] = input_[p];
+ // comp_value_[to_comp_[p]] = comp_value_[r];
+ data_[r] += data_[to_comp_[p]];
+ precondition(r <= ncomps_);
+ to_comp_[p] = r;
+ }
+ else
+ {
+ precondition(r < parent_.capacity());
+ data_[parent_[to_comp_[p]]] += data_[parent_[r]];
+ // comp_value_[parent_[to_comp_[p]]] = ntg::min(comp_value_[parent_[r]],
+ // comp_value_[parent_[to_comp_[p]]]);
+ parent_[r] = parent_[to_comp_[p]];
+
+ }
+ }
+ // precondition(comp_value_[parent_[r]] <= 255);
+ }
+ };
+
+ // traits specialization
+ template <typename T, typename DestType, typename A, typename Exact>
+ struct tarjan_traits<cc<T, DestType, A, Exact> >
+ {
+ typedef T input_type;
+ typedef typename mute<T, DestType>::ret output_type;
+ typedef A attr_type;
+ };
+
+
+ } // end of namespace tarjan
+
+ } // end of namespace topo
+
+} // end of namespace oln
+
+#endif // ! OLENA_TOPO_TARJAN_TARJAN_WITH_ATTR_HH
Index: olena/oln/topo/tarjan/tarjan.hh
--- olena/oln/topo/tarjan/tarjan.hh Wed, 31 Mar 2004 19:11:06 +0200 palma_g ()
+++ olena/oln/topo/tarjan/tarjan.hh Wed, 31 Mar 2004 18:42:56 +0200 palma_g (oln/m/47_tarjan.hh 644)
@@ -0,0 +1,153 @@
+// Copyright (C) 2001, 2002, 2003, 2004 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, 59 Temple Place - Suite 330, 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 OLENA_TOPO_TARJAN_TARJAN_HH
+# define OLENA_TOPO_TARJAN_TARJAN_HH
+# include <oln/basics.hh>
+
+// Macros for extract information on tarjan algorithms.
+# define oln_tarjan_input_type(T) typename oln::topo::tarjan::tarjan_traits<T>::input_type
+# define oln_tarjan_output_type(T) typename oln::topo::tarjan::tarjan_traits<T>::output_type
+# define oln_tarjan_attr_type(T) typename oln::topo::tarjan::tarjan_traits<T>::attr_type
+
+
+// # define oln_tarjan_input_type(T) typename oln::topo::tarjan::tarjan_traits<mlc_exact_type(T)>::input_type
+// # define oln_tarjan_output_type(T) typename oln::topo::tarjan::tarjan_traits<mlc_exact_type(T)>::output_type
+// # define oln_tarjan_attr_type(T) typename oln::topo::tarjan::tarjan_traits<mlc_exact_type(T)>::attr_type
+
+
+namespace oln {
+
+ namespace topo {
+ /// \brief Implementation of tarjan set.
+ namespace tarjan {
+ /// Forward declaration for tarjan traits.
+ template <typename Exact>
+ struct tarjan_traits;
+
+ /// Abstract classes for tarjan based algorithms.
+ namespace abstract {
+ /*!
+ ** \brief Top of tarjan hierarchy.
+ **
+ ** \param I Type of image to process.
+ ** \param D Type of data of the wanted image.
+ ** \param Exact Exact type of the class.
+ */
+ template <typename Exact>
+ struct tarjan: public mlc_hierarchy::any<Exact>
+ {
+ typedef oln_tarjan_input_type(Exact) input_type;
+ typedef oln_tarjan_output_type(Exact) image_out_type;
+ typedef oln_value_type(image_out_type) comp_type;
+ typedef oln_point_type(input_type) point_type;
+
+ /*!
+ ** \brief Run the algorithm.
+ **
+ **
+ ** \warning Implement get_compute_impl to be able to use
+ ** this method.
+ */
+ template<class N>
+ image_out_type
+ get_compute(const oln::abstract::neighborhood<N> &Ng)
+ {
+ mlc_dispatch(get_compute)(Ng);
+ }
+
+ /*!
+ ** \brief Give the number of component found.
+ **
+ ** \warning Implement ncomps_impl to be able to use
+ ** this method.
+ */
+ comp_type ncomps() const
+ {
+ mlc_dispatch(ncomps)();
+ }
+
+ protected:
+ /*!
+ ** \brief Abstract method to get the processing order.
+ **
+ ** \warning Implement get_processing_order_impl to be able
+ ** to use this method.
+ */
+ std::vector<point_type>
+ get_processing_order()
+ {
+ mlc_dispatch(get_processing_order)();
+ }
+
+ /*!
+ ** \brief Mark a point as a new component.
+ **
+ ** \warning Implement mark_set_impl to be able to use this
+ ** method.
+ */
+ void
+ mark_set(const point_type &x)
+ {
+ mlc_dispatch(mark_set)(x);
+ }
+
+ /*!
+ ** \brief Perform an union between two components.
+ **
+ ** \warning Implement uni_impl to be able to use this
+ ** method.
+ */
+ void
+ uni(const point_type& n, const point_type& p)
+ {
+ mlc_dispatch(uni)(n, p);
+ }
+
+ /*!
+ ** \brief tell if a point has already been processed.
+ **
+ **
+ ** \warning Implement is_proc_impl to be able to use this
+ ** method.
+ */
+ bool is_proc(const point_type &p) const
+ {
+ mlc_dispatch(is_proc)(p);
+ };
+
+ /*!
+ ** \brief Make the class abstract.
+ */
+ tarjan() {}
+ };
+ } // end of namespace abstract
+ } // end of namespace tarjan
+ } // end of namespace topo
+} // end of namespace oln
+
+#endif // ! OLENA_TOPO_TARJAN_TARJAN_HH
--
Giovanni Palma
EPITA - promo 2005 - membre d'EpX - LRDE
Mob. : +33 (0)6 60 97 31 74
2
3