Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- 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
March 2007
- 7 participants
- 73 discussions
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Add generalised_point concept.
* tests/core/sparse_image.cc,
* tests/core/rle_image.cc: remove print from tests.
* oln/core/rle/rle_pset.hh, oln/core/concept/iterator_on_points.hh,
* oln/core/gen/dpoints_piter.hh, oln/core/internal/box.hh,
* oln/core/internal/piter_adaptor.hh: there are now derived from iterator_on_point_base class.
* oln/core/concept/iterator.hh: add virtual for diamond inheritance.
* oln/core/concept/point.hh: remove useless traits declarations.
(there are now declare in generalised_point_class).
* oln/core/concept/generalised_point.hh: New, generalised_point class.
* oln/core/internal/image_base.hh: remove dead code.
* oln/core/internal/iterator_on_points_base.hh: New iterator_on_point_base class for
factorize some code on point iterators.
oln/core/concept/generalised_point.hh | 68 ++++++++++++++++++
oln/core/concept/iterator.hh | 2
oln/core/concept/iterator_on_points.hh | 5 +
oln/core/concept/point.hh | 12 +--
oln/core/gen/dpoints_piter.hh | 9 +-
oln/core/internal/box.hh | 9 +-
oln/core/internal/image_base.hh | 2
oln/core/internal/iterator_on_points_base.hh | 97 +++++++++++++++++++++++++++
oln/core/internal/piter_adaptor.hh | 8 +-
oln/core/rle/rle_pset.hh | 14 +--
tests/core/rle_image.cc | 45 ------------
tests/core/sparse_image.cc | 37 ----------
12 files changed, 196 insertions(+), 112 deletions(-)
Index: tests/core/sparse_image.cc
--- tests/core/sparse_image.cc (revision 911)
+++ tests/core/sparse_image.cc (working copy)
@@ -6,37 +6,6 @@
#include <oln/core/sparse/sparse_image.hh>
#include <oln/core/encode/sparse_encode.hh>
-template <typename Ps>
-void test(const Ps& pset)
-{
- typename Ps::fwd_piter it (pset);
-
- for (it.start(); it.is_valid(); it.next())
- std::cout << it.to_point() << std::endl;
-}
-
-template <typename Ps>
-void rtest(const Ps& pset)
-{
- typename Ps::bkd_piter it (pset);
-
- for (it.start(); it.is_valid(); it.next())
- std::cout << it.to_point() << std::endl;
-}
-
-
- template <typename I>
- void print(I& ima)
-{
- typename I::piter it (ima.points());
-
- for (it.start(); it.is_valid(); it.next())
- {
- std::cout << (oln::point2d) it << std::endl;
- std::cout << ima(it) << std::endl;
- }
-}
-
int main()
{
@@ -46,7 +15,6 @@
oln::sparse_image<oln::point2d, int> sparse2;
ima2d(oln::point2d(0, 4)) = 5;
- oln::debug::print(ima2d);
std::vector<int> values;
int a =5;
@@ -58,12 +26,7 @@
sparse.insert(q, 3, values);
- oln::debug::print(sparse);
-
- std::cout << "encode sparse" << std::endl;
sparse2 = sparse_encode(ima2d);
- oln::debug::print(sparse2);
-
return 0;
}
Index: tests/core/rle_image.cc
--- tests/core/rle_image.cc (revision 911)
+++ tests/core/rle_image.cc (working copy)
@@ -7,38 +7,6 @@
#include <oln/core/encode/rle_encode.hh>
-template <typename Ps>
-void test(const Ps& pset)
-{
- typename Ps::fwd_piter it (pset);
-
- for (it.start(); it.is_valid(); it.next())
- std::cout << it.to_point() << std::endl;
-}
-
-template <typename Ps>
-void rtest(const Ps& pset)
-{
- typename Ps::bkd_piter it (pset);
-
- for (it.start(); it.is_valid(); it.next())
- std::cout << it.to_point() << std::endl;
-}
-
-
- template <typename I>
- void print(I& ima)
-{
- typename I::piter it (ima.points());
-
- for (it.start(); it.is_valid(); it.next())
- {
- std::cout << (oln::point2d) it << std::endl;
- std::cout << ima(it) << std::endl;
- }
-}
-
-
int main()
{
oln::point2d p(0,1), q(2,2), r(3, 0);
@@ -51,24 +19,11 @@
rle.insert(p, 5, 4);
rle.insert(q, 8, 9);
- std::cout << my_set.has(q) << std::endl;
- test(my_set);
- std::cout << "reverse" << std::endl;
- rtest(my_set);
- std::cout << "ima" << std::endl;
- print(rle);
- oln::debug::print(rle);
- std::cout << rle.points().npoints() << std::endl;
-
- std::cout << "encode rle" << std::endl;
oln::image2d<int> ima2d (1, 5);
ima2d(oln::point2d(0, 4)) = 5;
- oln::debug::print(ima2d);
-
rle2 = rle_encode(ima2d);
- oln::debug::print(rle2);
return 0;
}
Index: oln/core/rle/rle_pset.hh
--- oln/core/rle/rle_pset.hh (revision 911)
+++ oln/core/rle/rle_pset.hh (working copy)
@@ -35,7 +35,7 @@
# include <oln/core/internal/point_set_base.hh>
-# include <oln/core/concept/iterator_on_points.hh>
+# include <oln/core/internal/iterator_on_points_base.hh>
# include <oln/core/gen/fbbox.hh>
@@ -190,7 +190,7 @@
struct super_trait_< rle_pset_fwd_piter_<P> >
{
typedef rle_pset_fwd_piter_<P> current;
- typedef Iterator_on_Points<current> ret;
+ typedef internal::iterator_on_points_base<current> ret;
};
// Virtual types
@@ -208,9 +208,9 @@
** P must be a point type
*/
template <typename P>
- class rle_pset_fwd_piter_ : public Iterator_on_Points<rle_pset_fwd_piter_<P> >
+ class rle_pset_fwd_piter_ : public internal::iterator_on_points_base<rle_pset_fwd_piter_<P> >
{
- typedef Iterator_on_Points< rle_pset_fwd_piter_<P> > super;
+ typedef internal::iterator_on_points_base< rle_pset_fwd_piter_<P> > super;
typedef rle_pset_fwd_piter_<P> current;
public:
stc_using(point);
@@ -328,7 +328,7 @@
struct super_trait_< rle_pset_bkd_piter_<P> >
{
typedef rle_pset_bkd_piter_<P> current;
- typedef Iterator_on_Points<current> ret;
+ typedef internal::iterator_on_points_base<current> ret;
};
// Virtual type
@@ -345,9 +345,9 @@
** P must be a point type
*/
template <typename P>
- class rle_pset_bkd_piter_ : public Iterator_on_Points<rle_pset_bkd_piter_<P> >
+ class rle_pset_bkd_piter_ : public internal::iterator_on_points_base<rle_pset_bkd_piter_<P> >
{
- typedef Iterator_on_Points< rle_pset_bkd_piter_<P> > super;
+ typedef internal::iterator_on_points_base< rle_pset_bkd_piter_<P> > super;
typedef rle_pset_bkd_piter_<P> current;
public:
stc_using(point);
Index: oln/core/concept/iterator_on_points.hh
--- oln/core/concept/iterator_on_points.hh (revision 911)
+++ oln/core/concept/iterator_on_points.hh (working copy)
@@ -30,6 +30,8 @@
# define OLN_CORE_CONCEPT_ITERATOR_ON_POINTS_HH
# include <ostream>
+
+# include <oln/core/concept/generalised_point.hh>
# include <oln/core/concept/iterator.hh>
# include <oln/core/concept/point.hh>
@@ -40,7 +42,8 @@
/// Concept-class "Iterator_on_Points".
template <typename Exact>
- struct Iterator_on_Points : public Iterator<Exact>
+ struct Iterator_on_Points : public Iterator<Exact>,
+ virtual public Generalised_Point<Exact>
{
stc_typename(point);
Index: oln/core/concept/iterator.hh
--- oln/core/concept/iterator.hh (revision 911)
+++ oln/core/concept/iterator.hh (working copy)
@@ -44,7 +44,7 @@
/// Concept-class "Iterator".
template <typename Exact>
- struct Iterator : public Any<Exact>
+ struct Iterator : virtual public Any<Exact>
{
void start();
void next();
Index: oln/core/concept/point.hh
--- oln/core/concept/point.hh (revision 911)
+++ oln/core/concept/point.hh (working copy)
@@ -30,11 +30,14 @@
# define OLN_CORE_CONCEPT_POINT_HH
# include <mlc/value.hh>
+
+# include <oln/core/concept/generalised_point.hh>
# include <oln/core/concept/grid.hh>
# include <oln/core/concept/operators.hh>
+
namespace oln
{
/// Instant value.
@@ -44,14 +47,9 @@
/// Concept-class "Point".
template <typename Exact>
- struct Point : public Any<Exact>
+ struct Point : public Generalised_Point<Exact>
{
- stc_typename(grid);
- stc_typename(dim);
- stc_typename(coord);
- stc_typename(dpoint);
-
- enum { n = mlc_value(dim) };
+ stc_using_from(Generalised_Point, dpoint);
/// Operator ==.
bool op_equal_(const Exact& rhs) const;
Index: oln/core/concept/generalised_point.hh
--- oln/core/concept/generalised_point.hh (revision 0)
+++ oln/core/concept/generalised_point.hh (revision 0)
@@ -0,0 +1,68 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_CONCEPT_GENERALISED_POINTS_HH
+# define OLN_CORE_CONCEPT_GENERALISED_POINTS_HH
+
+namespace oln
+{
+
+ /// FIXME: Instant value.
+ // oln_decl_instant_value(point);
+
+
+ // Generalised_Point concept
+
+ template <typename Exact>
+ struct Generalised_Point : virtual public Any<Exact>
+ {
+ stc_typename(grid);
+ stc_typename(dim);
+ stc_typename(coord);
+ stc_typename(dpoint);
+
+ enum { n = mlc_value(dim) };
+
+ protected:
+ Generalised_Point();
+ };
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Exact>
+ Generalised_Point<Exact>::Generalised_Point()
+ {
+ };
+
+
+# endif // OLN_INCLUDE_ONLY
+
+}
+
+#endif // !OLN_CORE_CONCEPT_GENERALISED_POINTS_HH
Index: oln/core/gen/dpoints_piter.hh
--- oln/core/gen/dpoints_piter.hh (revision 911)
+++ oln/core/gen/dpoints_piter.hh (working copy)
@@ -31,6 +31,7 @@
# include <oln/core/concept/window.hh>
# include <oln/core/concept/neighborhood.hh>
# include <oln/core/concept/image.hh>
+# include <oln/core/internal/iterator_on_points_base.hh>
# include <oln/core/internal/dpoints_piter_impl.hh>
@@ -51,7 +52,7 @@
struct super_trait_< dpoints_fwd_piter_<P> >
{
typedef dpoints_fwd_piter_<P> current__;
- typedef Iterator_on_Points<current__> ret;
+ typedef internal::iterator_on_points_base<current__> ret;
};
@@ -65,7 +66,7 @@
// Forward point iterator class on a set of dpoints.
template <typename P>
- class dpoints_fwd_piter_ : public Iterator_on_Points< dpoints_fwd_piter_<P> >,
+ class dpoints_fwd_piter_ : public internal::iterator_on_points_base< dpoints_fwd_piter_<P> >,
public internal::dpoints_fwd_piter_impl_<P>
{
public:
@@ -98,7 +99,7 @@
struct super_trait_< dpoints_bkd_piter_<P> >
{
typedef dpoints_bkd_piter_<P> current__;
- typedef Iterator_on_Points<current__> ret;
+ typedef internal::iterator_on_points_base<current__> ret;
};
@@ -112,7 +113,7 @@
/// Backward point iterator class on a set of dpoints.
template <typename P>
- class dpoints_bkd_piter_ : public Iterator_on_Points< dpoints_bkd_piter_<P> >,
+ class dpoints_bkd_piter_ : public internal::iterator_on_points_base< dpoints_bkd_piter_<P> >,
public internal::dpoints_bkd_piter_impl_<P>
{
public:
Index: oln/core/internal/box.hh
--- oln/core/internal/box.hh (revision 911)
+++ oln/core/internal/box.hh (working copy)
@@ -29,6 +29,7 @@
# define OLN_CORE_INTERNAL_BOX_HH
# include <oln/core/internal/point_set_base.hh>
+# include <oln/core/internal/iterator_on_points_base.hh>
namespace oln
@@ -116,14 +117,14 @@
struct super_trait_< box_fwd_piter_<B> >
{
typedef box_fwd_piter_<B> current__;
- typedef Iterator_on_Points<current__> ret;
+ typedef internal::iterator_on_points_base<current__> ret;
};
template <typename B>
struct super_trait_<box_bkd_piter_<B> >
{
typedef box_bkd_piter_<B> current__;
- typedef Iterator_on_Points<current__> ret;
+ typedef internal::iterator_on_points_base<current__> ret;
};
@@ -145,7 +146,7 @@
/// Class box_fwd_piter_<P>.
template <typename B>
- class box_fwd_piter_ : public Iterator_on_Points< box_fwd_piter_<B> >,
+ class box_fwd_piter_ : public internal::iterator_on_points_base< box_fwd_piter_<B> >,
private mlc::assert_< mlc_is_a(B, Point_Set) >
{
typedef box_fwd_piter_<B> current;
@@ -171,7 +172,7 @@
/// Class box_bkd_piter_<B>.
template <typename B>
- class box_bkd_piter_ : public Iterator_on_Points< box_bkd_piter_<B> >,
+ class box_bkd_piter_ : public internal::iterator_on_points_base< box_bkd_piter_<B> >,
private mlc::assert_< mlc_is_a(B, Point_Set) >
{
typedef box_bkd_piter_<B> current;
Index: oln/core/internal/image_base.hh
--- oln/core/internal/image_base.hh (revision 911)
+++ oln/core/internal/image_base.hh (working copy)
@@ -148,8 +148,6 @@
// Final.
typedef stc::final< stc::is<Image> > category;
- // FIXME:
- //typedef stc::final< box_<point__> > box;
typedef stc::final <typename pset__::box> box;
typedef stc::final< oln_grid(point__) > grid;
typedef stc::final< oln_dpoint(point__) > dpoint;
Index: oln/core/internal/piter_adaptor.hh
--- oln/core/internal/piter_adaptor.hh (revision 911)
+++ oln/core/internal/piter_adaptor.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef OLN_CORE_INTERNAL_PITER_ADAPTOR_HH
# define OLN_CORE_INTERNAL_PITER_ADAPTOR_HH
-# include <oln/core/concept/iterator_on_points.hh>
+# include <oln/core/internal/iterator_on_points_base.hh>
namespace oln
@@ -43,7 +43,7 @@
template <typename Exact>
struct super_trait_< internal::piter_adaptor_<Exact> >
{
- typedef Iterator_on_Points<Exact> ret;
+ typedef internal::iterator_on_points_base<Exact> ret;
};
@@ -65,9 +65,9 @@
// defined over other types of iterator on points.
template <typename Exact>
- class piter_adaptor_ : public Iterator_on_Points<Exact>
+ class piter_adaptor_ : public internal::iterator_on_points_base<Exact>
{
- typedef Iterator_on_Points<Exact> super;
+ typedef internal::iterator_on_points_base<Exact> super;
public:
stc_using(point);
Index: oln/core/internal/iterator_on_points_base.hh
--- oln/core/internal/iterator_on_points_base.hh (revision 0)
+++ oln/core/internal/iterator_on_points_base.hh (revision 0)
@@ -0,0 +1,97 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INTERNAL_ITERATOR_ON_POINTS_BASE_HH
+# define OLN_CORE_INTERNAL_ITERATOR_ON_POINTS_BASE_HH
+
+# include <oln/core/concept/iterator_on_points.hh>
+
+namespace oln
+{
+
+ // implementation
+
+
+ // Forward Declarations
+
+ namespace internal {
+ template <typename Exact>
+ struct iterator_on_points_base;
+ };
+
+ // Super type
+
+ template <typename Exact>
+ struct super_trait_< internal::iterator_on_points_base<Exact> >
+ {
+ typedef Iterator_on_Points<Exact> ret;
+ };
+
+ // Virtual types
+
+ template <typename Exact>
+ struct vtypes< internal::iterator_on_points_base<Exact> >
+ {
+ typedef stc::abstract point;
+
+ typedef stc_deferred(point) point__;
+ typedef stc::final<typename point__::grid> grid;
+ typedef stc::final<typename point__::coord> coord;
+ typedef stc::final<typename point__::dim> dim;
+ typedef stc::final<typename point__::dpoint> dpoint;
+ };
+
+
+
+namespace internal
+{
+ // iterator_on_points_base class
+
+ template <typename Exact>
+ class iterator_on_points_base : public Iterator_on_Points<Exact>
+ {
+
+ protected:
+ iterator_on_points_base();
+ };
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Exact>
+ iterator_on_points_base<Exact>::iterator_on_points_base()
+ {
+ }
+
+# endif // !OLN_INCLUDE_ONLY
+}
+
+
+
+}
+
+#endif // !OLN_CORE_INTERNAL_ITERATOR_ON_POINTS_BASE_HH
1
0
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Fix 'Make check morpho' / 'morpho'. draft cc_tarjan .
* olena/tests/algorithms/basic_morpho.cc: .
* olena/oln/morpho/dilation.hh: .
* olena/oln/morpho/cc_tarjan.cc: New.
* olena/oln/morpho/erosion.hh: .
* olena/oln/level/apply.hh: .
* olena/oln/core/2d/image2d.hh: .
* olena/oln/core/internal/image_base.hh: .
oln/core/2d/image2d.hh | 3 -
oln/core/internal/image_base.hh | 16 ++---
oln/level/apply.hh | 2
oln/morpho/cc_tarjan.cc | 107 +++++++++++++++++++++++++++++++++++++++
oln/morpho/dilation.hh | 25 +++++----
oln/morpho/erosion.hh | 25 +++++----
tests/algorithms/basic_morpho.cc | 60 ++++++---------------
7 files changed, 164 insertions(+), 74 deletions(-)
Index: olena/tests/algorithms/basic_morpho.cc
--- olena/tests/algorithms/basic_morpho.cc (revision 910)
+++ olena/tests/algorithms/basic_morpho.cc (working copy)
@@ -17,6 +17,15 @@
#include <oln/debug/print.hh>
+
+template <typename I>
+void my_test(I ima, int i)
+{
+ oln_piter(I) p1(ima.points());
+ for_all(p1)
+ assert(ima(p1) == i);
+}
+
int main()
{
using namespace oln;
@@ -31,54 +40,19 @@
for_all(p1)
ima(p1) = i++ % 2;
- std::cout << "ima" << std::endl;
- debug::print(ima);
+ my_test( (morpho::elementary_erosion(ima + c4)).image(), 0);
+ my_test( (morpho::elementary_dilation(ima + c4)).image(), 1 );
- I tmp = (morpho::elementary_erosion(ima + c4)).image();
- p1 = tmp.points();
- for_all(p1)
- assert(tmp(p1) == 0);
+ my_test( (morpho::elementary_opening(ima + c4)).image(), 0);
- // std::cout << "elementary_dilation" << std::endl;
- tmp = (morpho::elementary_dilation(ima + c4)).image();
- p1 = tmp.points();
- for_all(p1)
- assert(tmp(p1) == 1);
+ my_test( (morpho::elementary_closing(ima + c4)).image(), 1);
- // std::cout << "erosion_w" << std::endl;
- tmp = morpho::erosion(ima, win3x3);
- p1 = tmp.points();
- for_all(p1)
- assert(tmp(p1) == 0);
+ my_test( morpho::erosion(ima, win3x3), 0);
- // std::cout << "dilation_w" << std::endl;
- tmp = morpho::dilation(ima, win3x3);
- p1 = tmp.points();
- for_all(p1)
- assert(tmp(p1) == 1);
-
- // std::cout << "elementary_opening" << std::endl;
- tmp = (morpho::elementary_opening(ima + c4)).image();
- p1 = tmp.points();
- for_all(p1)
- assert(tmp(p1) == 0);
+ my_test( morpho::dilation(ima, win3x3), 1);
- // std::cout << "elementary_closing" << std::endl;
- tmp = (morpho::elementary_closing(ima + c4)).image();
- p1 = (tmp.points());
- for_all(p1)
- assert(tmp(p1) == 1);
+ my_test( morpho::opening(ima, win3x3), 0);
- // std::cout << "opening" << std::endl;
- tmp = morpho::opening(ima, win3x3);
- p1 = (tmp.points());
- for_all(p1)
- assert(tmp(p1) == 1);
-
- // std::cout << "closing" << std::endl;
- debug::print( morpho::closing(ima, win3x3) );
- p1 = (tmp.points());
- for_all(p1)
- assert(tmp(p1) == 1);
+ my_test( morpho::closing(ima, win3x3), 1);
}
Index: olena/oln/morpho/dilation.hh
--- olena/oln/morpho/dilation.hh (revision 910)
+++ olena/oln/morpho/dilation.hh (working copy)
@@ -54,21 +54,24 @@
template <typename I, typename W>
oln_plain(I)
- dilation_(const Image<I>& input, const Window<W>& win)
+ dilation_on_function_(const Image<I>&,
+ const I& input,
+ const Window<W>& win)
{
border::fill(input, oln_min(oln_value(I)));
accumulator::max_<oln_value(I)> max;
return level::apply_local(max, input, win);
}
- template <typename I>
+ template <typename I, typename W>
oln_plain(I)
dilation_on_set_(const Image<I>&,
- const I& input)
+ const I& input,
+ const Window<W>& win)
{
border::fill(input, oln_min(oln_value(I)));
accumulator::or_<oln_value(I)> accu_or;
- return level::apply_local(accu_or, input);
+ return level::apply_local(accu_or, input, win);
}
// FIXME: Add a fast version.
@@ -76,16 +79,18 @@
// Impl facade.
- template <typename I>
- oln_plain(I) dilation_(const Image<I>& input)
+ template <typename I, typename W>
+ oln_plain(I) dilation_(const Image<I>& input,
+ const Window<W>& win)
{
- return dilation_on_function_(exact(input), exact(input));
+ return dilation_on_function_(exact(input), exact(input), win);
}
- template <typename I>
- oln_plain(I) dilation_(const Binary_Image<I>& input)
+ template <typename I, typename W>
+ oln_plain(I) dilation_(const Binary_Image<I>& input,
+ const Window<W>& win)
{
- return dilation_on_set_(exact(input), exact(input));
+ return dilation_on_set_(exact(input), exact(input), win);
}
} // end of namespace oln::morpho::impl
Index: olena/oln/morpho/cc_tarjan.cc
--- olena/oln/morpho/cc_tarjan.cc (revision 0)
+++ olena/oln/morpho/cc_tarjan.cc (revision 0)
@@ -0,0 +1,107 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_MORPHO_DILATION_HH
+# define OLN_MORPHO_DILATION_HH
+
+namespace oln
+{
+
+ namespace morpho
+ {
+
+ template <typename I>
+ oln_point(I) find_root(const oln_point(I)& x)
+ {
+ if (parent[x] != x)
+ {
+ parent[x] = find_root(parent[x]);
+ return parent(x);
+ }
+ return x;
+ }
+
+ template <typename I>
+ void do_union(const oln_point(I)& n,
+ const oln_point(I)& p,
+ const oln_plain_value(I, oln_point(I))& parent)
+ {
+ oln_point(I) r = find_root(n);
+ if (r != p)
+ parent(r) = p;
+ }
+
+ template <typename I>
+ oln_plain_value(I, unsigned)
+ cc_tarjan(const Binary_Image<I>& input)
+ {
+ oln_plain_value(I, unsigned) output;
+ prepare(output, with, input);
+
+ oln_plain_value(I, oln_point(I)) parent;
+ prepare(parent, with, input);
+
+ // Init
+ unsigned current_label = 0;
+ oln_plain(I) is_processed;
+ prepare(is_processed, with, input);
+ oln_piter(I) p(input.points());
+ for_all(p)
+ is_processed(p) = false; // FIXME : built with.
+
+
+ // Fist pass
+ oln_piter(I) p(input.points());
+ for_all(p)
+ {
+ oln_niter(I) n(p, input);
+ for_all(n)
+ {
+ if ( is_processed(n) )
+ do_union(n, p, parent);
+ }
+ is_processed(p) = true;
+ }
+
+
+ // Second pass
+ oln_piter(I) p2(input.points());
+ for_all(p2)
+ {
+ if ( parent(p) == p )
+ output(p) = ++current_label;
+ else
+ output(p) = output(parent(p));
+ }
+ }
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+
+#endif // ! OLN_MORPHO_DILATION_HH
Index: olena/oln/morpho/erosion.hh
--- olena/oln/morpho/erosion.hh (revision 910)
+++ olena/oln/morpho/erosion.hh (working copy)
@@ -54,21 +54,24 @@
template <typename I, typename W>
oln_plain(I)
- erosion_(const Image<I>& input, const Window<W>& win)
+ erosion_on_function_(const Image<I>&,
+ const I& input,
+ const Window<W>& win)
{
border::fill(input, oln_max(oln_value(I)));
accumulator::min_<oln_value(I)> min;
return level::apply_local(min, input, win);
}
- template <typename I>
+ template <typename I, typename W>
oln_plain(I)
erosion_on_set_(const Image<I>&,
- const I& input)
+ const I& input,
+ const Window<W>& win)
{
border::fill(input, true);
accumulator::and_<oln_value(I)> accu_and;
- return level::apply_local(accu_and, input);
+ return level::apply_local(accu_and, input, win);
}
// FIXME: Add a fast version.
@@ -76,16 +79,18 @@
// Impl facade.
- template <typename I>
- oln_plain(I) erosion_(const Image<I>& input)
+ template <typename I, typename W>
+ oln_plain(I) erosion_(const Image<I>& input,
+ const Window<W>& win)
{
- return erosion_on_function_(exact(input), exact(input));
+ return erosion_on_function_(exact(input), exact(input), win);
}
- template <typename I>
- oln_plain(I) erosion_(const Binary_Image<I>& input)
+ template <typename I, typename W>
+ oln_plain(I) erosion_(const Binary_Image<I>& input,
+ const Window<W>& win)
{
- return erosion_on_set_(exact(input), exact(input));
+ return erosion_on_set_(exact(input), exact(input), win);
}
} // end of namespace oln::morpho::impl
Index: olena/oln/level/apply.hh
--- olena/oln/level/apply.hh (revision 910)
+++ olena/oln/level/apply.hh (working copy)
@@ -66,7 +66,7 @@
typedef typename F::result result;
oln_plain_value(I, result) output;
- init(output, with, input);
+ prepare(output, with, input);
oln_piter(I) p(input.points());
for_all(p)
output(p) = f(input(p));
Index: olena/oln/core/2d/image2d.hh
--- olena/oln/core/2d/image2d.hh (revision 910)
+++ olena/oln/core/2d/image2d.hh (working copy)
@@ -213,8 +213,7 @@
box2d b;
bool box_ok = init(b, with, dat);
postcondition(box_ok);
- array2d_<T,int>* ptr = new array2d_<T,int>(b.pmin().row(), //FIXME
- //: *.
+ array2d_<T,int>* ptr = new array2d_<T,int>(b.pmin().row(),
b.pmin().col(),
b.pmax().row(),
b.pmax().col());
Index: olena/oln/core/internal/image_base.hh
--- olena/oln/core/internal/image_base.hh (revision 910)
+++ olena/oln/core/internal/image_base.hh (working copy)
@@ -434,21 +434,21 @@
// init
- template <typename P, typename I>
- bool init_(typename internal::image_base_<I>::box* this_, const internal::image_base_<I>& data);
+ template <typename I>
+ bool init_(typename I::box* this_, const internal::image_base_<I>& data);
template <typename Target, typename I>
bool init_(Any<Target>* this_, const internal::single_image_morpher_<I>& data);
- template <typename P, typename I> // for disambiguation purpose
+ template <typename I> // for disambiguation purpose
bool
- init_(typename internal::image_base_<I>::box** this_, const internal::single_image_morpher_<I>& data);
+ init_(typename I::box* this_, const internal::single_image_morpher_<I>& data);
# ifndef OLN_INCLUDE_ONLY
- template <typename P, typename I>
- bool init_(typename internal::image_base_<I>::box** this_, const internal::image_base_<I>& data)
+ template <typename I>
+ bool init_(typename I::box* this_, const internal::image_base_<I>& data)
{
*this_ = data.bbox();
return true;
@@ -460,9 +460,9 @@
return init(*this_, with, data.image());
}
- template <typename P, typename I>
+ template <typename I>
bool
- init_(typename internal::image_base_<I>::box** this_, const internal::single_image_morpher_<I>& data)
+ init_(typename I::box* this_, const internal::single_image_morpher_<I>& data)
{
*this_ = data.bbox();
return true;
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Update point set hierarchy with Box.
* oln/level/apply_inplace.hh: Fix.
* oln/core/concept/point_set.hh (include): Update.
(operator<<): Add decl.
* oln/core/gen/pset_compare.hh (operator<=, op_leq_),
(operator>=, op_geq_, operator>, op_greater_): New.
* oln/core/internal/op_pset_such_as_fp2b.hh (box): New.
* oln/core/internal/box.hh (include): Update.
(pmin, pmax): Rename as...
(impl_pmin, impl_pmax): ...these.
(set_box): Remove; move code into...
(box): ...this ctor.
(box_fwd_piter_, box_bkd_piter_): Strengthen sigs;
Remove version without arg.
(b_): Add &.
* oln/core/internal/point_set_base.hh (point_set_selector_):
Simplify.
(super_trait_): Update.
(point_set_base_): Change inheritance to point_set_selector_.
* oln/core/internal/utils.hh (pair): New overload.
* oln/core/internal/op_image_restricted_to_pset.hh: Add
precondition and postconditions.
core/concept/point_set.hh | 15 +++--
core/gen/pset_compare.hh | 75 +++++++++++++++++++++++----
core/internal/box.hh | 74 ++++++--------------------
core/internal/op_image_restricted_to_pset.hh | 3 +
core/internal/op_pset_such_as_fp2b.hh | 1
core/internal/point_set_base.hh | 27 ++-------
core/internal/utils.hh | 28 +++++++++-
level/apply_inplace.hh | 4 -
8 files changed, 133 insertions(+), 94 deletions(-)
Index: oln/level/apply_inplace.hh
--- oln/level/apply_inplace.hh (revision 908)
+++ oln/level/apply_inplace.hh (working copy)
@@ -42,7 +42,7 @@
template <typename F, typename I>
void
- apply_inplace(const Function_v2v<F>& f, Mutable_Image<I>& input)
+ apply_inplace(const Function_v2v<F>& f, Mutable_Image<I>& input);
template <typename R, typename A, typename I>
void
@@ -83,7 +83,7 @@
void
apply_inplace(R (*f)(A), Mutable_Image<I>& input)
{
- impl::apply_inplace_(functorize_v2v(fun), exact(input));
+ impl::apply_inplace_(functorize_v2v(f), exact(input));
}
# endif
Index: oln/core/concept/point_set.hh
--- oln/core/concept/point_set.hh (revision 908)
+++ oln/core/concept/point_set.hh (working copy)
@@ -29,8 +29,7 @@
# define OLN_CORE_CONCEPT_POINT_SET_HH
# include <iostream>
-# include <oln/core/concept/point.hh>
-# include <oln/core/concept/iterator.hh> // for "for_all"
+# include <oln/core/concept/iterator_on_points.hh>
namespace oln
@@ -85,6 +84,9 @@
template <typename Ps>
std::ostream& operator<<(std::ostream& ostr, const Point_Set<Ps>& pts);
+ template <typename B>
+ std::ostream& operator<<(std::ostream& ostr, const Box<B>& b);
+
# ifndef OLN_INCLUDE_ONLY
@@ -151,14 +153,19 @@
std::ostream& operator<<(std::ostream& ostr, const Point_Set<Ps>& pts)
{
ostr << "{ ";
- typename Ps::piter p(pts);
+ oln_piter(Ps) p(pts);
for_all(p)
ostr << p << ' '; // FIXME: Add ','?
return ostr << " }";
}
+ template <typename B>
+ std::ostream& operator<<(std::ostream& ostr, const Box<B>& b)
+ {
+ return ostr << "{ " << b.pmin() << " .. " << b.pmax() << " }";
+ }
-# endif
+# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln
Index: oln/core/gen/pset_compare.hh
--- oln/core/gen/pset_compare.hh (revision 908)
+++ oln/core/gen/pset_compare.hh (working copy)
@@ -42,6 +42,15 @@
template <typename L, typename R>
bool operator < (const Point_Set<L>& lhs, const Point_Set<R>& rhs);
+ template <typename L, typename R>
+ bool operator <= (const Point_Set<L>& lhs, const Point_Set<R>& rhs);
+
+ template <typename L, typename R>
+ bool operator > (const Point_Set<L>& lhs, const Point_Set<R>& rhs);
+
+ template <typename L, typename R>
+ bool operator >= (const Point_Set<L>& lhs, const Point_Set<R>& rhs);
+
# ifndef OLN_INCLUDE_ONLY
@@ -72,16 +81,13 @@
return true;
}
- /*
// Version for Boxes.
- FIXME: Activate.
template <typename L, typename R>
bool op_eq_(const Box<L>& lhs, const Box<R>& rhs)
{
return lhs.pmin() = rhs.pmin() and lhs.pmax() = rhs.pmax();
}
- */
// Point_Set L < Point_Set R
@@ -109,23 +115,49 @@
return true;
}
- /*
- // Version for Boxes.
- FIXME: Activate.
+
+ // Box L <= Box R.
+
template <typename L, typename R>
- bool op_less_(const Box<L>& lhs, const Box<R>& rhs)
+ bool op_leq_(const Box<L>& lhs, const Box<R>& rhs)
{
- // subset test (i.e., lhs <= rhs)
for (unsigned i = 0; i < L::n; ++i)
{
if (lhs.pmin()[i] < rhs.pmin()[i] or lhs.pmax()[i] > rhs.pmax()[i])
return false;
}
- // proper (strict) test
- return lhs != rhs;
+ return true;
+ }
+
+ // Box L < Box R.
+
+ template <typename L, typename R>
+ bool op_less_(const Box<L>& lhs, const Box<R>& rhs)
+ {
+ return op_leq_(lhs, rhs) and lhs != rhs;
+ }
+
+ // Box L >= Box R.
+
+ template <typename L, typename R>
+ bool op_geq_(const Box<L>& lhs, const Box<R>& rhs)
+ {
+ for (unsigned i = 0; i < L::n; ++i)
+ {
+ if (lhs.pmin()[i] > rhs.pmin()[i] or lhs.pmax()[i] < rhs.pmax()[i])
+ return false;
+ }
+ return true;
+ }
+
+ // Box L > Box R.
+
+ template <typename L, typename R>
+ bool op_greater_(const Box<L>& lhs, const Box<R>& rhs)
+ {
+ return op_geq_(lhs, rhs) and lhs != rhs;
}
- */
} // end of namespace oln::impl
@@ -141,12 +173,33 @@
}
template <typename L, typename R>
+ bool operator <= (const Point_Set<L>& lhs, const Point_Set<R>& rhs)
+ {
+ assert_same_grid_<L, R>::check();
+ return impl::op_leq_(exact(lhs), exact(rhs));
+ }
+
+ template <typename L, typename R>
bool operator < (const Point_Set<L>& lhs, const Point_Set<R>& rhs)
{
assert_same_grid_<L, R>::check();
return impl::op_less_(exact(lhs), exact(rhs));
}
+ template <typename L, typename R>
+ bool operator >= (const Point_Set<L>& lhs, const Point_Set<R>& rhs)
+ {
+ assert_same_grid_<L, R>::check();
+ return impl::op_geq_(exact(lhs), exact(rhs));
+ }
+
+ template <typename L, typename R>
+ bool operator > (const Point_Set<L>& lhs, const Point_Set<R>& rhs)
+ {
+ assert_same_grid_<L, R>::check();
+ return impl::op_greater_(exact(lhs), exact(rhs));
+ }
+
# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln
Index: oln/core/internal/op_pset_such_as_fp2b.hh
--- oln/core/internal/op_pset_such_as_fp2b.hh (revision 908)
+++ oln/core/internal/op_pset_such_as_fp2b.hh (working copy)
@@ -64,6 +64,7 @@
template <typename S, typename F>
struct vtypes< internal::current >
{
+ typedef oln_box(S) box;
typedef oln_point(S) point;
typedef pset_such_as_fp2b_fwd_piter_<S, F> fwd_piter;
typedef pset_such_as_fp2b_bkd_piter_<S, F> bkd_piter;
Index: oln/core/internal/box.hh
--- oln/core/internal/box.hh (revision 908)
+++ oln/core/internal/box.hh (working copy)
@@ -28,9 +28,6 @@
#ifndef OLN_CORE_INTERNAL_BOX_HH
# define OLN_CORE_INTERNAL_BOX_HH
-//# include <oln/core/concept/point.hh>
-# include <oln/core/concept/point_set.hh>
-# include <oln/core/concept/iterator_on_points.hh>
# include <oln/core/internal/point_set_base.hh>
@@ -89,10 +86,10 @@
bool impl_has(const point& p) const;
const Exact& impl_bbox() const;
- const point& pmin() const;
- point& pmin();
- const point& pmax() const;
- point& pmax();
+ const point& impl_pmin() const;
+ point& impl_pmin();
+ const point& impl_pmax() const;
+ point& impl_pmax();
protected:
box_();
@@ -105,11 +102,6 @@
}; // end of class oln::box_<P>
- template <typename Exact>
- std::ostream& operator<<(std::ostream& ostr, const box_<Exact>& b)
- {
- return ostr << "{ " << b.pmin() << " .. " << b.pmax() << " }";
- }
} // end of namespace internal
@@ -161,9 +153,7 @@
public:
stc_using(point);
- box_fwd_piter_();
- box_fwd_piter_(const B& b);
- void set_box(const B& b);
+ box_fwd_piter_(const Point_Set<B>& b);
void impl_start();
void impl_next();
@@ -173,8 +163,8 @@
const point* impl_point_adr() const;
private:
- B b_;
- point p_, nop_;
+ const B& b_;
+ point nop_, p_;
};
@@ -189,9 +179,7 @@
public:
stc_using(point);
- box_bkd_piter_();
- box_bkd_piter_(const B& b);
- void set_box(const B& b);
+ box_bkd_piter_(const Point_Set<B>& b);
void impl_start();
void impl_next();
@@ -201,8 +189,8 @@
const point* impl_point_adr() const;
private:
- B b_;
- point p_, nop_;
+ const B& b_;
+ point nop_, p_;
};
@@ -275,7 +263,7 @@
template <typename Exact>
const typename box_<Exact>::point&
- box_<Exact>::pmin() const
+ box_<Exact>::impl_pmin() const
{
for (unsigned i = 0; i < n; ++i)
invariant(this->pmin_[i] <= this->pmax_[i]);
@@ -284,7 +272,7 @@
template <typename Exact>
const typename box_<Exact>::point&
- box_<Exact>::pmax() const
+ box_<Exact>::impl_pmax() const
{
for (unsigned i = 0; i < n; ++i)
invariant(this->pmax_[i] >= this->pmin_[i]);
@@ -293,14 +281,14 @@
template <typename Exact>
typename box_<Exact>::point&
- box_<Exact>::pmin()
+ box_<Exact>::impl_pmin()
{
return this->pmin_;
}
template <typename Exact>
typename box_<Exact>::point&
- box_<Exact>::pmax()
+ box_<Exact>::impl_pmax()
{
return this->pmax_;
}
@@ -308,23 +296,10 @@
// -------------------- box_fwd_piter_<B>
-
- template <typename B>
- box_fwd_piter_<B>::box_fwd_piter_()
- {
- }
-
template <typename B>
- box_fwd_piter_<B>::box_fwd_piter_(const B& b)
+ box_fwd_piter_<B>::box_fwd_piter_(const Point_Set<B>& b)
+ : b_(exact(b))
{
- this->set_box(b);
- }
-
- template <typename B>
- void
- box_fwd_piter_<B>::set_box(const B& b)
- {
- b_ = b;
nop_ = b_.pmax();
++nop_[0];
p_ = nop_;
@@ -385,23 +360,10 @@
// -------------------- box_bkd_piter_<P>
-
- template <typename B>
- box_bkd_piter_<B>::box_bkd_piter_()
- {
- }
-
template <typename B>
- box_bkd_piter_<B>::box_bkd_piter_(const B& b)
- {
- this->set_box(b);
- }
-
- template <typename B>
- void
- box_bkd_piter_<B>::set_box(const B& b)
+ box_bkd_piter_<B>::box_bkd_piter_(const Point_Set<B>& b)
+ : b_(exact(b))
{
- b_ = b;
nop_ = b_.pmin();
--nop_[0];
p_ = nop_;
Index: oln/core/internal/point_set_base.hh
--- oln/core/internal/point_set_base.hh (revision 908)
+++ oln/core/internal/point_set_base.hh (working copy)
@@ -38,15 +38,12 @@
namespace internal
{
- template <bool Is_box, typename Exact>
- struct point_set_selector_;
-
- template <typename Exact>
- struct point_set_selector_< true, Exact > : public Box<Exact>
+ template <typename Box_ptr, typename Exact>
+ struct point_set_selector_ : public Point_Set<Exact>
{};
template <typename Exact>
- struct point_set_selector_< false, Exact > : public Point_Set<Exact>
+ struct point_set_selector_< Exact*, Exact > : public Box<Exact>
{};
} // end of namespace oln::internal
@@ -56,28 +53,20 @@
// point_set_base_ class
- /// Fwd decls.
+ // Fwd decls.
namespace internal { template <typename Exact> struct point_set_base_; }
template <typename P> class gen_box;
- /// Super type.
+ // Super type.
template <typename Exact>
struct super_trait_< internal::point_set_base_<Exact> >
{
- typedef Point_Set<Exact> ret;
-
- /*
- FIXME: Activate to replace the above code.
-
- typedef stc_deferred(box) box__;
- typedef mlc::eq_<box__, Exact> test__;
- typedef internal::point_set_selector_<mlc_bool(test__), Exact> ret;
- */
+ typedef internal::point_set_selector_< stc_deferred(box)*, Exact > ret;
};
- /// Virtual types.
+ // Virtual types.
template <typename Exact>
struct vtypes< internal::point_set_base_<Exact> >
{
@@ -101,7 +90,7 @@
/// Base class for point sets.
template <typename Exact>
- struct point_set_base_ : public Point_Set<Exact> // FIXME: Change inheritance.
+ struct point_set_base_ : public super_trait_< point_set_base_<Exact> >::ret
{
protected:
point_set_base_();
Index: oln/core/internal/utils.hh
--- oln/core/internal/utils.hh (revision 908)
+++ oln/core/internal/utils.hh (working copy)
@@ -96,10 +96,34 @@
};
template <typename T1, typename T2>
- struct pair< T1, T2* >;
+ struct pair< T1*, T2* >
+ {
+ typedef pair<T1*,T2*> self_t;
+
+ // Not impled.
+ pair();
+ pair(const self_t&);
+ void operator=(const self_t&);
+ // end of Not impled.
+
+ pair(T1* p_first, T2* p_second)
+ : first(*p_first),
+ second(*p_second)
+ {
+ precondition(p_first != 0);
+ precondition(p_second != 0);
+ }
+ T1& first;
+ T2& second;
+ ~pair()
+ {
+ delete &first;
+ delete &second;
+ }
+ };
template <typename T1, typename T2>
- struct pair< T1*, T2* >;
+ struct pair< T1, T2* >;
/// Simple triplet class.
Index: oln/core/internal/op_image_restricted_to_pset.hh
--- oln/core/internal/op_image_restricted_to_pset.hh (revision 908)
+++ oln/core/internal/op_image_restricted_to_pset.hh (working copy)
@@ -129,6 +129,7 @@
template <typename I, typename S>
current::special_op_(I& ima, S& subset)
{
+ precondition(subset <= ima.points());
this->data_ = new data(ima, subset);
}
@@ -187,6 +188,7 @@
bool subset_ok = init(this_->data__()->second, with, dat);
postcondition(image_ok);
postcondition(subset_ok);
+ postcondition(this_->points() <= this_->image().points());
return image_ok and subset_ok;
}
@@ -202,6 +204,7 @@
bool subset_ok = init(target.data__()->second, with, dat);
postcondition(image_ok);
postcondition(subset_ok);
+ postcondition(target.points() <= target.image().points());
return image_ok and subset_ok;
}
1
0
24 Mar '07
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Adapt gen_box and point1d class to the new box hierarchy.
* tests/core/image1d.cc, oln/core/rle/rle_pset.hh,
* core/internal/point_set_base.hh: change vtypes.
* oln/core/1d/box1d.hh: box1d is know a real class.
* oln/core/2d/box2d.hh: add a constructor.
* oln/core/gen/box.hh: adapt gen_box.
* oln/core/internal/box.hh: fix a bug.
oln/core/1d/box1d.hh | 60 ++++++
oln/core/2d/box2d.hh | 12 -
oln/core/gen/box.hh | 344 +-----------------------------------
oln/core/internal/box.hh | 53 ++---
oln/core/internal/point_set_base.hh | 3
oln/core/rle/rle_pset.hh | 1
tests/core/image1d.cc | 1
7 files changed, 108 insertions(+), 366 deletions(-)
Index: tests/core/image1d.cc
--- tests/core/image1d.cc (revision 907)
+++ tests/core/image1d.cc (working copy)
@@ -38,6 +38,7 @@
// Fill a 1D image using its iterator.
image1d<char> ima1(3);
+ image1d<char>::box box1 = ima1.points();
image1d<char>::piter p1(ima1.points());
for_all(p1)
ima1(p1) = 1;
Index: oln/core/rle/rle_pset.hh
--- oln/core/rle/rle_pset.hh (revision 907)
+++ oln/core/rle/rle_pset.hh (working copy)
@@ -61,6 +61,7 @@
{
typedef P point;
+ typedef gen_box<P> box;
typedef rle_pset_fwd_piter_<P> fwd_piter;
typedef rle_pset_bkd_piter_<P> bkd_piter;
};
Index: oln/core/1d/box1d.hh
--- oln/core/1d/box1d.hh (revision 907)
+++ oln/core/1d/box1d.hh (working copy)
@@ -35,8 +35,64 @@
namespace oln
{
- // FIXME: box1d should be an actual type, not an alias...
- typedef gen_box<point1d> box1d;
+ // Forward declarations
+ struct box1d;
+
+ // Super type
+ template <>
+ struct super_trait_< box1d >
+ {
+ typedef box1d current;
+ typedef internal::box_<box1d> ret;
+ };
+
+ // Virtual types
+ template <>
+ struct vtypes<box1d>
+ {
+ typedef point1d point;
+ typedef box1d box;
+ };
+
+ // Class box1d
+ class box1d : public internal::box_< box1d >
+ {
+ typedef box1d current;
+ typedef internal::box_< box1d > super;
+ public:
+ // Note: we can't use stc_using because box1d isn't a templated class
+ typedef super::point point;
+
+ box1d();
+ box1d(const box1d::from_to_t& dat);
+ box1d(const point1d& pmin, const point1d& pmax);
+ template <typename D>
+ box1d(const internal::initializer_<D>& data);
+ };
+
+# ifndef OLN_INCLUDE_ONLY
+
+ box1d::box1d()
+ {
+ }
+
+ box1d::box1d(const box1d::from_to_t& dat) :
+ super(dat)
+ {
+ }
+
+ box1d::box1d(const point1d& pmin, const point1d& pmax) :
+ super(pmin, pmax)
+ {
+ }
+
+ template <typename D>
+ box1d::box1d(const internal::initializer_<D>& data) :
+ super(data)
+ {
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln
Index: oln/core/2d/box2d.hh
--- oln/core/2d/box2d.hh (revision 907)
+++ oln/core/2d/box2d.hh (working copy)
@@ -36,10 +36,6 @@
namespace oln
{
- // Fwd decl.
- template <typename P> class box_;
-
-
// Forward declarations
struct box2d;
@@ -71,6 +67,8 @@
box2d();
box2d(const box2d::from_to_t& dat);
box2d(const point2d& pmin, const point2d& pmax);
+ template <typename D>
+ box2d(const internal::initializer_<D>& data);
};
namespace internal
@@ -103,6 +101,12 @@
{
}
+ template <typename D>
+ box2d::box2d(const internal::initializer_<D>& data) :
+ super(data)
+ {
+ }
+
namespace internal
{
Index: oln/core/gen/box.hh
--- oln/core/gen/box.hh (revision 907)
+++ oln/core/gen/box.hh (working copy)
@@ -31,7 +31,7 @@
# include <oln/core/concept/point.hh>
# include <oln/core/concept/iterator_on_points.hh>
-# include <oln/core/internal/point_set_base.hh>
+# include <oln/core/internal/box.hh>
namespace oln
@@ -40,8 +40,6 @@
// Forward declarations.
template <typename P> class gen_box;
- template <typename P> class gen_box_fwd_piter_;
- template <typename P> class gen_box_bkd_piter_;
// Super type declaration.
@@ -49,7 +47,7 @@
struct super_trait_< gen_box<P> >
{
typedef gen_box<P> current__;
- typedef internal::point_set_base_<current__> ret;
+ typedef internal::box_<current__> ret;
};
@@ -58,150 +56,35 @@
struct vtypes< gen_box<P> >
{
typedef P point;
- typedef gen_box_fwd_piter_<P> fwd_piter;
- typedef gen_box_bkd_piter_<P> bkd_piter;
+ typedef gen_box<P> box;
};
/// Generic box class based on a point class.
template <typename P>
- class gen_box : public internal::point_set_base_< gen_box<P> >,
+ class gen_box : public internal::box_< gen_box<P> >,
private mlc::assert_< mlc_is_a(P, Point) >
{
typedef gen_box<P> current;
- typedef internal::point_set_base_<current> super;
-
- typedef internal::initializer_<
- internal::pair< internal::from_t<P>, internal::to_t<P> >
- > from_to_t;
-
+ typedef internal::box_<current> super;
public:
-
stc_using(point);
stc_using(box);
- private:
- typedef stc_type(point, dim) dim__;
- enum { n = mlc_value(dim__) };
public:
gen_box();
gen_box(const P& pmin, const P& pmax);
- gen_box(const from_to_t& data);
+ gen_box(const typename gen_box<P>::from_to_t& data);
template <typename D>
gen_box(const internal::initializer_<D>& data);
- unsigned impl_npoints() const;
- bool impl_has(const P& p) const;
- const gen_box<P>& impl_bbox() const;
-
- const P& pmin() const;
- P& pmin();
- const P& pmax() const;
- P& pmax();
-
- protected:
- point pmin_, pmax_;
-
}; // end of class oln::gen_box<P>
- template <typename P>
- std::ostream& operator<<(std::ostream& ostr, const gen_box<P>& b)
- {
- return ostr << "{ " << b.pmin() << " .. " << b.pmax() << " }";
- }
-
-
- // -------------------- iterators on gen_box<P>
-
-
-
-
- /// Super types.
-
- template <typename P>
- struct super_trait_< gen_box_fwd_piter_<P> >
- {
- typedef gen_box_fwd_piter_<P> current__;
- typedef Iterator_on_Points<current__> ret;
- };
-
- template <typename P>
- struct super_trait_< gen_box_bkd_piter_<P> >
- {
- typedef gen_box_bkd_piter_<P> current__;
- typedef Iterator_on_Points<current__> ret;
- };
-
-
- /// Virtual types.
-
- template <typename P>
- struct vtypes< gen_box_fwd_piter_<P> >
- {
- typedef P point;
- };
-
- template <typename P>
- struct vtypes< gen_box_bkd_piter_<P> >
- {
- typedef P point;
- };
-
-
- /// Class gen_box_fwd_piter_<P>.
-
- template <typename P>
- class gen_box_fwd_piter_ : public Iterator_on_Points< gen_box_fwd_piter_<P> >,
- private mlc::assert_< mlc_is_a(P, Point) >
- {
- public:
- gen_box_fwd_piter_();
- gen_box_fwd_piter_(const Point_Set< gen_box<P> >& b);
- void set_box(const gen_box<P>& b);
-
- void impl_start();
- void impl_next();
- void impl_invalidate();
- bool impl_is_valid() const;
- P impl_to_point() const;
- const P* impl_point_adr() const;
-
- private:
- gen_box<P> b_;
- P p_, nop_;
- };
-
-
- /// Class gen_box_bkd_piter_<P>.
-
- template <typename P>
- class gen_box_bkd_piter_ : public Iterator_on_Points< gen_box_bkd_piter_<P> >,
- private mlc::assert_< mlc_is_a(P, Point) >
- {
- public:
- gen_box_bkd_piter_();
- gen_box_bkd_piter_(const Point_Set< gen_box<P> >& b);
- void set_box(const gen_box<P>& b);
-
- void impl_start();
- void impl_next();
- void impl_invalidate();
- bool impl_is_valid() const;
- P impl_to_point() const;
- const P* impl_point_adr() const;
-
- private:
- gen_box<P> b_;
- P p_, nop_;
- };
-
-
-
# ifndef OLN_INCLUDE_ONLY
@@ -215,225 +98,22 @@
}
template <typename P>
- gen_box<P>::gen_box(const P& pmin, const P& pmax)
+ gen_box<P>::gen_box(const P& pmin, const P& pmax) :
+ super(pmin, pmax)
{
- for (unsigned i = 0; i < n; ++i)
- precondition(pmax[i] >= pmin[i]);
- this->pmin_ = pmin;
- this->pmax_ = pmax;
}
template <typename P>
- gen_box<P>::gen_box(const typename gen_box<P>::from_to_t& dat)
+ gen_box<P>::gen_box(const typename gen_box<P>::from_to_t& data) :
+ super(data)
{
- this->pmin_ = dat->first.value;
- this->pmax_ = dat->second.value;
}
template <typename P>
template <typename D>
- gen_box<P>::gen_box(const internal::initializer_<D>& data)
- {
- bool box_ok = internal::init__(internal::tag::box_t(), *this, data.value());
- postcondition(box_ok);
- }
-
- template <typename P>
- unsigned
- gen_box<P>::impl_npoints() const
- {
- unsigned count = 1;
- for (unsigned i = 0; i < n; ++i)
- count *= (this->pmax_[i] - this->pmin_[i] + 1);
- return count;
- }
-
- template <typename P>
- bool
- gen_box<P>::impl_has(const P& p) const
- {
- for (unsigned i = 0; i < n; ++i)
- if (p[i] < this->pmin_[i] or p[i] > this->pmax_[i])
- return false;
- return true;
- }
-
- template <typename P>
- const gen_box<P>&
- gen_box<P>::impl_bbox() const
- {
- return *this;
- }
-
- template <typename P>
- const P&
- gen_box<P>::pmin() const
- {
- for (unsigned i = 0; i < n; ++i)
- invariant(this->pmin_[i] <= this->pmax_[i]);
- return this->pmin_;
- }
-
- template <typename P>
- const P&
- gen_box<P>::pmax() const
- {
- for (unsigned i = 0; i < n; ++i)
- invariant(this->pmax_[i] >= this->pmin_[i]);
- return this->pmax_;
- }
-
- template <typename P>
- P&
- gen_box<P>::pmin()
- {
- return this->pmin_;
- }
-
- template <typename P>
- P&
- gen_box<P>::pmax()
- {
- return this->pmax_;
- }
-
-
- // -------------------- gen_box_fwd_piter_<P>
-
-
- template <typename P>
- gen_box_fwd_piter_<P>::gen_box_fwd_piter_()
- {
- }
-
- template <typename P>
- gen_box_fwd_piter_<P>::gen_box_fwd_piter_(const Point_Set< gen_box<P> >& b)
- {
- this->set_box(exact(b));
- }
-
- template <typename P>
- void gen_box_fwd_piter_<P>::set_box(const gen_box<P>& b)
- {
- b_ = b;
- nop_ = b_.pmax();
- ++nop_[0];
- p_ = nop_;
- }
-
- template <typename P>
- void gen_box_fwd_piter_<P>::impl_start()
- {
- p_ = b_.pmin();
- }
-
- template <typename P>
- void gen_box_fwd_piter_<P>::impl_next()
- {
- for (int i = P::n - 1; i >= 0; --i)
- if (p_[i] == b_.pmax()[i])
- p_[i] = b_.pmin()[i];
- else
- {
- ++p_[i];
- break;
- }
- if (p_ == b_.pmin())
- p_ = nop_;
- }
-
- template <typename P>
- void gen_box_fwd_piter_<P>::impl_invalidate()
- {
- p_ = nop_;
- }
-
- template <typename P>
- bool gen_box_fwd_piter_<P>::impl_is_valid() const
- {
- return p_ != nop_;
- }
-
- template <typename P>
- P gen_box_fwd_piter_<P>::impl_to_point() const
- {
- return p_;
- }
-
- template <typename P>
- const P* gen_box_fwd_piter_<P>::impl_point_adr() const
- {
- return &p_;
- }
-
-
-
- // -------------------- gen_box_bkd_piter_<P>
-
-
- template <typename P>
- gen_box_bkd_piter_<P>::gen_box_bkd_piter_()
- {
- }
-
- template <typename P>
- gen_box_bkd_piter_<P>::gen_box_bkd_piter_(const Point_Set< gen_box<P> >& b)
- {
- this->set_box(exact(b));
- }
-
- template <typename P>
- void gen_box_bkd_piter_<P>::set_box(const gen_box<P>& b)
- {
- b_ = b;
- nop_ = b_.pmin();
- --nop_[0];
- p_ = nop_;
- }
-
- template <typename P>
- void gen_box_bkd_piter_<P>::impl_start()
- {
- p_ = b_.pmax();
- }
-
- template <typename P>
- void gen_box_bkd_piter_<P>::impl_next()
- {
- for (int i = P::n - 1; i >= 0; --i)
- if (p_[i] == b_.pmin()[i])
- p_[i] = b_.pmax()[i];
- else
- {
- --p_[i];
- break;
- }
- if (p_ == b_.pmax())
- p_ = nop_;
- }
-
- template <typename P>
- void gen_box_bkd_piter_<P>::impl_invalidate()
- {
- p_ = nop_;
- }
-
- template <typename P>
- bool gen_box_bkd_piter_<P>::impl_is_valid() const
- {
- return p_ != nop_;
- }
-
- template <typename P>
- P gen_box_bkd_piter_<P>::impl_to_point() const
- {
- return p_;
- }
-
- template <typename P>
- const P* gen_box_bkd_piter_<P>::impl_point_adr() const
+ gen_box<P>::gen_box(const internal::initializer_<D>& data) :
+ super(data)
{
- return &p_;
}
# endif // !OLN_INCLUDE_ONLY
Index: oln/core/internal/box.hh
--- oln/core/internal/box.hh (revision 907)
+++ oln/core/internal/box.hh (working copy)
@@ -39,18 +39,14 @@
// Forward declarations.
- namespace internal
- {
- template <typename Exact> class box_;
+ namespace internal { template <typename Exact> class box_; }
template <typename Exact> class box_fwd_piter_;
template <typename Exact> class box_bkd_piter_;
- }
// Super type declaration.
template <typename Exact>
struct super_trait_< internal::box_<Exact> >
{
- // typedef box_<Exact> current__;
typedef internal::point_set_base_<Exact> ret;
};
@@ -59,9 +55,8 @@
template <typename Exact>
struct vtypes< internal::box_<Exact> >
{
- //typedef point2d point;
- typedef stc::final< internal::box_fwd_piter_<Exact> > fwd_piter;
- typedef stc::final< internal::box_bkd_piter_<Exact> > bkd_piter;
+ typedef stc::final< box_fwd_piter_<Exact> > fwd_piter;
+ typedef stc::final< box_bkd_piter_<Exact> > bkd_piter;
};
@@ -103,6 +98,8 @@
box_();
box_(const point& pmin, const point& pmax);
box_(const from_to_t& data);
+ template <typename D>
+ box_(const internal::initializer_<D>& data);
point pmin_, pmax_;
@@ -121,20 +118,19 @@
-
/// Super types.
template <typename B>
- struct super_trait_< internal::box_fwd_piter_<B> >
+ struct super_trait_< box_fwd_piter_<B> >
{
- typedef internal::box_fwd_piter_<B> current__;
+ typedef box_fwd_piter_<B> current__;
typedef Iterator_on_Points<current__> ret;
};
template <typename B>
- struct super_trait_<internal:: box_bkd_piter_<B> >
+ struct super_trait_<box_bkd_piter_<B> >
{
- typedef internal::box_bkd_piter_<B> current__;
+ typedef box_bkd_piter_<B> current__;
typedef Iterator_on_Points<current__> ret;
};
@@ -142,20 +138,18 @@
/// Virtual types.
template <typename B>
- struct vtypes< internal::box_fwd_piter_<B> >
+ struct vtypes< box_fwd_piter_<B> >
{
typedef typename B::point point;
};
template <typename B>
- struct vtypes< internal::box_bkd_piter_<B> >
+ struct vtypes< box_bkd_piter_<B> >
{
typedef typename B::point point;
};
- namespace internal
- {
/// Class box_fwd_piter_<P>.
template <typename B>
@@ -168,7 +162,7 @@
stc_using(point);
box_fwd_piter_();
- box_fwd_piter_(const Point_Set< B >& b);
+ box_fwd_piter_(const B& b);
void set_box(const B& b);
void impl_start();
@@ -196,7 +190,7 @@
stc_using(point);
box_bkd_piter_();
- box_bkd_piter_(const Point_Set< B >& b);
+ box_bkd_piter_(const B& b);
void set_box(const B& b);
void impl_start();
@@ -216,6 +210,8 @@
# ifndef OLN_INCLUDE_ONLY
+ namespace internal
+ {
// -------------------- box_<Exact>
@@ -242,6 +238,13 @@
this->pmax_ = dat->second.value;
}
+ template <typename Exact>
+ template <typename D>
+ box_<Exact>::box_(const internal::initializer_<D>& data)
+ {
+ bool box_ok = internal::init__(internal::tag::box_t(), *this, data.value());
+ postcondition(box_ok);
+ }
template <typename Exact>
unsigned
@@ -301,7 +304,7 @@
{
return this->pmax_;
}
-
+ }
// -------------------- box_fwd_piter_<B>
@@ -312,9 +315,9 @@
}
template <typename B>
- box_fwd_piter_<B>::box_fwd_piter_(const Point_Set< B >& b)
+ box_fwd_piter_<B>::box_fwd_piter_(const B& b)
{
- this->set_box(exact(b));
+ this->set_box(b);
}
template <typename B>
@@ -389,9 +392,9 @@
}
template <typename B>
- box_bkd_piter_<B>::box_bkd_piter_(const Point_Set< B >& b)
+ box_bkd_piter_<B>::box_bkd_piter_(const B& b)
{
- this->set_box(exact(b));
+ this->set_box(b);
}
template <typename B>
@@ -456,8 +459,6 @@
}
# endif // OLN_INCLUDE_ONLY
- } // end of namespace internal
-
} // end of namespace oln
Index: oln/core/internal/point_set_base.hh
--- oln/core/internal/point_set_base.hh (revision 907)
+++ oln/core/internal/point_set_base.hh (working copy)
@@ -84,13 +84,12 @@
typedef stc::abstract point;
typedef stc::abstract fwd_piter;
typedef stc::abstract bkd_piter;
+ typedef stc::abstract box;
typedef stc_deferred(point) point__;
typedef stc_deferred(fwd_piter) fwd_piter__;
typedef stc::final< stc::is<Point_Set> > category;
- //FIXME:
- typedef gen_box<point__> box;
typedef stc::final< oln_grid(point__) > grid;
typedef stc::final< fwd_piter__ > piter;
};
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add image level comparisons and better point set ones.
* oln/level/compare.hh: New.
* TODO: New "Rough list" and "Tiny improvements" sections.
* oln/core/concept/grid.hh
(both_types_should_have_the_same_grid_),
(assert_same_grid_): New.
* oln/core/concept/operators.hh: Separate defs from decls.
Fix dispatch using 'exact'.
* oln/core/gen/pset_compare.hh (guards): Remove.
(operator<=, impl_leq_): Replace by...
(operator<, impl_less_): ...these.
TODO | 50 ++++++++++++++
oln/core/concept/grid.hh | 21 ++++++
oln/core/concept/operators.hh | 141 +++++++++++++++++++-----------------------
oln/core/gen/pset_compare.hh | 54 +++++++---------
oln/level/compare.hh | 109 ++++++++++++++++++++++++++++++++
5 files changed, 271 insertions(+), 104 deletions(-)
Index: TODO
--- TODO (revision 906)
+++ TODO (working copy)
@@ -1,3 +1,53 @@
+
+
+* Rough list
+
+value types (including gray level types, label types, (bool, T) type,
+color types, etc.)
+
+op traits (for C types, oln value types, and also oln types such as
+points, etc.)
+
+image thru a function f (where f is pure, a bijection, a two-way
+function, an accessor, a projection, etc.)
+
+basics important routines: fill, assign, clone, unmorph (undress?),
+convert, ...
+
+torus and mask types, and the proper niter type deductions (with or
+without virtual border)
+
+virtual border adaptation and initialization policies
+
+safe type when image is mutable; question: can we have Mutable_Image&
+as argument when an image, a morpher, is created on the fly?
+
+io pnm
+
+draw routines
+
+window types such as lines, rectangles, and so on
+
+meta-window type; for instance, ball, segment, etc.
+
+const promotions for op_<L,O,R> types
+
+
+* Tiny improvements
+
+Replace point type comparison assertions by an explicit version
+(just like assert_same_grid_)
+
+
+
+* Some ideas
+
+Consider the morphological gradient "d(f) - e(f)", it is a combination
+of local functions; can we make it explicit? Advantage: no temp image
+created.
+
+
+
* Renaming
** point_accessibility
Index: oln/level/compare.hh
--- oln/level/compare.hh (revision 0)
+++ oln/level/compare.hh (revision 0)
@@ -0,0 +1,109 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_LEVEL_COMPARE_HH
+# define OLN_LEVEL_COMPARE_HH
+
+# include <oln/core/concept/image.hh>
+# include <oln/core/gen/pset_compare.hh>
+
+
+namespace oln
+{
+
+ // Fwd decls.
+
+ template <typename L, typename R>
+ bool operator = (const Image<L>& lhs, const Image<R>& rhs);
+
+ template <typename L, typename R>
+ bool operator < (const Image<L>& lhs, const Image<R>& rhs);
+
+
+# ifndef OLN_LNCLUDE_ONLY
+
+ namespace impl
+ {
+
+ // Image L = Image R
+ // ----------------------
+
+ // Generic version.
+
+ template <typename L, typename R>
+ bool op_eq_(const Image<L>& lhs, const Image<R>& rhs);
+ {
+ precondition(lhs.points() = rhs.points());
+ oln_piter(L) p(lhs.points());
+ for_all(p)
+ if (lhs(p) != rhs(p))
+ return false;
+ return true;
+ }
+
+
+ // Image L < Image R
+ // ---------------------
+
+ // Generic version.
+
+ template <typename L, typename R>
+ bool op_less_(const Image<L>& lhs, const Image<R>& rhs);
+ {
+ precondition(lhs.points() = rhs.points());
+ oln_piter(L) p(lhs.points());
+ for_all(p)
+ if (lhs(p) >= rhs(p))
+ return false;
+ return true;
+ }
+
+ } // end of namespace oln::level::impl
+
+
+ // Facades.
+
+ template <typename L, typename R>
+ bool operator = (const Image<L>& lhs, const Image<R>& rhs)
+ {
+ assert_same_grid_<L, R>::check();
+ return impl::op_eq_(exact(lhs), exact(rhs));
+ }
+
+ template <typename L, typename R>
+ bool operator < (const Image<L>& lhs, const Image<R>& rhs)
+ {
+ assert_same_grid_<L, R>::check();
+ return impl::op_less_(exact(lhs), exact(rhs));
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+} // end of namespace oln
+
+
+#endif // ! OLN_LEVEL_COMPARE_HH
Index: oln/core/concept/grid.hh
--- oln/core/concept/grid.hh (revision 906)
+++ oln/core/concept/grid.hh (working copy)
@@ -52,6 +52,27 @@
};
+ namespace ERROR
+ {
+
+ template < typename Type_1,
+ typename Type_2,
+ typename Grid_1 = oln_grid(Type_1),
+ typename Grid_2 = oln_grid(Type_2) >
+ struct both_types_should_have_the_same_grid_
+ {
+ };
+
+ } // end of namespace oln::ERROR
+
+
+ template <typename T1, typename T2>
+ struct assert_same_grid_
+ : public mlc::assert_< mlc::eq_<oln_grid(T1), oln_grid(T2)>,
+ ERROR::both_types_should_have_the_same_grid_<T1, T2> >
+ {};
+
+
} // end of namespace oln
Index: oln/core/concept/operators.hh
--- oln/core/concept/operators.hh (revision 906)
+++ oln/core/concept/operators.hh (working copy)
@@ -34,8 +34,50 @@
namespace oln
{
- /// \{
/// Operator = (default version).
+ template <typename L, typename R>
+ bool operator=(const Any<L>& lhs, const Any<R>& rhs);
+
+ /// Operator != (default version).
+ template <typename L, typename R>
+ bool operator!=(const Any<L>& lhs, const Any<R>& rhs);
+
+ /// Operator < (default version).
+ template <typename L, typename R>
+ bool operator< (const Any<L>& lhs, const Any<R>& rhs);
+
+ /// Operator > (default version).
+ template <typename L, typename R>
+ bool operator> (const Any<L>& lhs, const Any<R>& rhs);
+
+ /// Operator >= (default version).
+ template <typename L, typename R>
+ bool operator>=(const Any<L>& lhs, const Any<R>& rhs);
+
+ /// Operator <= (default version).
+ template <typename L, typename R>
+ bool operator<=(const Any<L>& lhs, const Any<R>& rhs);
+
+ /// Operator += (default version).
+ template <typename L, typename R>
+ L& operator+=(Any<L>& lhs, const Any<R>& rhs);
+
+ /// Operator + (default version).
+ template <typename T>
+ T operator+ (const Any<T>& lhs, const Any<T>& rhs);
+
+ /// Operator -= (default version).
+ template <typename L, typename R>
+ L& operator-=(Any<L>& lhs, const Any<R>& rhs);
+
+ /// Operator - (default version).
+ template <typename T>
+ T operator- (const Any<T>& rhs);
+
+
+
+
+# ifndef OLN_INCLUDE_ONLY
template <typename L, typename R>
bool operator=(const Any<L>& lhs, const Any<R>& rhs)
@@ -43,138 +85,87 @@
return exact(lhs).op_equal_(exact(rhs));
}
- /// \}
-
-
- /// \{
- /// Operator != (default version).
-
template <typename L, typename R>
bool operator!=(const Any<L>& lhs, const Any<R>& rhs)
{
- return not (lhs = rhs);
+ return not (exact(lhs) = exact(rhs));
}
- /// \}
-
-
- /// \{
- /// Operator < (default version).
-
template <typename L, typename R>
bool operator< (const Any<L>& lhs, const Any<R>& rhs)
{
return exact(lhs).op_less_(exact(rhs));
}
- /// \}
-
-
- /// \{
- /// Operator > (default version).
-
template <typename L, typename R>
bool operator> (const Any<L>& lhs, const Any<R>& rhs)
{
- return rhs < lhs;
+ return exact(rhs) < exact(lhs);
}
- /// \}
-
-
- /// \{
- /// Operator >= (default version).
-
template <typename L, typename R>
bool operator>=(const Any<L>& lhs, const Any<R>& rhs)
{
- return not (lhs < rhs);
+ return not (exact(lhs) < exact(rhs));
}
- /// \}
-
-
- /// \{
- /// Operator <= (default version).
-
template <typename L, typename R>
bool operator<=(const Any<L>& lhs, const Any<R>& rhs)
{
- return not (rhs < lhs);
+ return not (exact(rhs) < exact(lhs));
}
- /// \}
-
-
- /// \{
- /// Operator += (default version).
-
template <typename L, typename R>
L& operator+=(Any<L>& lhs, const Any<R>& rhs)
{
return exact(lhs).op_plus_equal_(exact(rhs));
}
- /// \}
-
-
- /// \{
- /// Operators + (default versions).
-
template <typename T>
T operator+ (const Any<T>& lhs, const Any<T>& rhs)
{
T tmp = exact(lhs);
- return tmp += rhs;
+ return tmp += exact(rhs);
}
-// template <typename L, typename R>
-// xtd_op_plus_trait(L, R) operator+ (const Any<L>& lhs, const Any<R>& rhs)
-// {
-// return exact(lhs).op_plus_(exact(rhs));
-// }
-
- /// \}
-
-
- /// \{
- /// Operator -= (default version).
-
template <typename L, typename R>
L& operator-=(Any<L>& lhs, const Any<R>& rhs)
{
return exact(lhs).op_minus_equal_(exact(rhs));
}
- /// \}
-
-
- /// \{
- /// Operators - (default versions).
-
template <typename T>
T operator- (const Any<T>& rhs)
{
return exact(rhs).op_unary_minus_();
}
-/* template <typename T>
+ /*
+
+ FIXME: Activate?
+
+ template <typename L, typename R>
+ xtd_op_plus_trait(L, R) operator+ (const Any<L>& lhs, const Any<R>& rhs)
+ {
+ return exact(lhs).op_plus_(exact(rhs));
+ }
+
+ template <typename T>
T operator- (const Any<T>& lhs, const Any<T>& rhs)
{
T tmp = exact(lhs);
return tmp -= rhs;
}
-*/
-
-// template <typename L, typename R>
-// xtd_op_minus_trait(L, R) operator- (const Any<L>& lhs, const Any<R>& rhs)
-// {
-// return exact(lhs).op_minus_(exact(rhs));
-// }
- /// \}
+ template <typename L, typename R>
+ xtd_op_minus_trait(L, R) operator- (const Any<L>& lhs, const Any<R>& rhs)
+ {
+ return exact(lhs).op_minus_(exact(rhs));
+ }
+ */
+# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln
Index: oln/core/gen/pset_compare.hh
--- oln/core/gen/pset_compare.hh (revision 906)
+++ oln/core/gen/pset_compare.hh (working copy)
@@ -40,15 +40,7 @@
bool operator = (const Point_Set<L>& lhs, const Point_Set<R>& rhs);
template <typename L, typename R>
- bool operator <= (const Point_Set<L>& lhs, const Point_Set<R>& rhs);
-
-
- // FIXME: Guards; without impl!
- template <typename L, typename R> bool operator < (const Point_Set<L>&, const Point_Set<R>&);
- template <typename L, typename R> bool operator > (const Point_Set<L>&, const Point_Set<R>&);
- template <typename L, typename R> bool operator >= (const Point_Set<L>&, const Point_Set<R>&);
- // end of FIXME
-
+ bool operator < (const Point_Set<L>& lhs, const Point_Set<R>& rhs);
# ifndef OLN_INCLUDE_ONLY
@@ -92,26 +84,26 @@
*/
- // Point_Set L <= Point_Set R
- // ------------------------------
+ // Point_Set L < Point_Set R
+ // -----------------------------
// Generic version.
template <typename L, typename R>
- bool op_leq_(const Point_Set<L>& lhs, const Point_Set<R>& rhs)
+ bool op_less_(const Point_Set<L>& lhs, const Point_Set<R>& rhs)
{
- // quick test:
- if (lhs.npoints() > rhs.npoints())
+ if (lhs.npoints() >= rhs.npoints()) // quick test
return false;
- // final test:
- oln_piter(R) pr(rhs);
- pr.start();
- oln_piter(L) pl(lhs);
- for_all(pl)
- {
- while (pr.is_valid() and pr.to_point() != pl.to_point())
- pr.next();
- if (not pr.is_valid())
+ // we have lhs.npoints() < rhs.npoints()
+ // so we shall now test that all points of lhs are IN rhs
+ oln_piter(R) p_rhs(rhs);
+ p_rhs.start();
+ oln_piter(L) p_lhs(lhs);
+ for_all(p_lhs)
+ {
+ while (p_rhs.is_valid() and p_rhs.to_point() != p_lhs.to_point())
+ p_rhs.next();
+ if (not p_rhs.is_valid())
return false;
}
return true;
@@ -122,12 +114,16 @@
FIXME: Activate.
template <typename L, typename R>
- bool op_leq_(const Box<L>& lhs, const Box<R>& rhs)
+ bool op_less_(const Box<L>& lhs, const Box<R>& rhs)
{
+ // subset test (i.e., lhs <= rhs)
for (unsigned i = 0; i < L::n; ++i)
+ {
if (lhs.pmin()[i] < rhs.pmin()[i] or lhs.pmax()[i] > rhs.pmax()[i])
return false;
- return true;
+ }
+ // proper (strict) test
+ return lhs != rhs;
}
*/
@@ -140,15 +136,15 @@
template <typename L, typename R>
bool operator = (const Point_Set<L>& lhs, const Point_Set<R>& rhs)
{
- mlc::assert_equal_< oln_grid(L), oln_grid(R) >::check(); // FIXME: Add err msg.
+ assert_same_grid_<L, R>::check();
return impl::op_eq_(exact(lhs), exact(rhs));
}
template <typename L, typename R>
- bool operator <= (const Point_Set<L>& lhs, const Point_Set<R>& rhs)
+ bool operator < (const Point_Set<L>& lhs, const Point_Set<R>& rhs)
{
- mlc::assert_equal_< oln_grid(L), oln_grid(R) >::check(); // FIXME: Add err msg.
- return impl::op_leq_(exact(lhs), exact(rhs));
+ assert_same_grid_<L, R>::check();
+ return impl::op_less_(exact(lhs), exact(rhs));
}
# endif // ! OLN_INCLUDE_ONLY
1
0
I've got an error since last 2 patchs :
error: no matching function for call to 'init_(oln::box2d*, const oln::image2d<int>&)'
We look at it with nico but didn't manage to fix.
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Morpho : Elementary versions.
* oln/morpho/elementary_gradient.hh: New.
* oln/morpho/elementary_gradient_external.hh: New.
* oln/morpho/elementary_laplace.hh: New.
* oln/morpho/gradient_internal.hh: .
* oln/morpho/gradient.hh: .
* oln/morpho/gradient_external.hh: .
* oln/morpho/laplace.hh: .
* oln/morpho/erosion.hh: .
* oln/morpho/elementary_gradient_internal.hh: New.
* oln/core/2d/image2d.hh: .
core/2d/image2d.hh | 3 -
morpho/elementary_gradient.hh | 84 +++++++++++++++++++++++++++++++++
morpho/elementary_gradient_external.hh | 83 ++++++++++++++++++++++++++++++++
morpho/elementary_gradient_internal.hh | 83 ++++++++++++++++++++++++++++++++
morpho/elementary_laplace.hh | 84 +++++++++++++++++++++++++++++++++
morpho/erosion.hh | 6 +-
morpho/gradient.hh | 25 +++++----
morpho/gradient_external.hh | 29 +++++------
morpho/gradient_internal.hh | 28 +++++------
morpho/laplace.hh | 23 +++++----
10 files changed, 395 insertions(+), 53 deletions(-)
Index: oln/morpho/elementary_gradient.hh
--- oln/morpho/elementary_gradient.hh (revision 0)
+++ oln/morpho/elementary_gradient.hh (revision 0)
@@ -0,0 +1,84 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_MORPHO_ELEMENTARY_GRADIENT_HH
+# define OLN_MORPHO_ELEMENTARY_GRADIENT_HH
+
+#include <oln/morpho/elementary_erosion.hh>
+#include <oln/morpho/elementary_dilation.hh>
+#include <oln/arith/minus.hh>
+
+namespace oln
+{
+
+ namespace morpho
+ {
+
+ // Fwd decl.
+
+ template <typename I>
+ oln_plain(I)
+ elementary_gradient(const Image_with_Nbh<I>& input);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ // Generic version.
+
+ template <typename I>
+ oln_plain(I)
+ elementary_gradient_(const Image_with_Nbh<I>& input)
+ {
+ return elementary_dilation(input) - elementary_erosion(input);
+ }
+
+
+ // FIXME: Add a fast version.
+
+ } // end of namespace oln::morpho::impl
+
+
+ // Facade.
+
+ template <typename I>
+ oln_plain(I)
+ elementary_gradient(const Image_with_Nbh<I>& input)
+ {
+ return impl::elementary_gradient_(exact(input));
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+
+#endif // ! OLN_MORPHO_ELEMENTARY_GRADIENT_HH
Index: oln/morpho/elementary_gradient_external.hh
--- oln/morpho/elementary_gradient_external.hh (revision 0)
+++ oln/morpho/elementary_gradient_external.hh (revision 0)
@@ -0,0 +1,83 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_MORPHO_EXTERNAL_GRADIENT_HH
+# define OLN_MORPHO_EXTERNAL_GRADIENT_HH
+
+#include <oln/morpho/elementary_dilation.hh>
+#include <oln/arith/minus.hh>
+
+namespace oln
+{
+
+ namespace morpho
+ {
+
+ // Fwd decl.
+
+ template <typename I>
+ oln_plain(I)
+ elementary_gradient_external(const Image_with_Nbh<I>& input);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ // Generic version.
+
+ template <typename I>
+ oln_plain(I)
+ elementary_gradient_external_(const Image_with_Nbh<I>& input)
+ {
+ return elementary_dilation(input) - input;
+ }
+
+
+ // FIXME: Add a fast version.
+
+ } // end of namespace oln::morpho::impl
+
+
+ // Facade.
+
+ template <typename I>
+ oln_plain(I)
+ elementary_gradient_external(const Image_with_Nbh<I>& input)
+ {
+ return impl::elementary_gradient_external_(exact(input));
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+
+#endif // ! OLN_MORPHO_EXTERNAL_GRADIENT_HH
Index: oln/morpho/elementary_laplace.hh
--- oln/morpho/elementary_laplace.hh (revision 0)
+++ oln/morpho/elementary_laplace.hh (revision 0)
@@ -0,0 +1,84 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_MORPHO_ELEMENTARY_LAPLACE_HH
+# define OLN_MORPHO_ELEMENTARY_LAPLACE_HH
+
+#include <oln/morpho/elementary_gradient_external.hh>
+#include <oln/morpho/elementary_gradient_internal.hh>
+#include <oln/arith/minus.hh>
+
+namespace oln
+{
+
+ namespace morpho
+ {
+
+ // Fwd decl.
+
+ template <typename I>
+ oln_plain(I)
+ elementary_laplace(const Image_with_Nbh<I>& input);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ // Generic version.
+
+ template <typename I>
+ oln_plain(I)
+ elementary_laplace_(const Image_with_Nbh<I>& input)
+ {
+ return elementary_gradient_external(input) - elementary_gradient_internal(input);
+ }
+
+
+ // FIXME: Add a fast version.
+
+ } // end of namespace oln::morpho::impl
+
+
+ // Facade.
+
+ template <typename I>
+ oln_plain(I)
+ elementary_laplace(const Image_with_Nbh<I>& input)
+ {
+ return impl::elementary_laplace_(exact(input));
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+
+#endif // ! OLN_MORPHO_ELEMENTARY_LAPLACE_HH
Index: oln/morpho/gradient_internal.hh
--- oln/morpho/gradient_internal.hh (revision 905)
+++ oln/morpho/gradient_internal.hh (working copy)
@@ -25,10 +25,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_MORPHO_INSIDE_GRADIENT_HH
-# define OLN_MORPHO_INSIDE_GRADIENT_HH
+#ifndef OLN_MORPHO_GRADIENT_INTERNAL_HH
+# define OLN_MORPHO_GRADIENT_INTERNAL_HH
-#include <oln/morpho/elementary_erosion.hh>
+#include <oln/morpho/erosion.hh>
#include <oln/arith/minus.hh>
namespace oln
@@ -39,9 +39,10 @@
// Fwd decl.
- template <typename I>
+ template <typename I, typename W>
oln_plain(I)
- inside_gradient(const Image_with_Nbh<I>& input);
+ gradient_internal(const Image<I>& input,
+ const Window<W>& win);
# ifndef OLN_INCLUDE_ONLY
@@ -51,26 +52,27 @@
// Generic version.
- template <typename I>
+ template <typename I, typename W>
oln_plain(I)
- inside_gradient_(const Image_with_Nbh<I>& input)
+ gradient_internal_(const Image<I>& input,
+ const Window<W>& win)
{
- return input - elementary_erosion(input);
+ return input - erosion(input, win);
}
- // FIXME: Add a fast version.
} // end of namespace oln::morpho::impl
// Facade.
- template <typename I>
+ template <typename I, typename W>
oln_plain(I)
- inside_gradient(const Image_with_Nbh<I>& input)
+ gradient_internal(const Image<I>& input,
+ const Window<W>& win)
{
- return impl::inside_gradient_(exact(input));
+ return impl::gradient_internal_(exact(input), win);
}
# endif // ! OLN_INCLUDE_ONLY
@@ -80,4 +82,4 @@
} // end of namespace oln
-#endif // ! OLN_MORPHO_INSIDE_GRADIENT_HH
+#endif // ! OLN_MORPHO_GRADIENT_INTERNAL_HH
Index: oln/morpho/gradient.hh
--- oln/morpho/gradient.hh (revision 905)
+++ oln/morpho/gradient.hh (working copy)
@@ -28,8 +28,8 @@
#ifndef OLN_MORPHO_GRADIENT_HH
# define OLN_MORPHO_GRADIENT_HH
-#include <oln/morpho/elementary_erosion.hh>
-#include <oln/morpho/elementary_dilation.hh>
+#include <oln/morpho/erosion.hh>
+#include <oln/morpho/dilation.hh>
#include <oln/arith/minus.hh>
namespace oln
@@ -40,9 +40,10 @@
// Fwd decl.
- template <typename I>
+ template <typename I, typename W>
oln_plain(I)
- gradient(const Image_with_Nbh<I>& input);
+ gradient(const Image<I>& input,
+ const Window<W>& win);
# ifndef OLN_INCLUDE_ONLY
@@ -52,26 +53,26 @@
// Generic version.
- template <typename I>
+ template <typename I, typename W>
oln_plain(I)
- gradient_(const Image_with_Nbh<I>& input)
+ gradient_(const Image<I>& input,
+ const Window<W>& win)
{
- return elementary_dilation(input) - elementary_erosion(input);
+ return dilation(input, win) - erosion(input, win);
}
- // FIXME: Add a fast version.
-
} // end of namespace oln::morpho::impl
// Facade.
- template <typename I>
+ template <typename I, typename W>
oln_plain(I)
- gradient(const Image_with_Nbh<I>& input)
+ gradient(const Image<I>& input,
+ const Window<W>& win)
{
- return impl::gradient_(exact(input));
+ return impl::gradient_(exact(input), win);
}
# endif // ! OLN_INCLUDE_ONLY
Index: oln/morpho/gradient_external.hh
--- oln/morpho/gradient_external.hh (revision 905)
+++ oln/morpho/gradient_external.hh (working copy)
@@ -25,10 +25,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_MORPHO_EXTERNAL_GRADIENT_HH
-# define OLN_MORPHO_EXTERNAL_GRADIENT_HH
+#ifndef OLN_MORPHO_GRADIENT_EXTERNAL_HH
+# define OLN_MORPHO_GRADIENT_EXTERNAL_HH
-#include <oln/morpho/elementary_dilation.hh>
+#include <oln/morpho/dilation.hh>
#include <oln/arith/minus.hh>
namespace oln
@@ -39,9 +39,10 @@
// Fwd decl.
- template <typename I>
+ template <typename I, typename W>
oln_plain(I)
- external_gradient(const Image_with_Nbh<I>& input);
+ gradient_external(const Image<I>& input,
+ const Window<W>& win);
# ifndef OLN_INCLUDE_ONLY
@@ -51,26 +52,26 @@
// Generic version.
- template <typename I>
+ template <typename I, typename W>
oln_plain(I)
- external_gradient_(const Image_with_Nbh<I>& input)
+ gradient_external_(const Image<I>& input,
+ const Window<W>& win)
{
- return elementary_dilation(input) - input;
+ return dilation(input, win) - input;
}
- // FIXME: Add a fast version.
-
} // end of namespace oln::morpho::impl
// Facade.
- template <typename I>
+ template <typename I, typename W>
oln_plain(I)
- external_gradient(const Image_with_Nbh<I>& input)
+ gradient_external(const Image<I>& input,
+ const Window<W>& win)
{
- return impl::external_gradient_(exact(input));
+ return impl::gradient_external_(exact(input), win);
}
# endif // ! OLN_INCLUDE_ONLY
@@ -80,4 +81,4 @@
} // end of namespace oln
-#endif // ! OLN_MORPHO_EXTERNAL_GRADIENT_HH
+#endif // ! OLN_MORPHO_GRADIENT_EXTERNAL_HH
Index: oln/morpho/laplace.hh
--- oln/morpho/laplace.hh (revision 905)
+++ oln/morpho/laplace.hh (working copy)
@@ -28,8 +28,8 @@
#ifndef OLN_MORPHO_LAPLACE_HH
# define OLN_MORPHO_LAPLACE_HH
-#include <oln/morpho/gradient_external.hh>
-#include <oln/morpho/gradient_internal.hh>
+#include <oln/morpho/elementary_gradient_external.hh>
+#include <oln/morpho/elementary_gradient_internal.hh>
#include <oln/arith/minus.hh>
namespace oln
@@ -40,9 +40,10 @@
// Fwd decl.
- template <typename I>
+ template <typename I, typename W>
oln_plain(I)
- laplace(const Image_with_Nbh<I>& input);
+ laplace(const Image<I>& input,
+ const Window<W>& win);
# ifndef OLN_INCLUDE_ONLY
@@ -52,11 +53,12 @@
// Generic version.
- template <typename I>
+ template <typename I, typename W>
oln_plain(I)
- laplace_(const Image_with_Nbh<I>& input)
+ laplace_(const Image<I>& input,
+ const Window<W>& win)
{
- return external_gradient(input) - inside_gradient(input);
+ return gradient_external(input, win) - gradient_internal(input, win);
}
@@ -67,11 +69,12 @@
// Facade.
- template <typename I>
+ template <typename I, typename W>
oln_plain(I)
- laplace(const Image_with_Nbh<I>& input)
+ laplace(const Image<I>& input,
+ const Window<W>& win)
{
- return impl::laplace_(exact(input));
+ return impl::laplace_(exact(input), win);
}
# endif // ! OLN_INCLUDE_ONLY
Index: oln/morpho/erosion.hh
--- oln/morpho/erosion.hh (revision 905)
+++ oln/morpho/erosion.hh (working copy)
@@ -30,7 +30,7 @@
#include <oln/level/apply_local.hh>
#include <oln/border/fill.hh>
-#include <oln/accumulator/max.hh>
+#include <oln/accumulator/min.hh>
namespace oln
{
@@ -56,7 +56,7 @@
oln_plain(I)
erosion_(const Image<I>& input, const Window<W>& win)
{
- border::fill(input, oln_min(oln_value(I)));
+ border::fill(input, oln_max(oln_value(I)));
accumulator::min_<oln_value(I)> min;
return level::apply_local(min, input, win);
}
@@ -66,7 +66,7 @@
erosion_on_set_(const Image<I>&,
const I& input)
{
- border::fill(input, oln_min(oln_value(I)));
+ border::fill(input, true);
accumulator::and_<oln_value(I)> accu_and;
return level::apply_local(accu_and, input);
}
Index: oln/morpho/elementary_gradient_internal.hh
--- oln/morpho/elementary_gradient_internal.hh (revision 0)
+++ oln/morpho/elementary_gradient_internal.hh (revision 0)
@@ -0,0 +1,83 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_MORPHO_ELEMENTARY_GRADIENT_INTERNAL_HH
+# define OLN_MORPHO_ELEMENTARY_GRADIENT_INTERNAL_HH
+
+#include <oln/morpho/elementary_erosion.hh>
+#include <oln/arith/minus.hh>
+
+namespace oln
+{
+
+ namespace morpho
+ {
+
+ // Fwd decl.
+
+ template <typename I>
+ oln_plain(I)
+ elementary_gradient_internal(const Image_with_Nbh<I>& input);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ // Generic version.
+
+ template <typename I>
+ oln_plain(I)
+ elementary_gradient_internal_(const Image_with_Nbh<I>& input)
+ {
+ return input - elementary_erosion(input);
+ }
+
+
+ // FIXME: Add a fast version.
+
+ } // end of namespace oln::morpho::impl
+
+
+ // Facade.
+
+ template <typename I>
+ oln_plain(I)
+ elementary_gradient_internal(const Image_with_Nbh<I>& input)
+ {
+ return impl::elementary_gradient_internal_(exact(input));
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+
+#endif // ! OLN_MORPHO_ELEMENTARY_GRADIENT_INTERNAL_HH
Index: oln/core/2d/image2d.hh
--- oln/core/2d/image2d.hh (revision 905)
+++ oln/core/2d/image2d.hh (working copy)
@@ -213,7 +213,8 @@
box2d b;
bool box_ok = init(b, with, dat);
postcondition(box_ok);
- array2d_<T,int>* ptr = new array2d_<T,int>(b.pmin().row(),
+ array2d_<T,int>* ptr = new array2d_<T,int>(b.pmin().row(), //FIXME
+ //: *.
b.pmin().col(),
b.pmax().row(),
b.pmax().col());
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add Box and comparison operators between point sets.
* oln/core/gen/pset_compare.hh: New.
* oln/core/concept/point_set.hh (Box): New.
* oln/core/2d/box2d.hh (include): Remove gen/box.hh.
* oln/core/internal/point_set_base.hh
(point_set_selector_): New.
* oln/stc/scoop.hxx (super_trait_): Change dummy code.
core/2d/box2d.hh | 12 ---
core/concept/point_set.hh | 54 +++++++++++++
core/gen/pset_compare.hh | 159 ++++++++++++++++++++++++++++++++++++++++
core/internal/point_set_base.hh | 30 +++++++
stc/scoop.hxx | 12 ++-
5 files changed, 255 insertions(+), 12 deletions(-)
Index: oln/core/concept/point_set.hh
--- oln/core/concept/point_set.hh (revision 904)
+++ oln/core/concept/point_set.hh (working copy)
@@ -64,6 +64,24 @@
}; // end of oln::Point_Set<Exact>
+ /// Concept-class "Box".
+
+ template <typename Exact>
+ struct Box : public Point_Set<Exact>
+ {
+ stc_using_from(Point_Set, point);
+
+ const point& pmin() const;
+ point& pmin();
+ const point& pmax() const;
+ point& pmax();
+
+ protected:
+ Box();
+
+ }; // end of oln::Box<Exact>
+
+
template <typename Ps>
std::ostream& operator<<(std::ostream& ostr, const Point_Set<Ps>& pts);
@@ -96,6 +114,38 @@
{
}
+ template <typename Exact>
+ Box<Exact>::Box()
+ {
+ }
+
+ template <typename Exact>
+ const typename Box<Exact>::point&
+ Box<Exact>::pmin() const
+ {
+ return exact(this)->impl_pmin();
+ }
+
+ template <typename Exact>
+ typename Box<Exact>::point&
+ Box<Exact>::pmin()
+ {
+ return exact(this)->impl_pmin();
+ }
+
+ template <typename Exact>
+ const typename Box<Exact>::point&
+ Box<Exact>::pmax() const
+ {
+ return exact(this)->impl_pmax();
+ }
+
+ template <typename Exact>
+ typename Box<Exact>::point&
+ Box<Exact>::pmax()
+ {
+ return exact(this)->impl_pmax();
+ }
template <typename Ps>
std::ostream& operator<<(std::ostream& ostr, const Point_Set<Ps>& pts)
@@ -114,4 +164,8 @@
} // end of namespace oln
+// FIXME: Bad?
+# include <oln/core/gen/pset_compare.hh>
+
+
#endif // ! OLN_CORE_CONCEPT_POINT_SET_HH
Index: oln/core/2d/box2d.hh
--- oln/core/2d/box2d.hh (revision 904)
+++ oln/core/2d/box2d.hh (working copy)
@@ -86,17 +86,9 @@
} // end of namespace oln::internal
-} // end of namespace oln
-
-
-# include <oln/core/gen/box.hh>
-
# ifndef OLN_INCLUDE_ONLY
-namespace oln
-{
-
box2d::box2d()
{
}
@@ -144,10 +136,10 @@
} // end of namespace oln::internal
-} // end of namespace oln
+# endif // ! OLN_INCLUDE_ONLY
-# endif // OLN_INCLUDE_ONLY
+} // end of namespace oln
#endif // ! OLN_CORE_2D_BOX2D_HH
Index: oln/core/gen/pset_compare.hh
--- oln/core/gen/pset_compare.hh (revision 0)
+++ oln/core/gen/pset_compare.hh (revision 0)
@@ -0,0 +1,159 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_GEN_PSET_COMPARE_HH
+# define OLN_CORE_GEN_PSET_COMPARE_HH
+
+# include <oln/core/concept/point_set.hh>
+
+
+namespace oln
+{
+
+ // Fwd decls.
+
+ template <typename L, typename R>
+ bool operator = (const Point_Set<L>& lhs, const Point_Set<R>& rhs);
+
+ template <typename L, typename R>
+ bool operator <= (const Point_Set<L>& lhs, const Point_Set<R>& rhs);
+
+
+ // FIXME: Guards; without impl!
+ template <typename L, typename R> bool operator < (const Point_Set<L>&, const Point_Set<R>&);
+ template <typename L, typename R> bool operator > (const Point_Set<L>&, const Point_Set<R>&);
+ template <typename L, typename R> bool operator >= (const Point_Set<L>&, const Point_Set<R>&);
+ // end of FIXME
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ // Point_Set L = Point_Set R
+ // ------------------------------
+
+ // Generic version.
+
+ template <typename L, typename R>
+ bool op_eq_(const Point_Set<L>& lhs, const Point_Set<R>& rhs)
+ {
+ oln_piter(L) pl(lhs);
+ oln_piter(R) pr(rhs);
+ for (pl.start(), pr.start();
+ pl.is_valid();
+ pl.next(), pr.next())
+ {
+ if (not pr.is_valid()) // while pl is valid
+ return false;
+ if (pl.to_point() != pr.to_point())
+ return false;
+ }
+ if (pr.is_valid()) // while pl is not valid
+ return false;
+ return true;
+ }
+
+ /*
+ // Version for Boxes.
+
+ FIXME: Activate.
+ template <typename L, typename R>
+ bool op_eq_(const Box<L>& lhs, const Box<R>& rhs)
+ {
+ return lhs.pmin() = rhs.pmin() and lhs.pmax() = rhs.pmax();
+ }
+ */
+
+
+ // Point_Set L <= Point_Set R
+ // ------------------------------
+
+ // Generic version.
+
+ template <typename L, typename R>
+ bool op_leq_(const Point_Set<L>& lhs, const Point_Set<R>& rhs)
+ {
+ // quick test:
+ if (lhs.npoints() > rhs.npoints())
+ return false;
+ // final test:
+ oln_piter(R) pr(rhs);
+ pr.start();
+ oln_piter(L) pl(lhs);
+ for_all(pl)
+ {
+ while (pr.is_valid() and pr.to_point() != pl.to_point())
+ pr.next();
+ if (not pr.is_valid())
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ // Version for Boxes.
+
+ FIXME: Activate.
+ template <typename L, typename R>
+ bool op_leq_(const Box<L>& lhs, const Box<R>& rhs)
+ {
+ for (unsigned i = 0; i < L::n; ++i)
+ if (lhs.pmin()[i] < rhs.pmin()[i] or lhs.pmax()[i] > rhs.pmax()[i])
+ return false;
+ return true;
+ }
+ */
+
+
+ } // end of namespace oln::impl
+
+
+ // Facades.
+
+ template <typename L, typename R>
+ bool operator = (const Point_Set<L>& lhs, const Point_Set<R>& rhs)
+ {
+ mlc::assert_equal_< oln_grid(L), oln_grid(R) >::check(); // FIXME: Add err msg.
+ return impl::op_eq_(exact(lhs), exact(rhs));
+ }
+
+ template <typename L, typename R>
+ bool operator <= (const Point_Set<L>& lhs, const Point_Set<R>& rhs)
+ {
+ mlc::assert_equal_< oln_grid(L), oln_grid(R) >::check(); // FIXME: Add err msg.
+ return impl::op_leq_(exact(lhs), exact(rhs));
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_GEN_PSET_COMPARE_HH
Index: oln/core/internal/point_set_base.hh
--- oln/core/internal/point_set_base.hh (revision 904)
+++ oln/core/internal/point_set_base.hh (working copy)
@@ -34,8 +34,28 @@
namespace oln
{
+
+ namespace internal
+ {
+
+ template <bool Is_box, typename Exact>
+ struct point_set_selector_;
+
+ template <typename Exact>
+ struct point_set_selector_< true, Exact > : public Box<Exact>
+ {};
+
+ template <typename Exact>
+ struct point_set_selector_< false, Exact > : public Point_Set<Exact>
+ {};
+
+ } // end of namespace oln::internal
+
+
+
// point_set_base_ class
+
/// Fwd decls.
namespace internal { template <typename Exact> struct point_set_base_; }
template <typename P> class gen_box;
@@ -46,6 +66,14 @@
struct super_trait_< internal::point_set_base_<Exact> >
{
typedef Point_Set<Exact> ret;
+
+ /*
+ FIXME: Activate to replace the above code.
+
+ typedef stc_deferred(box) box__;
+ typedef mlc::eq_<box__, Exact> test__;
+ typedef internal::point_set_selector_<mlc_bool(test__), Exact> ret;
+ */
};
@@ -74,7 +102,7 @@
/// Base class for point sets.
template <typename Exact>
- struct point_set_base_ : public Point_Set<Exact>
+ struct point_set_base_ : public Point_Set<Exact> // FIXME: Change inheritance.
{
protected:
point_set_base_();
Index: oln/stc/scoop.hxx
--- oln/stc/scoop.hxx (revision 904)
+++ oln/stc/scoop.hxx (working copy)
@@ -88,7 +88,10 @@
/* super_trait_ */
template <typename from_type>
-struct super_trait_;
+struct super_trait_
+{
+ typedef mlc::none ret;
+};
template <typename from_type>
@@ -96,6 +99,11 @@
{
};
+
+/*
+
+ FIXME: Inactivate since dummy code (many class are not Abstractions but abstraction<Exact>).
+
template <template <class> class abstraction, typename Exact>
struct super_trait_< abstraction<Exact> >
{
@@ -109,6 +117,8 @@
typedef mlc::none ret;
};
+*/
+
1
0
23 Mar '07
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Mopho : Top_hat_white, top_hat_black, Fix Opening, Renaming.
* oln/morpho/inside_gradient.hh: Remove.
* oln/morpho/gradient_internal.hh: New.
* oln/morpho/top_hat_black.hh: New.
* oln/morpho/closing.hh: Fixed.
* oln/morpho/top_hat_white.hh: New.
* oln/morpho/opening.hh: Fixed.
* oln/morpho/external_gradient.hh: Remove.
* oln/morpho/gradient_external.hh: New.
* oln/morpho/laplace.hh: .
closing.hh | 4 +-
laplace.hh | 4 +-
opening.hh | 8 ++---
top_hat_black.hh | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
top_hat_white.hh | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 183 insertions(+), 8 deletions(-)
Index: oln/morpho/top_hat_black.hh
--- oln/morpho/top_hat_black.hh (revision 0)
+++ oln/morpho/top_hat_black.hh (revision 0)
@@ -0,0 +1,88 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_MORPHO_TOP_HAT_BLACK_HH
+# define OLN_MORPHO_TOP_HAT_BLACK_HH
+
+#include <oln/morpho/opening.hh>
+#include <oln/morpho/closing.hh>
+#include <oln/arith/minus.hh>
+
+namespace oln
+{
+
+ namespace morpho
+ {
+
+ // Fwd decl.
+
+ template <typename I, typename W>
+ oln_plain(I)
+ top_hat_black(const Image<I>& input,
+ const Window<W>& win);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ // Generic version.
+
+ template <typename I, typename W>
+ oln_plain(I)
+ top_hat_black_(const Image<I>& input,
+ const Window<W>& win)
+ {
+ return closing(input, win) - input;
+ }
+
+
+ // FIXME: Add a fast version.
+
+ } // end of namespace oln::morpho::impl
+
+
+ // Facade.
+
+ template <typename I, typename W>
+ oln_plain(I)
+ top_hat_black(const Image<I>& input,
+ const Window<W>& win)
+ {
+ return impl::top_hat_black_(exact(input), win);
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+
+#endif // ! OLN_MORPHO_TOP_HAT_BLACK_HH
+
Index: oln/morpho/closing.hh
--- oln/morpho/closing.hh (revision 903)
+++ oln/morpho/closing.hh (working copy)
@@ -28,8 +28,8 @@
#ifndef OLN_MORPHO_CLOSING_HH
# define OLN_MORPHO_CLOSING_HH
-#include <oln/morpho/elementary_erosion.hh>
-#include <oln/morpho/elementary_dilation.hh>
+#include <oln/morpho/erosion.hh>
+#include <oln/morpho/dilation.hh>
namespace oln
{
Index: oln/morpho/top_hat_white.hh
--- oln/morpho/top_hat_white.hh (revision 0)
+++ oln/morpho/top_hat_white.hh (revision 0)
@@ -0,0 +1,87 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_MORPHO_TOP_HAT_WHITE_HH
+# define OLN_MORPHO_TOP_HAT_WHITE_HH
+
+#include <oln/morpho/opening.hh>
+#include <oln/morpho/closing.hh>
+#include <oln/arith/minus.hh>
+
+namespace oln
+{
+
+ namespace morpho
+ {
+
+ // Fwd decl.
+
+ template <typename I, typename W>
+ oln_plain(I)
+ top_hat_white(const Image<I>& input,
+ const Window<W>& win);
+
+# ifndef OLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ // Generic version.
+
+ template <typename I, typename W>
+ oln_plain(I)
+ top_hat_white_(const Image<I>& input,
+ const Window<W>& win)
+ {
+ return input - opening(input, win);
+ }
+
+
+ // FIXME: Add a fast version.
+
+ } // end of namespace oln::morpho::impl
+
+
+ // Facade.
+
+ template <typename I, typename W>
+ oln_plain(I)
+ top_hat_white(const Image<I>& input,
+ const Window<W>& win)
+ {
+ return impl::top_hat_white_(exact(input), win);
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+
+#endif // ! OLN_MORPHO_TOP_HAT_WHITE_HH
+
Index: oln/morpho/opening.hh
--- oln/morpho/opening.hh (revision 903)
+++ oln/morpho/opening.hh (working copy)
@@ -28,8 +28,8 @@
#ifndef OLN_MORPHO_OPENING_HH
# define OLN_MORPHO_OPENING_HH
-#include <oln/morpho/elementary_erosion.hh>
-#include <oln/morpho/elementary_dilation.hh>
+#include <oln/morpho/erosion.hh>
+#include <oln/morpho/dilation.hh>
namespace oln
{
@@ -56,8 +56,8 @@
opening_(const Image<I>& input,
const Window<W>& win)
{
- oln_plain(I) tmp = morpho::dilation(input, win);
- return morpho::erosion(tmp, win); // FIXME : inverse(win).
+ oln_plain(I) tmp = morpho::erosion(input, win);
+ return morpho::dilation(tmp, win); // FIXME : inverse(win).
}
// FIXME: Add a fast version.
Index: oln/morpho/laplace.hh
--- oln/morpho/laplace.hh (revision 903)
+++ oln/morpho/laplace.hh (working copy)
@@ -28,8 +28,8 @@
#ifndef OLN_MORPHO_LAPLACE_HH
# define OLN_MORPHO_LAPLACE_HH
-#include <oln/morpho/external_gradient.hh>
-#include <oln/morpho/inside_gradient.hh>
+#include <oln/morpho/gradient_external.hh>
+#include <oln/morpho/gradient_internal.hh>
#include <oln/arith/minus.hh>
namespace oln
1
0
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Add internal::box_ and box2d classes.
* oln/core/rle/rle_image.hh, oln/core/sparse/sparse_image.hh
* oln/core/encode/sparse_encode.hh, oln/core/encode/rle_encode.hh: change licence and header name
* oln/core/1d/box1d.hh: move box_ to gen_box
* oln/core/2d/box2d.hh: box2d is know a real class
* oln/core/gen/box.hh: rename box_ class as gen_box
* oln/core/gen/fbbox.hh: move box_ to gen_box
* oln/core/internal/box.hh: New class internal::box_
* oln/core/internal/point_set_base.hh, oln/core/internal/image_base.hh: .
* oln/core/internal/point_set_std_based.hh: Change vtypes
1d/box1d.hh | 2
2d/box2d.hh | 50 ++++
encode/rle_encode.hh | 1
encode/sparse_encode.hh | 9
gen/box.hh | 142 ++++++-------
gen/fbbox.hh | 10
internal/box.hh | 464 +++++++++++++++++++++++++++++++++++++++++++++
internal/image_base.hh | 14 -
internal/point_set_base.hh | 7
rle/rle_image.hh | 3
sparse/sparse_image.hh | 12 -
11 files changed, 620 insertions(+), 94 deletions(-)
Index: oln/core/rle/rle_image.hh
--- oln/core/rle/rle_image.hh (revision 902)
+++ oln/core/rle/rle_image.hh (working copy)
@@ -1,5 +1,4 @@
-// Copyright (C) 2007 EPITA
-// Research and Development Laboratory
+// Copyright (C) 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
Index: oln/core/sparse/sparse_image.hh
--- oln/core/sparse/sparse_image.hh (revision 902)
+++ oln/core/sparse/sparse_image.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,9 +25,11 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
+
#ifndef OLN_CORE_GEN_SPARSE_IMAGE_HH
# define OLN_CORE_GEN_SPARSE_IMAGE_HH
+
# include <vector>
# include <map>
@@ -64,12 +66,17 @@
typedef rle_pset<point> pset;
- //FIXME:
+ //FIXME: set correct trait
typedef mlc::none plain;
typedef std::pair< pset, std::map<point, std::vector<value> > > data;
};
+ /*!
+ ** \class sparse_image
+ ** \brief represent an image not plain
+ **
+ */
template < typename P, typename T>
class sparse_image : public internal::primitive_image_< sparse_image<P, T> >
{
@@ -159,3 +166,4 @@
} // end of namespace oln
#endif // ! OLN_CORE_GEN_SPARSE_IMAGE_HH
+
Index: oln/core/encode/sparse_encode.hh
--- oln/core/encode/sparse_encode.hh (revision 902)
+++ oln/core/encode/sparse_encode.hh (working copy)
@@ -52,9 +52,12 @@
sparse_image<typename I::point, typename I::value> output;
typename I::piter p(input.points());
unsigned len = 1;
- typename I::coord old = 1; /*!< old point first dim coordinate */
- typename I::point rstart; /*!< range pointstart */
- std::vector<typename I::value> values; /*!< range value */
+ /// old point first dim coordinate
+ typename I::coord old = 1;
+ /// range pointstart
+ typename I::point rstart;
+ /// range value
+ std::vector<typename I::value> values;
p.start();
if (!p.is_valid())
Index: oln/core/encode/rle_encode.hh
--- oln/core/encode/rle_encode.hh (revision 902)
+++ oln/core/encode/rle_encode.hh (working copy)
@@ -33,6 +33,7 @@
# include <oln/core/rle/rle_image.hh>
+
namespace oln
{
Index: oln/core/1d/box1d.hh
--- oln/core/1d/box1d.hh (revision 902)
+++ oln/core/1d/box1d.hh (working copy)
@@ -36,7 +36,7 @@
{
// FIXME: box1d should be an actual type, not an alias...
- typedef box_<point1d> box1d;
+ typedef gen_box<point1d> box1d;
} // end of namespace oln
Index: oln/core/2d/box2d.hh
--- oln/core/2d/box2d.hh (revision 902)
+++ oln/core/2d/box2d.hh (working copy)
@@ -30,6 +30,7 @@
# include <oln/core/concept/point_set.hh> // for internal::tag::box_t
# include <oln/core/2d/point2d.hh>
+# include <oln/core/internal/box.hh>
namespace oln
@@ -39,11 +40,39 @@
template <typename P> class box_;
- // FIXME: box2d should be an actual type, not an alias...
- typedef box_<point2d> box2d;
+ // Forward declarations
+ struct box2d;
+ // Super type
+ template <>
+ struct super_trait_< box2d >
+ {
+ typedef box2d current;
+ typedef internal::box_<box2d> ret;
+ };
+
+ // Virtual types
+ template <>
+ struct vtypes<box2d>
+ {
+ typedef point2d point;
+ typedef box2d box;
+ };
+
+ // Class box2d
+ class box2d : public internal::box_< box2d >
+ {
+ typedef box2d current;
+ typedef internal::box_< box2d > super;
+ public:
+ // Note: we can't use stc_using because box2d isn't a templated class
+ typedef super::point point;
+
+ box2d();
+ box2d(const box2d::from_to_t& dat);
+ box2d(const point2d& pmin, const point2d& pmax);
+ };
- /// init__
namespace internal
{
@@ -68,6 +97,21 @@
namespace oln
{
+ box2d::box2d()
+ {
+ }
+
+ box2d::box2d(const box2d::from_to_t& dat) :
+ super(dat)
+ {
+ }
+
+ box2d::box2d(const point2d& pmin, const point2d& pmax) :
+ super(pmin, pmax)
+ {
+ }
+
+
namespace internal
{
Index: oln/core/gen/box.hh
--- oln/core/gen/box.hh (revision 902)
+++ oln/core/gen/box.hh (working copy)
@@ -39,37 +39,37 @@
// Forward declarations.
- template <typename P> class box_;
- template <typename P> class box_fwd_piter_;
- template <typename P> class box_bkd_piter_;
+ template <typename P> class gen_box;
+ template <typename P> class gen_box_fwd_piter_;
+ template <typename P> class gen_box_bkd_piter_;
// Super type declaration.
template <typename P>
- struct super_trait_< box_<P> >
+ struct super_trait_< gen_box<P> >
{
- typedef box_<P> current__;
+ typedef gen_box<P> current__;
typedef internal::point_set_base_<current__> ret;
};
- /// Virtual types associated to oln::box_<P>.
+ /// Virtual types associated to oln::gen_box<P>.
template <typename P>
- struct vtypes< box_<P> >
+ struct vtypes< gen_box<P> >
{
typedef P point;
- typedef box_fwd_piter_<P> fwd_piter;
- typedef box_bkd_piter_<P> bkd_piter;
+ typedef gen_box_fwd_piter_<P> fwd_piter;
+ typedef gen_box_bkd_piter_<P> bkd_piter;
};
/// Generic box class based on a point class.
template <typename P>
- class box_ : public internal::point_set_base_< box_<P> >,
+ class gen_box : public internal::point_set_base_< gen_box<P> >,
private mlc::assert_< mlc_is_a(P, Point) >
{
- typedef box_<P> current;
+ typedef gen_box<P> current;
typedef internal::point_set_base_<current> super;
typedef internal::initializer_<
@@ -87,16 +87,16 @@
public:
- box_();
- box_(const P& pmin, const P& pmax);
- box_(const from_to_t& data);
+ gen_box();
+ gen_box(const P& pmin, const P& pmax);
+ gen_box(const from_to_t& data);
template <typename D>
- box_(const internal::initializer_<D>& data);
+ gen_box(const internal::initializer_<D>& data);
unsigned impl_npoints() const;
bool impl_has(const P& p) const;
- const box_<P>& impl_bbox() const;
+ const gen_box<P>& impl_bbox() const;
const P& pmin() const;
P& pmin();
@@ -106,17 +106,17 @@
protected:
point pmin_, pmax_;
- }; // end of class oln::box_<P>
+ }; // end of class oln::gen_box<P>
template <typename P>
- std::ostream& operator<<(std::ostream& ostr, const box_<P>& b)
+ std::ostream& operator<<(std::ostream& ostr, const gen_box<P>& b)
{
return ostr << "{ " << b.pmin() << " .. " << b.pmax() << " }";
}
- // -------------------- iterators on box_<P>
+ // -------------------- iterators on gen_box<P>
@@ -124,16 +124,16 @@
/// Super types.
template <typename P>
- struct super_trait_< box_fwd_piter_<P> >
+ struct super_trait_< gen_box_fwd_piter_<P> >
{
- typedef box_fwd_piter_<P> current__;
+ typedef gen_box_fwd_piter_<P> current__;
typedef Iterator_on_Points<current__> ret;
};
template <typename P>
- struct super_trait_< box_bkd_piter_<P> >
+ struct super_trait_< gen_box_bkd_piter_<P> >
{
- typedef box_bkd_piter_<P> current__;
+ typedef gen_box_bkd_piter_<P> current__;
typedef Iterator_on_Points<current__> ret;
};
@@ -141,28 +141,28 @@
/// Virtual types.
template <typename P>
- struct vtypes< box_fwd_piter_<P> >
+ struct vtypes< gen_box_fwd_piter_<P> >
{
typedef P point;
};
template <typename P>
- struct vtypes< box_bkd_piter_<P> >
+ struct vtypes< gen_box_bkd_piter_<P> >
{
typedef P point;
};
- /// Class box_fwd_piter_<P>.
+ /// Class gen_box_fwd_piter_<P>.
template <typename P>
- class box_fwd_piter_ : public Iterator_on_Points< box_fwd_piter_<P> >,
+ class gen_box_fwd_piter_ : public Iterator_on_Points< gen_box_fwd_piter_<P> >,
private mlc::assert_< mlc_is_a(P, Point) >
{
public:
- box_fwd_piter_();
- box_fwd_piter_(const Point_Set< box_<P> >& b);
- void set_box(const box_<P>& b);
+ gen_box_fwd_piter_();
+ gen_box_fwd_piter_(const Point_Set< gen_box<P> >& b);
+ void set_box(const gen_box<P>& b);
void impl_start();
void impl_next();
@@ -172,21 +172,21 @@
const P* impl_point_adr() const;
private:
- box_<P> b_;
+ gen_box<P> b_;
P p_, nop_;
};
- /// Class box_bkd_piter_<P>.
+ /// Class gen_box_bkd_piter_<P>.
template <typename P>
- class box_bkd_piter_ : public Iterator_on_Points< box_bkd_piter_<P> >,
+ class gen_box_bkd_piter_ : public Iterator_on_Points< gen_box_bkd_piter_<P> >,
private mlc::assert_< mlc_is_a(P, Point) >
{
public:
- box_bkd_piter_();
- box_bkd_piter_(const Point_Set< box_<P> >& b);
- void set_box(const box_<P>& b);
+ gen_box_bkd_piter_();
+ gen_box_bkd_piter_(const Point_Set< gen_box<P> >& b);
+ void set_box(const gen_box<P>& b);
void impl_start();
void impl_next();
@@ -196,7 +196,7 @@
const P* impl_point_adr() const;
private:
- box_<P> b_;
+ gen_box<P> b_;
P p_, nop_;
};
@@ -206,16 +206,16 @@
# ifndef OLN_INCLUDE_ONLY
- // -------------------- box_<P>
+ // -------------------- gen_box<P>
template <typename P>
- box_<P>::box_()
+ gen_box<P>::gen_box()
{
}
template <typename P>
- box_<P>::box_(const P& pmin, const P& pmax)
+ gen_box<P>::gen_box(const P& pmin, const P& pmax)
{
for (unsigned i = 0; i < n; ++i)
precondition(pmax[i] >= pmin[i]);
@@ -224,7 +224,7 @@
}
template <typename P>
- box_<P>::box_(const typename box_<P>::from_to_t& dat)
+ gen_box<P>::gen_box(const typename gen_box<P>::from_to_t& dat)
{
this->pmin_ = dat->first.value;
this->pmax_ = dat->second.value;
@@ -232,7 +232,7 @@
template <typename P>
template <typename D>
- box_<P>::box_(const internal::initializer_<D>& data)
+ gen_box<P>::gen_box(const internal::initializer_<D>& data)
{
bool box_ok = internal::init__(internal::tag::box_t(), *this, data.value());
postcondition(box_ok);
@@ -240,7 +240,7 @@
template <typename P>
unsigned
- box_<P>::impl_npoints() const
+ gen_box<P>::impl_npoints() const
{
unsigned count = 1;
for (unsigned i = 0; i < n; ++i)
@@ -250,7 +250,7 @@
template <typename P>
bool
- box_<P>::impl_has(const P& p) const
+ gen_box<P>::impl_has(const P& p) const
{
for (unsigned i = 0; i < n; ++i)
if (p[i] < this->pmin_[i] or p[i] > this->pmax_[i])
@@ -259,15 +259,15 @@
}
template <typename P>
- const box_<P>&
- box_<P>::impl_bbox() const
+ const gen_box<P>&
+ gen_box<P>::impl_bbox() const
{
return *this;
}
template <typename P>
const P&
- box_<P>::pmin() const
+ gen_box<P>::pmin() const
{
for (unsigned i = 0; i < n; ++i)
invariant(this->pmin_[i] <= this->pmax_[i]);
@@ -276,7 +276,7 @@
template <typename P>
const P&
- box_<P>::pmax() const
+ gen_box<P>::pmax() const
{
for (unsigned i = 0; i < n; ++i)
invariant(this->pmax_[i] >= this->pmin_[i]);
@@ -285,35 +285,35 @@
template <typename P>
P&
- box_<P>::pmin()
+ gen_box<P>::pmin()
{
return this->pmin_;
}
template <typename P>
P&
- box_<P>::pmax()
+ gen_box<P>::pmax()
{
return this->pmax_;
}
- // -------------------- box_fwd_piter_<P>
+ // -------------------- gen_box_fwd_piter_<P>
template <typename P>
- box_fwd_piter_<P>::box_fwd_piter_()
+ gen_box_fwd_piter_<P>::gen_box_fwd_piter_()
{
}
template <typename P>
- box_fwd_piter_<P>::box_fwd_piter_(const Point_Set< box_<P> >& b)
+ gen_box_fwd_piter_<P>::gen_box_fwd_piter_(const Point_Set< gen_box<P> >& b)
{
this->set_box(exact(b));
}
template <typename P>
- void box_fwd_piter_<P>::set_box(const box_<P>& b)
+ void gen_box_fwd_piter_<P>::set_box(const gen_box<P>& b)
{
b_ = b;
nop_ = b_.pmax();
@@ -322,13 +322,13 @@
}
template <typename P>
- void box_fwd_piter_<P>::impl_start()
+ void gen_box_fwd_piter_<P>::impl_start()
{
p_ = b_.pmin();
}
template <typename P>
- void box_fwd_piter_<P>::impl_next()
+ void gen_box_fwd_piter_<P>::impl_next()
{
for (int i = P::n - 1; i >= 0; --i)
if (p_[i] == b_.pmax()[i])
@@ -343,47 +343,47 @@
}
template <typename P>
- void box_fwd_piter_<P>::impl_invalidate()
+ void gen_box_fwd_piter_<P>::impl_invalidate()
{
p_ = nop_;
}
template <typename P>
- bool box_fwd_piter_<P>::impl_is_valid() const
+ bool gen_box_fwd_piter_<P>::impl_is_valid() const
{
return p_ != nop_;
}
template <typename P>
- P box_fwd_piter_<P>::impl_to_point() const
+ P gen_box_fwd_piter_<P>::impl_to_point() const
{
return p_;
}
template <typename P>
- const P* box_fwd_piter_<P>::impl_point_adr() const
+ const P* gen_box_fwd_piter_<P>::impl_point_adr() const
{
return &p_;
}
- // -------------------- box_bkd_piter_<P>
+ // -------------------- gen_box_bkd_piter_<P>
template <typename P>
- box_bkd_piter_<P>::box_bkd_piter_()
+ gen_box_bkd_piter_<P>::gen_box_bkd_piter_()
{
}
template <typename P>
- box_bkd_piter_<P>::box_bkd_piter_(const Point_Set< box_<P> >& b)
+ gen_box_bkd_piter_<P>::gen_box_bkd_piter_(const Point_Set< gen_box<P> >& b)
{
this->set_box(exact(b));
}
template <typename P>
- void box_bkd_piter_<P>::set_box(const box_<P>& b)
+ void gen_box_bkd_piter_<P>::set_box(const gen_box<P>& b)
{
b_ = b;
nop_ = b_.pmin();
@@ -392,13 +392,13 @@
}
template <typename P>
- void box_bkd_piter_<P>::impl_start()
+ void gen_box_bkd_piter_<P>::impl_start()
{
p_ = b_.pmax();
}
template <typename P>
- void box_bkd_piter_<P>::impl_next()
+ void gen_box_bkd_piter_<P>::impl_next()
{
for (int i = P::n - 1; i >= 0; --i)
if (p_[i] == b_.pmin()[i])
@@ -413,30 +413,30 @@
}
template <typename P>
- void box_bkd_piter_<P>::impl_invalidate()
+ void gen_box_bkd_piter_<P>::impl_invalidate()
{
p_ = nop_;
}
template <typename P>
- bool box_bkd_piter_<P>::impl_is_valid() const
+ bool gen_box_bkd_piter_<P>::impl_is_valid() const
{
return p_ != nop_;
}
template <typename P>
- P box_bkd_piter_<P>::impl_to_point() const
+ P gen_box_bkd_piter_<P>::impl_to_point() const
{
return p_;
}
template <typename P>
- const P* box_bkd_piter_<P>::impl_point_adr() const
+ const P* gen_box_bkd_piter_<P>::impl_point_adr() const
{
return &p_;
}
-# endif // OLN_INCLUDE_ONLY
+# endif // !OLN_INCLUDE_ONLY
} // end of namespace oln
Index: oln/core/gen/fbbox.hh
--- oln/core/gen/fbbox.hh (revision 902)
+++ oln/core/gen/fbbox.hh (working copy)
@@ -49,16 +49,16 @@
public:
fbbox_();
- operator box_<P>() const;
+ operator gen_box<P>() const;
bool is_valid() const;
void flush();
fbbox_<P>& take(const P& p);
- const box_<P>& box() const;
+ const gen_box<P>& box() const;
private:
bool is_valid_;
- box_<P> b_;
+ gen_box<P> b_;
}; // end of class oln::fbbox_<P>
@@ -73,7 +73,7 @@
}
template <typename P>
- fbbox_<P>::operator box_<P>() const
+ fbbox_<P>::operator gen_box<P>() const
{
precondition(this->is_valid_);
return this->b_;
@@ -112,7 +112,7 @@
}
template <typename P>
- const box_<P>& fbbox_<P>::box() const
+ const gen_box<P>& fbbox_<P>::box() const
{
precondition(this->is_valid_);
return this->b_;
Index: oln/core/internal/box.hh
--- oln/core/internal/box.hh (revision 0)
+++ oln/core/internal/box.hh (revision 0)
@@ -0,0 +1,464 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INTERNAL_BOX_HH
+# define OLN_CORE_INTERNAL_BOX_HH
+
+//# include <oln/core/concept/point.hh>
+# include <oln/core/concept/point_set.hh>
+# include <oln/core/concept/iterator_on_points.hh>
+# include <oln/core/internal/point_set_base.hh>
+
+
+namespace oln
+{
+
+
+ // Forward declarations.
+ namespace internal
+ {
+ template <typename Exact> class box_;
+ template <typename Exact> class box_fwd_piter_;
+ template <typename Exact> class box_bkd_piter_;
+ }
+
+ // Super type declaration.
+ template <typename Exact>
+ struct super_trait_< internal::box_<Exact> >
+ {
+ // typedef box_<Exact> current__;
+ typedef internal::point_set_base_<Exact> ret;
+ };
+
+
+ /// Virtual types associated to oln::box_<P>.
+ template <typename Exact>
+ struct vtypes< internal::box_<Exact> >
+ {
+ //typedef point2d point;
+ typedef stc::final< internal::box_fwd_piter_<Exact> > fwd_piter;
+ typedef stc::final< internal::box_bkd_piter_<Exact> > bkd_piter;
+ };
+
+
+
+ namespace internal
+ {
+ /// Generic box class based on a point class.
+ template <typename Exact>
+ class box_ : public point_set_base_< Exact >
+ {
+ typedef box_<Exact> current;
+ typedef point_set_base_<Exact> super;
+ public:
+ stc_using(point);
+ stc_using(box);
+
+
+ typedef internal::initializer_<
+ internal::pair< internal::from_t<point>, internal::to_t<point> >
+ > from_to_t;
+
+ private:
+ typedef stc_type(point, dim) dim__;
+
+ public:
+ enum { n = mlc_value(dim__) };
+
+
+ unsigned impl_npoints() const;
+ bool impl_has(const point& p) const;
+ const Exact& impl_bbox() const;
+
+ const point& pmin() const;
+ point& pmin();
+ const point& pmax() const;
+ point& pmax();
+
+ protected:
+ box_();
+ box_(const point& pmin, const point& pmax);
+ box_(const from_to_t& data);
+
+ point pmin_, pmax_;
+
+ }; // end of class oln::box_<P>
+
+ template <typename Exact>
+ std::ostream& operator<<(std::ostream& ostr, const box_<Exact>& b)
+ {
+ return ostr << "{ " << b.pmin() << " .. " << b.pmax() << " }";
+ }
+
+ } // end of namespace internal
+
+
+ // -------------------- iterators on box_<Exact>
+
+
+
+
+ /// Super types.
+
+ template <typename B>
+ struct super_trait_< internal::box_fwd_piter_<B> >
+ {
+ typedef internal::box_fwd_piter_<B> current__;
+ typedef Iterator_on_Points<current__> ret;
+ };
+
+ template <typename B>
+ struct super_trait_<internal:: box_bkd_piter_<B> >
+ {
+ typedef internal::box_bkd_piter_<B> current__;
+ typedef Iterator_on_Points<current__> ret;
+ };
+
+
+ /// Virtual types.
+
+ template <typename B>
+ struct vtypes< internal::box_fwd_piter_<B> >
+ {
+ typedef typename B::point point;
+ };
+
+ template <typename B>
+ struct vtypes< internal::box_bkd_piter_<B> >
+ {
+ typedef typename B::point point;
+ };
+
+
+ namespace internal
+ {
+ /// Class box_fwd_piter_<P>.
+
+ template <typename B>
+ class box_fwd_piter_ : public Iterator_on_Points< box_fwd_piter_<B> >,
+ private mlc::assert_< mlc_is_a(B, Point_Set) >
+ {
+ typedef box_fwd_piter_<B> current;
+ typedef Iterator_on_Points<current> super;
+ public:
+ stc_using(point);
+
+ box_fwd_piter_();
+ box_fwd_piter_(const Point_Set< B >& b);
+ void set_box(const B& b);
+
+ void impl_start();
+ void impl_next();
+ void impl_invalidate();
+ bool impl_is_valid() const;
+ point impl_to_point() const;
+ const point* impl_point_adr() const;
+
+ private:
+ B b_;
+ point p_, nop_;
+ };
+
+
+ /// Class box_bkd_piter_<B>.
+
+ template <typename B>
+ class box_bkd_piter_ : public Iterator_on_Points< box_bkd_piter_<B> >,
+ private mlc::assert_< mlc_is_a(B, Point_Set) >
+ {
+ typedef box_bkd_piter_<B> current;
+ typedef Iterator_on_Points<current> super;
+ public:
+ stc_using(point);
+
+ box_bkd_piter_();
+ box_bkd_piter_(const Point_Set< B >& b);
+ void set_box(const B& b);
+
+ void impl_start();
+ void impl_next();
+ void impl_invalidate();
+ bool impl_is_valid() const;
+ point impl_to_point() const;
+ const point* impl_point_adr() const;
+
+ private:
+ B b_;
+ point p_, nop_;
+ };
+
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+
+ // -------------------- box_<Exact>
+
+
+ template <typename Exact>
+ box_<Exact>::box_()
+ {
+ }
+
+ template <typename Exact>
+ box_<Exact>::box_(const box_<Exact>::point& pmin,
+ const box_<Exact>::point& pmax)
+ {
+ for (unsigned i = 0; i < n; ++i)
+ precondition(pmax[i] >= pmin[i]);
+ this->pmin_ = pmin;
+ this->pmax_ = pmax;
+ }
+
+ template <typename P>
+ box_<P>::box_(const typename box_<P>::from_to_t& dat)
+ {
+ this->pmin_ = dat->first.value;
+ this->pmax_ = dat->second.value;
+ }
+
+
+ template <typename Exact>
+ unsigned
+ box_<Exact>::impl_npoints() const
+ {
+ unsigned count = 1;
+ for (unsigned i = 0; i < n; ++i)
+ count *= (this->pmax_[i] - this->pmin_[i] + 1);
+ return count;
+ }
+
+ template <typename Exact>
+ bool
+ box_<Exact>::impl_has(const box_<Exact>::point& p) const
+ {
+ for (unsigned i = 0; i < n; ++i)
+ if (p[i] < this->pmin_[i] or p[i] > this->pmax_[i])
+ return false;
+ return true;
+ }
+
+ template <typename Exact>
+ const Exact&
+ box_<Exact>::impl_bbox() const
+ {
+ return *exact(this);
+ }
+
+ template <typename Exact>
+ const typename box_<Exact>::point&
+ box_<Exact>::pmin() const
+ {
+ for (unsigned i = 0; i < n; ++i)
+ invariant(this->pmin_[i] <= this->pmax_[i]);
+ return this->pmin_;
+ }
+
+ template <typename Exact>
+ const typename box_<Exact>::point&
+ box_<Exact>::pmax() const
+ {
+ for (unsigned i = 0; i < n; ++i)
+ invariant(this->pmax_[i] >= this->pmin_[i]);
+ return this->pmax_;
+ }
+
+ template <typename Exact>
+ typename box_<Exact>::point&
+ box_<Exact>::pmin()
+ {
+ return this->pmin_;
+ }
+
+ template <typename Exact>
+ typename box_<Exact>::point&
+ box_<Exact>::pmax()
+ {
+ return this->pmax_;
+ }
+
+
+ // -------------------- box_fwd_piter_<B>
+
+
+ template <typename B>
+ box_fwd_piter_<B>::box_fwd_piter_()
+ {
+ }
+
+ template <typename B>
+ box_fwd_piter_<B>::box_fwd_piter_(const Point_Set< B >& b)
+ {
+ this->set_box(exact(b));
+ }
+
+ template <typename B>
+ void
+ box_fwd_piter_<B>::set_box(const B& b)
+ {
+ b_ = b;
+ nop_ = b_.pmax();
+ ++nop_[0];
+ p_ = nop_;
+ }
+
+ template <typename B>
+ void
+ box_fwd_piter_<B>::impl_start()
+ {
+ p_ = b_.pmin();
+ }
+
+ template <typename B>
+ void
+ box_fwd_piter_<B>::impl_next()
+ {
+ for (int i = B::n - 1; i >= 0; --i)
+ if (p_[i] == b_.pmax()[i])
+ p_[i] = b_.pmin()[i];
+ else
+ {
+ ++p_[i];
+ break;
+ }
+ if (p_ == b_.pmin())
+ p_ = nop_;
+ }
+
+ template <typename B>
+ void
+ box_fwd_piter_<B>::impl_invalidate()
+ {
+ p_ = nop_;
+ }
+
+ template <typename B>
+ bool
+ box_fwd_piter_<B>::impl_is_valid() const
+ {
+ return p_ != nop_;
+ }
+
+ template <typename B>
+ typename box_fwd_piter_<B>::point
+ box_fwd_piter_<B>::impl_to_point() const
+ {
+ return p_;
+ }
+
+ template <typename B>
+ const typename box_fwd_piter_<B>::point*
+ box_fwd_piter_<B>::impl_point_adr() const
+ {
+ return &p_;
+ }
+
+
+
+ // -------------------- box_bkd_piter_<P>
+
+
+ template <typename B>
+ box_bkd_piter_<B>::box_bkd_piter_()
+ {
+ }
+
+ template <typename B>
+ box_bkd_piter_<B>::box_bkd_piter_(const Point_Set< B >& b)
+ {
+ this->set_box(exact(b));
+ }
+
+ template <typename B>
+ void
+ box_bkd_piter_<B>::set_box(const B& b)
+ {
+ b_ = b;
+ nop_ = b_.pmin();
+ --nop_[0];
+ p_ = nop_;
+ }
+
+ template <typename B>
+ void
+ box_bkd_piter_<B>::impl_start()
+ {
+ p_ = b_.pmax();
+ }
+
+ template <typename B>
+ void
+ box_bkd_piter_<B>::impl_next()
+ {
+ for (int i = B::n - 1; i >= 0; --i)
+ if (p_[i] == b_.pmin()[i])
+ p_[i] = b_.pmax()[i];
+ else
+ {
+ --p_[i];
+ break;
+ }
+ if (p_ == b_.pmax())
+ p_ = nop_;
+ }
+
+ template <typename B>
+ void
+ box_bkd_piter_<B>::impl_invalidate()
+ {
+ p_ = nop_;
+ }
+
+ template <typename B>
+ bool
+ box_bkd_piter_<B>::impl_is_valid() const
+ {
+ return p_ != nop_;
+ }
+
+ template <typename B>
+ typename box_bkd_piter_<B>::point
+ box_bkd_piter_<B>::impl_to_point() const
+ {
+ return p_;
+ }
+
+ template <typename B>
+ const typename box_bkd_piter_<B>::point*
+ box_bkd_piter_<B>::impl_point_adr() const
+ {
+ return &p_;
+ }
+
+# endif // OLN_INCLUDE_ONLY
+ } // end of namespace internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_BOX_HH
Index: oln/core/internal/point_set_base.hh
--- oln/core/internal/point_set_base.hh (revision 902)
+++ oln/core/internal/point_set_base.hh (working copy)
@@ -34,9 +34,11 @@
namespace oln
{
+ // point_set_base_ class
+
/// Fwd decls.
namespace internal { template <typename Exact> struct point_set_base_; }
- template <typename P> class box_;
+ template <typename P> class gen_box;
/// Super type.
@@ -59,7 +61,8 @@
typedef stc_deferred(fwd_piter) fwd_piter__;
typedef stc::final< stc::is<Point_Set> > category;
- typedef stc::final< box_<point__> > box;
+ //FIXME:
+ typedef gen_box<point__> box;
typedef stc::final< oln_grid(point__) > grid;
typedef stc::final< fwd_piter__ > piter;
};
Index: oln/core/internal/image_base.hh
--- oln/core/internal/image_base.hh (revision 902)
+++ oln/core/internal/image_base.hh (working copy)
@@ -148,7 +148,9 @@
// Final.
typedef stc::final< stc::is<Image> > category;
- typedef stc::final< box_<point__> > box;
+ // FIXME:
+ //typedef stc::final< box_<point__> > box;
+ typedef stc::final <typename pset__::box> box;
typedef stc::final< oln_grid(point__) > grid;
typedef stc::final< oln_dpoint(point__) > dpoint;
typedef stc::final< oln_fwd_piter(pset__) > fwd_piter;
@@ -433,19 +435,20 @@
// init
template <typename P, typename I>
- bool init_(box_<P>* this_, const internal::image_base_<I>& data);
+ bool init_(typename internal::image_base_<I>::box* this_, const internal::image_base_<I>& data);
template <typename Target, typename I>
bool init_(Any<Target>* this_, const internal::single_image_morpher_<I>& data);
template <typename P, typename I> // for disambiguation purpose
- bool init_(box_<P>* this_, const internal::single_image_morpher_<I>& data);
+ bool
+ init_(typename internal::image_base_<I>::box** this_, const internal::single_image_morpher_<I>& data);
# ifndef OLN_INCLUDE_ONLY
template <typename P, typename I>
- bool init_(box_<P>* this_, const internal::image_base_<I>& data)
+ bool init_(typename internal::image_base_<I>::box** this_, const internal::image_base_<I>& data)
{
*this_ = data.bbox();
return true;
@@ -458,7 +461,8 @@
}
template <typename P, typename I>
- bool init_(box_<P>* this_, const internal::single_image_morpher_<I>& data)
+ bool
+ init_(typename internal::image_base_<I>::box** this_, const internal::single_image_morpher_<I>& data)
{
*this_ = data.bbox();
return true;
Index: oln/core/internal/point_set_std_based.hh
1
0
23 Mar '07
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Morpho : Gradient, gradient+ gradient-, Laplace. Arith : +, -.
* oln/morpho/laplace.hh: New.
* oln/morpho/inside_gradient.hh: New.
* oln/morpho/gradient.hh: New.
* oln/morpho/external_gradient.hh: New.
* oln/arith: New.
* oln/arith/plus.hh: New.
* oln/arith/minus.hh: New.
* oln/core/concept/operators.hh: .
* oln/core/2d/image2d.hh: .
arith/minus.hh | 64 +++++++++++++++++++++++++++++++++
arith/plus.hh | 64 +++++++++++++++++++++++++++++++++
core/2d/image2d.hh | 2 -
core/concept/operators.hh | 3 +
morpho/external_gradient.hh | 83 +++++++++++++++++++++++++++++++++++++++++++
morpho/gradient.hh | 84 ++++++++++++++++++++++++++++++++++++++++++++
morpho/inside_gradient.hh | 83 +++++++++++++++++++++++++++++++++++++++++++
morpho/laplace.hh | 84 ++++++++++++++++++++++++++++++++++++++++++++
8 files changed, 465 insertions(+), 2 deletions(-)
Index: oln/morpho/laplace.hh
--- oln/morpho/laplace.hh (revision 0)
+++ oln/morpho/laplace.hh (revision 0)
@@ -0,0 +1,84 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_MORPHO_LAPLACE_HH
+# define OLN_MORPHO_LAPLACE_HH
+
+#include <oln/morpho/external_gradient.hh>
+#include <oln/morpho/inside_gradient.hh>
+#include <oln/arith/minus.hh>
+
+namespace oln
+{
+
+ namespace morpho
+ {
+
+ // Fwd decl.
+
+ template <typename I>
+ oln_plain(I)
+ laplace(const Image_with_Nbh<I>& input);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ // Generic version.
+
+ template <typename I>
+ oln_plain(I)
+ laplace_(const Image_with_Nbh<I>& input)
+ {
+ return external_gradient(input) - inside_gradient(input);
+ }
+
+
+ // FIXME: Add a fast version.
+
+ } // end of namespace oln::morpho::impl
+
+
+ // Facade.
+
+ template <typename I>
+ oln_plain(I)
+ laplace(const Image_with_Nbh<I>& input)
+ {
+ return impl::laplace_(exact(input));
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+
+#endif // ! OLN_MORPHO_LAPLACE_HH
Index: oln/morpho/inside_gradient.hh
--- oln/morpho/inside_gradient.hh (revision 0)
+++ oln/morpho/inside_gradient.hh (revision 0)
@@ -0,0 +1,83 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_MORPHO_INSIDE_GRADIENT_HH
+# define OLN_MORPHO_INSIDE_GRADIENT_HH
+
+#include <oln/morpho/elementary_erosion.hh>
+#include <oln/arith/minus.hh>
+
+namespace oln
+{
+
+ namespace morpho
+ {
+
+ // Fwd decl.
+
+ template <typename I>
+ oln_plain(I)
+ inside_gradient(const Image_with_Nbh<I>& input);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ // Generic version.
+
+ template <typename I>
+ oln_plain(I)
+ inside_gradient_(const Image_with_Nbh<I>& input)
+ {
+ return input - elementary_erosion(input);
+ }
+
+
+ // FIXME: Add a fast version.
+
+ } // end of namespace oln::morpho::impl
+
+
+ // Facade.
+
+ template <typename I>
+ oln_plain(I)
+ inside_gradient(const Image_with_Nbh<I>& input)
+ {
+ return impl::inside_gradient_(exact(input));
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+
+#endif // ! OLN_MORPHO_INSIDE_GRADIENT_HH
Index: oln/morpho/gradient.hh
--- oln/morpho/gradient.hh (revision 0)
+++ oln/morpho/gradient.hh (revision 0)
@@ -0,0 +1,84 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_MORPHO_GRADIENT_HH
+# define OLN_MORPHO_GRADIENT_HH
+
+#include <oln/morpho/elementary_erosion.hh>
+#include <oln/morpho/elementary_dilation.hh>
+#include <oln/arith/minus.hh>
+
+namespace oln
+{
+
+ namespace morpho
+ {
+
+ // Fwd decl.
+
+ template <typename I>
+ oln_plain(I)
+ gradient(const Image_with_Nbh<I>& input);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ // Generic version.
+
+ template <typename I>
+ oln_plain(I)
+ gradient_(const Image_with_Nbh<I>& input)
+ {
+ return elementary_dilation(input) - elementary_erosion(input);
+ }
+
+
+ // FIXME: Add a fast version.
+
+ } // end of namespace oln::morpho::impl
+
+
+ // Facade.
+
+ template <typename I>
+ oln_plain(I)
+ gradient(const Image_with_Nbh<I>& input)
+ {
+ return impl::gradient_(exact(input));
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+
+#endif // ! OLN_MORPHO_GRADIENT_HH
Index: oln/morpho/external_gradient.hh
--- oln/morpho/external_gradient.hh (revision 0)
+++ oln/morpho/external_gradient.hh (revision 0)
@@ -0,0 +1,83 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_MORPHO_EXTERNAL_GRADIENT_HH
+# define OLN_MORPHO_EXTERNAL_GRADIENT_HH
+
+#include <oln/morpho/elementary_dilation.hh>
+#include <oln/arith/minus.hh>
+
+namespace oln
+{
+
+ namespace morpho
+ {
+
+ // Fwd decl.
+
+ template <typename I>
+ oln_plain(I)
+ external_gradient(const Image_with_Nbh<I>& input);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ // Generic version.
+
+ template <typename I>
+ oln_plain(I)
+ external_gradient_(const Image_with_Nbh<I>& input)
+ {
+ return elementary_dilation(input) - input;
+ }
+
+
+ // FIXME: Add a fast version.
+
+ } // end of namespace oln::morpho::impl
+
+
+ // Facade.
+
+ template <typename I>
+ oln_plain(I)
+ external_gradient(const Image_with_Nbh<I>& input)
+ {
+ return impl::external_gradient_(exact(input));
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+
+#endif // ! OLN_MORPHO_EXTERNAL_GRADIENT_HH
Index: oln/arith/plus.hh
--- oln/arith/plus.hh (revision 0)
+++ oln/arith/plus.hh (revision 0)
@@ -0,0 +1,64 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_ARITH_PLUS_HH
+# define OLN_ARITH_PLUS_HH
+
+
+namespace oln
+{
+
+ namespace arith
+ {
+
+ // Fwd decl.
+
+ template <typename I>
+ oln_plain(I)
+ operator + (const Image<I>& lhs, const Image<I>& rhs);
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename I>
+ oln_plain(I)
+ operator + (const Image<I>& lhs, const Image<I>& rhs)
+ {
+ oln_plain(I) output;
+ init(output, with, lhs);
+ oln_piter(I) p(lhs.points());
+ for_all(p)
+ output(p) = lhs(p) + rhs(p);
+ return output;
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+ } // end of namespace oln::arith
+
+} // end of namespace oln
+
+#endif // ! OLN_ARITH_PLUS_HH
Index: oln/arith/minus.hh
--- oln/arith/minus.hh (revision 0)
+++ oln/arith/minus.hh (revision 0)
@@ -0,0 +1,64 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_ARITH_MINUS_HH
+# define OLN_ARITH_MINUS_HH
+
+
+namespace oln
+{
+
+// namespace arith
+// {
+
+ // Fwd decl.
+
+ template <typename I>
+ oln_plain(I)
+ operator - (const Image<I>& lhs, const Image<I>& rhs);
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename I>
+ oln_plain(I)
+ operator - (const Image<I>& lhs, const Image<I>& rhs)
+ {
+ oln_plain(I) output;
+ init(output, with, lhs);
+ oln_piter(I) p(lhs.points());
+ for_all(p)
+ output(p) = lhs(p) - rhs(p);
+ return output;
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+// } // end of namespace oln::arith
+
+} // end of namespace oln
+
+#endif // ! OLN_ARITH_MINUS_HH
Index: oln/core/concept/operators.hh
--- oln/core/concept/operators.hh (revision 901)
+++ oln/core/concept/operators.hh (working copy)
@@ -158,12 +158,13 @@
return exact(rhs).op_unary_minus_();
}
- template <typename T>
+/* template <typename T>
T operator- (const Any<T>& lhs, const Any<T>& rhs)
{
T tmp = exact(lhs);
return tmp -= rhs;
}
+*/
// template <typename L, typename R>
// xtd_op_minus_trait(L, R) operator- (const Any<L>& lhs, const Any<R>& rhs)
Index: oln/core/2d/image2d.hh
--- oln/core/2d/image2d.hh (revision 901)
+++ oln/core/2d/image2d.hh (working copy)
@@ -213,7 +213,7 @@
box2d b;
bool box_ok = init(b, with, dat);
postcondition(box_ok);
- array2d_<T,int> ptr = new array2d_<T,int>(b.pmin().row(),
+ array2d_<T,int>* ptr = new array2d_<T,int>(b.pmin().row(),
b.pmin().col(),
b.pmax().row(),
b.pmax().col());
1
0