(désolé ! le système de commit auto a chié)
2005-03-31 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* oln/core/abstract/image_like_.hh: New.
* oln/core/abstract/image_operator.hh: New.
* oln/core/abstract/image_by_delegation.hh: New.
* oln/core/abstract/image_identity.hh: Move to...
* oln/core/gen/identity.hh: here.
* tests/core/tests/image_identity: Update.
* oln/core/abstract/op.hh: Update.
* oln/core/2d/image2d.hh: Update.
* oln/core/box.hh (image()): Rename into...
* oln/core/box.hh (unbox()): this.
* oln/utils/clone.hh: Update.
* oln/basics.hh: Likewise.
* oln/morpho/dilation.hh: Likewise.
* oln/morpho/erosion.hh: Likewise.
* oln/io/read_image_2d_pnm.hh: Cosmetic change.
* oln/arith/min.hh: Likewise.
* oln/arith/max.hh: Likewise.
Index: tests/core/tests/image_identity
===================================================================
--- tests/core/tests/image_identity (revision 98)
+++ tests/core/tests/image_identity (working copy)
@@ -1,47 +1,18 @@
-#include <oln/core/abstract/image_identity.hh>
#include <oln/core/2d/image2d.hh>
+#include <oln/core/gen/identity.hh>
#include <ntg/all.hh>
-template <typename I>
-struct image_identity;
-namespace oln {
-
- template <typename I>
- struct set_category< image_identity<I> >
- {
- typedef category::image ret;
- };
-
- template <typename I>
- struct set_props < category::image, image_identity<I> >
- : public get_props < category::image, I >
- {
- typedef I delegated_type;
- };
-
-}
-
-template <typename I>
-struct image_identity : public oln::abstract::image_identity<I,
image_identity<I> >
-{
- typedef oln::abstract::image_identity<I, image_identity<I> > super_type;
-
- image_identity(I& ima) : super_type(ima)
- {
- this->exact_ptr = (image_identity<I>*)(void*)(this);
- }
-};
-
-
bool check()
{
- oln::image2d<ntg::int_u8> ima(10, 10);
- image_identity<oln::image2d<ntg::int_u8> > _ima(ima);
- image_identity<image_identity<oln::image2d<ntg::int_u8> > >
__ima(_ima);
- oln::point2d p(0, 0);
+ using namespace oln;
+ point2d p(0, 0);
+ image2d<ntg::int_u8> ima(10, 10);
+ internal::image_identity< image2d<ntg::int_u8> > _ima(ima);
+ internal::image_identity< internal::image_identity< image2d<ntg::int_u8>
> > __ima(_ima);
+
__ima[p] = 'a';
ntg::int_u8 b = ima[p];
if (b == 'a')
Index: oln/core/abstract/image_like_.hh
===================================================================
--- oln/core/abstract/image_like_.hh (revision 0)
+++ oln/core/abstract/image_like_.hh (revision 0)
@@ -0,0 +1,99 @@
+// Copyright (C) 2005 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLENA_CORE_ABSTRACT_IMAGE_LIKE__HH
+# define OLENA_CORE_ABSTRACT_IMAGE_LIKE__HH
+
+# include <oln/core/abstract/image_by_delegation.hh>
+
+
+namespace oln {
+
+
+ // fwd decl
+ namespace abstract {
+ template <typename I, typename E> struct image_like_;
+ }
+
+ // category
+
+ template <typename I, typename E>
+ struct set_category< abstract::image_like_<I, E> > {
+ typedef category::image ret;
+ };
+
+ // super type
+
+ template <typename I, typename E>
+ struct set_super_type < abstract::image_like_<I, E> >
+ {
+ typedef abstract::image_by_delegation<I, E> ret;
+ };
+
+
+
+
+ namespace abstract {
+
+ /// Mutable version of image_like_.
+
+ template <typename I, typename E>
+ struct image_like_ : public image_by_delegation<I, E>
+ {
+ typedef image_by_delegation<I, E> super_type;
+
+ public:
+
+ image_like_ ()
+ {
+ }
+
+ image_like_(abstract::image<I>& image) :
+ super_type(image)
+ {
+ }
+
+ const I& real() const
+ {
+ return this->image_.unbox();
+ }
+
+ I& real()
+ {
+ return this->image_.unbox();
+ }
+
+ };
+
+ } // end of namespace oln::abstract
+
+
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_ABSTRACT_IMAGE_LIKE__HH
Index: oln/core/abstract/image_identity.hh
===================================================================
--- oln/core/abstract/image_identity.hh (revision 98)
+++ oln/core/abstract/image_identity.hh (working copy)
@@ -1,124 +0,0 @@
-// Copyright (C) 2005 EPITA Research and Development Laboratory
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
-// MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#ifndef OLENA_CORE_ABSTRACT_IMAGE_IDENTITY_HH
-# define OLENA_CORE_ABSTRACT_IMAGE_IDENTITY_HH
-
-# include <mlc/box.hh>
-
-# include <oln/core/properties.hh>
-# include <oln/core/abstract/entry.hh>
-
-
-namespace oln {
-
-
- // fwd decl
- namespace abstract {
- template <typename I, typename E> struct image_identity;
- }
-
- // category
- template <typename I, typename E>
- struct set_category< abstract::image_identity<I,E> > {
- typedef category::image ret;
- };
-
- // props
- template <typename I, typename E>
- struct set_props < category::image, abstract::image_identity<I,E> >
- : public get_props< category::image, I >
- {
- typedef I delegated_type;
- };
-
-
-
- namespace abstract {
-
- template <typename I, typename E>
- struct image_identity : public abstract::image_entry<E>
- {
- protected:
-
- image_identity () {}
-
- image_identity(abstract::image<I>& image) : image_(image.exact())
- {}
-
- image_identity(const image_identity& rhs) : image_(rhs.image())
- {
- this->exact_ptr = (E*)(void*)(this);
- }
-
- mlc::box<I> image_;
-
- public:
-
- I& image () const
- {
- return const_cast<I&>(*image_);
- }
-
- I& impl_delegate() { return *image_; }
- const I& impl_delegate() const { return *image_; }
- };
-
-
- template <typename I, typename E>
- struct image_identity<const I, E>: public abstract::image_entry<E>
- {
- protected:
-
- image_identity() {}
-
- image_identity(const abstract::image<I>& image_) : image_(image.exact())
- {}
-
- image_identity(const image_identity& rhs) : image_(rhs.image())
- {
- this->exact_ptr = (E*)(void*)(this);
- }
-
- mlc::box<const I> image_;
-
- public:
- const I& image () const
- {
- return *image_;
- }
-
- I& impl_delegate() { return *image_; }
- const I& impl_delegate() const { return *image_; }
- };
-
- }
-
-}
-
-
-#endif // ! OLENA_CORE_ABSTRACT_IMAGE_IDENTITY_HH
Index: oln/core/abstract/image_operator.hh
===================================================================
--- oln/core/abstract/image_operator.hh (revision 0)
+++ oln/core/abstract/image_operator.hh (revision 0)
@@ -0,0 +1,166 @@
+// Copyright (C) 2005 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLENA_CORE_ABSTRACT_IMAGE_OPERATOR_HH
+# define OLENA_CORE_ABSTRACT_IMAGE_OPERATOR_HH
+
+# include <oln/core/abstract/image_like_.hh>
+
+namespace oln {
+
+ // fwd decls
+ namespace abstract {
+ template <typename O, typename E> struct image_operator;
+ template <typename O, typename I, typename E> struct image_unary_operator;
+ template <typename O, typename I1, typename I2, typename E> struct
image_binary_operator;
+ }
+
+ // category
+ template <typename O, typename E>
+ struct set_category< abstract::image_operator<O, E> > { typedef
category::image ret; };
+ template <typename O, typename I, typename E>
+ struct set_category< abstract::image_unary_operator<O, I, E> > { typedef
category::image ret; };
+ template <typename O, typename I1, typename I2, typename E>
+ struct set_category< abstract::image_binary_operator<O, I1, I2, E> > {
typedef category::image ret; };
+
+ // super types
+ template <typename O, typename E>
+ struct set_super_type< abstract::image_operator<O, E> > { typedef
abstract::image_like_<O, E> ret; };
+ template <typename O, typename I, typename E>
+ struct set_super_type< abstract::image_unary_operator<O, I, E> > { typedef
abstract::image_operator<O, E> ret; };
+ template <typename O, typename I1, typename I2, typename E>
+ struct set_super_type< abstract::image_binary_operator<O, I1, I2, E> > {
typedef abstract::image_operator<O, E> ret; };
+
+
+ namespace abstract {
+
+
+ /// Class image_operator.
+ // FIXME: some methods here should be defined in a real OO abstraction
+
+ template <typename O, typename E>
+ struct image_operator : public image_like_<O, E>
+ {
+
+ /// run
+
+ void run()
+ {
+ this->impl_precondition();
+ this->impl_before_run();
+ this->impl_run();
+ this->impl_after_run();
+
+ this->image_ = this->output;
+
+ this->impl_postcondition();
+ }
+
+ virtual void impl_run()
+ {
+ // impl_run is defined here so that base operators can be instantiated
+ std::cerr << "oops: nothing done!" << std::endl;
+ }
+
+ virtual void impl_before_run()
+ {
+ // nothing
+ }
+
+ virtual void impl_after_run()
+ {
+ // nothing
+ }
+
+ virtual void impl_precondition()
+ {
+ // none
+ }
+
+ virtual void impl_postcondition()
+ {
+ // none
+ }
+
+ box<O> output;
+
+ protected:
+ image_operator() {}
+
+ };
+
+
+ /// Class image_unary_operator.
+
+ template <typename O, typename I, typename E>
+ struct image_unary_operator : public image_operator<O, E>
+ {
+ box<const I> input;
+
+ protected:
+
+ image_unary_operator() {}
+
+ image_unary_operator(const abstract::image<I>& input) :
+ input(input)
+ {
+ }
+
+ };
+
+
+ /// Class image_binary_operator.
+
+ template <typename O, typename I1, typename I2, typename E>
+ struct image_binary_operator : public image_operator<O, E>
+ {
+
+ box<const I1> input1;
+ box<const I2> input2;
+
+ protected:
+
+ image_binary_operator() {}
+
+ image_binary_operator(const abstract::image<I1>& input1,
+ const abstract::image<I2>& input2) :
+ input1(input1),
+ input2(input2)
+ {
+ }
+
+ };
+
+
+ } // end of namespace oln::abstract
+
+
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_ABSTRACT_IMAGE_OPERATOR_HH
Index: oln/core/abstract/image_by_delegation.hh
===================================================================
--- oln/core/abstract/image_by_delegation.hh (revision 0)
+++ oln/core/abstract/image_by_delegation.hh (revision 0)
@@ -0,0 +1,145 @@
+// Copyright (C) 2005 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+// MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLENA_CORE_ABSTRACT_IMAGE_BY_DELEGATION_HH
+# define OLENA_CORE_ABSTRACT_IMAGE_BY_DELEGATION_HH
+
+# include <oln/core/box.hh>
+# include <oln/core/properties.hh>
+# include <oln/core/abstract/entry.hh>
+
+
+namespace oln {
+
+
+ // fwd decl
+ namespace abstract {
+ template <typename I, typename E> struct image_by_delegation;
+ }
+
+ // category
+
+ template <typename I, typename E>
+ struct set_category< abstract::image_by_delegation<I, E> > {
+ typedef category::image ret;
+ };
+
+ template <typename I, typename E>
+ struct set_category< abstract::image_by_delegation<const I, E> > {
+ typedef category::image ret;
+ };
+
+ // props
+
+ template <typename I, typename E>
+ struct set_props < category::image, abstract::image_by_delegation<I, E> >
+ : public get_props< category::image, I >
+ {
+ typedef I delegated_type;
+ };
+
+ template <typename I, typename E>
+ struct set_props < category::image, abstract::image_by_delegation<const I, E>
>
+ : public get_props< category::image, I >
+ {
+ typedef I delegated_type;
+ };
+
+
+
+
+ namespace abstract {
+
+ /// Mutable version of image_by_delegation
+
+ template <typename I, typename E>
+ struct image_by_delegation : public image_entry<E>
+ {
+ protected:
+
+ image_by_delegation ()
+ {
+ this->exact_ptr = (E*)(void*)(this);
+ }
+
+ image_by_delegation(abstract::image<I>& image) :
+ image_(image.exact())
+ {
+ this->exact_ptr = (E*)(void*)(this);
+ }
+
+ image_by_delegation(const image_by_delegation& rhs) :
+ image_(rhs.image_)
+ {
+ this->exact_ptr = (E*)(void*)(this);
+ }
+
+ box<I> image_;
+
+ public:
+
+ I& impl_delegate() { return this->image_.unbox(); }
+ const I& impl_delegate() const { return this->image_.unbox(); }
+ };
+
+ /// Const version of image_by_delegation
+
+ template <typename I, typename E>
+ struct image_by_delegation<const I, E> : public image_entry<E>
+ {
+ protected:
+
+ image_by_delegation()
+ {
+ this->exact_ptr = (E*)(void*)(this);
+ }
+
+ image_by_delegation(const abstract::image<I>& ima) :
+ image_(ima.exact())
+ {
+ this->exact_ptr = (E*)(void*)(this);
+ }
+
+ image_by_delegation(const image_by_delegation& rhs) :
+ image_(rhs.image())
+ {
+ this->exact_ptr = (E*)(void*)(this);
+ }
+
+ box<const I> image_;
+
+ public:
+
+ const I& impl_delegate() const { return this->image_.unbox(); }
+ };
+
+ }
+
+}
+
+
+#endif // ! OLENA_CORE_ABSTRACT_IMAGE_BY_DELEGATION_HH
Index: oln/core/abstract/op.hh
===================================================================
--- oln/core/abstract/op.hh (revision 98)
+++ oln/core/abstract/op.hh (working copy)
@@ -29,7 +29,7 @@
# define OLENA_CORE_ABSTRACT_OP_HH
# include <oln/core/box.hh>
-# include <oln/core/abstract/image_identity.hh>
+# include <oln/core/abstract/image_like_.hh>
namespace oln {
@@ -44,15 +44,15 @@
// super_type
template <typename O, typename E>
- struct set_super_type< abstract::op<O,E> > { typedef
abstract::image_identity<O, E> ret; };
+ struct set_super_type< abstract::op<O,E> > { typedef
abstract::image_like_<O, E> ret; };
namespace abstract {
template <typename O, typename E>
- struct op : public image_identity<O, E>
+ struct op : public image_like_<O, E>
{
- typedef image_identity<O, E> super_type;
+ typedef image_like_<O, E> super_type;
op(O& ref) : super_type(ref)
{
Index: oln/core/2d/image2d.hh
===================================================================
--- oln/core/2d/image2d.hh (revision 98)
+++ oln/core/2d/image2d.hh (working copy)
@@ -30,7 +30,7 @@
# include <mlc/traits.hh>
-# include <oln/core/abstract/image_identity.hh>
+# include <oln/core/abstract/image_like_.hh>
# include <oln/core/abstract/image_with_data.hh>
# include <oln/core/abstract/image_vectorialness.hh>
# include <oln/core/2d/array2d.hh>
@@ -155,9 +155,10 @@
};
template <typename I, typename E>
- image2d& operator=(const abstract::image_identity<I, E>& rhs)
+ image2d& operator=(abstract::image_like_<I, E> rhs)
{
- return *this = rhs.image();
+ *this = rhs.real();
+ return *this;
}
image2d& operator=(const io::filename& rhs)
Index: oln/core/box.hh
===================================================================
--- oln/core/box.hh (revision 98)
+++ oln/core/box.hh (working copy)
@@ -117,15 +117,15 @@
/// Hooks.
-// I& image()
-// {
-// return this->image_;
-// }
+ I& unbox()
+ {
+ return this->image_;
+ }
-// const I& image() const
-// {
-// return this->image_;
-// }
+ const I& unbox() const
+ {
+ return this->image_;
+ }
private:
@@ -194,10 +194,10 @@
/// Hook.
-// const I& image() const
-// {
-// return this->image_;
-// }
+ const I& unbox() const
+ {
+ return this->image_;
+ }
private:
Index: oln/utils/clone.hh
===================================================================
--- oln/utils/clone.hh (revision 98)
+++ oln/utils/clone.hh (working copy)
@@ -28,18 +28,15 @@
#ifndef OLN_UTILS_CLONE_HH
# define OLN_UTILS_CLONE_HH
-# include <oln/core/abstract/op.hh>
-# include <oln/core/abstract/piter.hh>
+# include <oln/basics.hh>
namespace oln {
// fwd decl
namespace utils {
-
namespace impl {
template <typename I> struct clone_type;
}
-
}
// category
@@ -53,7 +50,7 @@
template <typename I>
struct set_super_type < utils::impl::clone_type<I> >
{
- typedef abstract::op<I, utils::impl::clone_type<I> > ret;
+ typedef abstract::image_unary_operator<I, I, utils::impl::clone_type<I> >
ret;
};
@@ -63,40 +60,41 @@
namespace impl {
template <typename I>
- struct clone_type : abstract::op<I, clone_type<I> >
+ struct clone_type : public abstract::image_unary_operator<I, I,
clone_type<I> >
+ // FIXME: use concrete_type; Cf. erosion.hh
{
- typedef abstract::op<I, clone_type<I> > super_type;
+ typedef abstract::image_unary_operator<I, I, clone_type<I> > super_type;
- box<I> input_;
-
- clone_type(I& input) :
- input_(input)
+ clone_type(const abstract::image<I>& input) :
+ super_type(input)
{
}
void impl_run()
{
- I ima(input_.size());
- oln_type_of(I, fwd_piter) p(input_.size());
+ I tmp(input.size()); // FIXME: trick
+ output = tmp;
+ oln_type_of(I, fwd_piter) p(input.size());
for_all(p)
- ima[p] = input_[p];
-
- *this->image_ = ima;
+ output[p] = input[p];
}
};
- }
+ } // end of namespace oln::utils::impl
+
template <typename I>
- impl::clone_type<I> clone(abstract::image<I>& ima)
+ impl::clone_type<I> clone(const abstract::image<I>& ima)
{
impl::clone_type<I> tmp(ima.exact());
tmp.run();
return tmp;
}
- }
-}
+ } // end of namespace oln::utils
+} // end of namespace oln
+
+
#endif // ! OLN_UTILS_CLONE_HH
Index: oln/basics.hh
===================================================================
--- oln/basics.hh (revision 98)
+++ oln/basics.hh (working copy)
@@ -52,13 +52,13 @@
# include <oln/core/coord.hh>
# include <oln/core/properties.hh>
# include <oln/core/value_box.hh>
+# include <oln/core/box.hh>
# include <oln/core/abstract/size.hh>
# include <oln/core/abstract/point.hh>
# include <oln/core/abstract/images.hh>
# include <oln/core/abstract/entry.hh>
-# include <oln/core/box.hh>
-# include <oln/core/abstract/op.hh>
+# include <oln/core/abstract/image_operator.hh>
# include <oln/core/abstract/piter.hh>
# include <oln/core/abstract/witer.hh>
Index: oln/morpho/dilation.hh
===================================================================
--- oln/morpho/dilation.hh (revision 98)
+++ oln/morpho/dilation.hh (working copy)
@@ -30,6 +30,7 @@
# include <oln/basics.hh>
# include <oln/morpho/stat.hh>
+# include <oln/core/abstract/image_operator.hh>
// # include <oln/morpho/fast_morpho.hh>
# include <mlc/cmp.hh>
@@ -103,34 +104,36 @@
template <typename I, typename E>
struct set_super_type< morpho::impl::dilation_type<I,E> >
{
- typedef abstract::op<I, morpho::impl::dilation_type<I, E> > ret;
+ typedef abstract::image_unary_operator<I, I, morpho::impl::dilation_type<I,
E> > ret; // FIXME: see below
};
namespace morpho {
namespace impl {
- template <class I, class E>
- struct dilation_type : abstract::op<I, dilation_type<I, E> >
+ template <typename I, typename E>
+ struct dilation_type : public abstract::image_unary_operator<I, I,
dilation_type<I, E> >
+ // FIXME: abstract::image_unary_operator<oln_type_of(I, concrete), ...
{
- box<const I> input_;
- const E se_;
+ typedef abstract::image_unary_operator<I, I, dilation_type<I, E> >
super_type;
+ const E se;
+
dilation_type(const abstract::non_vectorial_image<I>& input,
- const abstract::struct_elt<E>& se) :
- input_(input.exact()),
- se_(se.exact())
+ const abstract::struct_elt<E>& se) :
+ super_type(input.exact()),
+ se(se.exact())
{}
};
- template <class I, class E>
- struct dilation_type_classic : dilation_type<I, E>
+ template <typename I, typename E>
+ struct dilation_type_classic : public dilation_type<I, E>
{
typedef dilation_type<I, E> super_type;
dilation_type_classic(const abstract::non_vectorial_image<I>& input,
- const abstract::struct_elt<E>& se) :
+ const abstract::struct_elt<E>& se) :
super_type(input, se)
{}
@@ -138,25 +141,22 @@
{
mlc::is_true<mlc::type::eq<oln_type_of(I, size),
oln_type_of(E, size)>::ret>::ensure();
- I output(this->input_.size());
- // FIXME: see erosion.hh
- this->input_.resize_border(this->se_.get_delta());
+ I tmp(input.size()); // FIXME: trick
+ output = tmp;
- oln_type_of(I, fwd_piter) p(this->input_.size());
-
+ oln_type_of(I, fwd_piter) p(input.size());
for_all (p)
- output[p] = morpho::max(this->input_, p, this->se_);
- *this->image_ = output;
+ output[p] = morpho::max(input, p, se);
}
};
}
- template<class I, class E>
+ template<typename I, typename E>
impl::dilation_type<I, E>
dilation(const abstract::non_vectorial_image<I>& input,
- const abstract::struct_elt<E>& se)
+ const abstract::struct_elt<E>& se)
{
impl::dilation_type_classic<I, E> tmp(input, se);
tmp.run();
Index: oln/morpho/erosion.hh
===================================================================
--- oln/morpho/erosion.hh (revision 98)
+++ oln/morpho/erosion.hh (working copy)
@@ -31,7 +31,7 @@
# include <oln/basics.hh>
# include <oln/morpho/stat.hh>
// # include <oln/morpho/fast_morpho.hh>
-# include <oln/core/abstract/op.hh>
+# include <oln/core/abstract/image_operator.hh>
# include <mlc/cmp.hh>
namespace oln {
@@ -98,29 +98,30 @@
template <typename I, typename E>
struct set_super_type< morpho::impl::erosion_type<I,E> >
{
- typedef abstract::op<I, morpho::impl::erosion_type<I, E> > ret;
+ typedef abstract::image_unary_operator<I, I, morpho::impl::erosion_type<I,
E> > ret; // FIXME: see below
};
namespace morpho {
namespace impl {
- template <class I, class E>
- struct erosion_type : abstract::op<I, erosion_type<I, E> >
+ template <typename I, typename E>
+ struct erosion_type : abstract::image_unary_operator<I, I, erosion_type<I,
E> >
+ // FIXME: abstract::image_unary_operator<oln_type_of(I, concrete), ...
{
- box<const I> input_;
- const E se_;
+ typedef abstract::image_unary_operator<I, I, erosion_type<I, E> >
super_type;
+ const E se;
erosion_type(const abstract::non_vectorial_image<I>& input,
const abstract::struct_elt<E>& se) :
- input_(input.exact()),
- se_(se.exact())
+ super_type(input),
+ se(se.exact())
{}
};
- template <class I, class E>
- struct erosion_type_classic : erosion_type<I, E>
+ template <typename I, typename E>
+ struct erosion_type_classic : public erosion_type<I, E>
{
typedef erosion_type<I, E> super_type;
@@ -133,26 +134,20 @@
{
mlc::is_true<mlc::type::eq<oln_type_of(I, size),
oln_type_of(E, size)>::ret>::ensure();
- I output(this->input_.size());
- // FIXME: not only resize but also set values in border!
- // FIXME: code commented below cause only valid with bordered_image
+ I tmp(input.size()); // FIXME: trick
+ output = tmp;
- this->input_.resize_border(this->se_.get_delta());
-
- oln_type_of(I, fwd_piter) p(this->input_.size());
-
+ oln_type_of(I, fwd_piter) p(input.size());
for_all (p)
- output[p] = morpho::min(this->input_, p, this->se_);
- // FIXME: remove * below (oln::box)
- *this->image_ = output;
+ output[p] = morpho::min(input, p, se);
}
};
}
- template<class I, class E>
+ template<typename I, typename E>
impl::erosion_type<I, E>
erosion(const abstract::non_vectorial_image<I>& input,
const abstract::struct_elt<E>& se)
@@ -197,7 +192,7 @@
** \image html oln_morpho_fast_erosion.png
** \image latex oln_morpho_fast_erosion.png
*/
-// template<class I, class E>
+// template<typename I, typename E>
// oln_concrete_type(I)
// erosion(const abstract::non_vectorial_image<I>& input,
// const abstract::struct_elt<E>& se)
Index: oln/io/read_image_2d_pnm.hh
===================================================================
--- oln/io/read_image_2d_pnm.hh (revision 98)
+++ oln/io/read_image_2d_pnm.hh (working copy)
@@ -74,8 +74,7 @@
namespace impl {
template <typename I>
- struct read_image_2d_raw :
- public oln::abstract::op<I, read_image_2d_raw<I> >
+ struct read_image_2d_raw : public oln::abstract::op<I,
read_image_2d_raw<I> >
{
typedef oln::abstract::op<I, read_image_2d_raw<I> > super_type;
Index: oln/arith/min.hh
===================================================================
--- oln/arith/min.hh (revision 98)
+++ oln/arith/min.hh (working copy)
@@ -29,6 +29,7 @@
# define OLENA_ARITH_MIN_HH
# include <oln/basics.hh>
+# include <oln/core/abstract/op.hh>
# include <ntg/all.hh>
namespace oln {
@@ -60,7 +61,7 @@
namespace impl {
template <class I>
- struct min_type : abstract::op<I, min_type<I> >
+ struct min_type : public abstract::op<I, min_type<I> >
{
box<const I> input1_;
box<const I> input2_;
@@ -80,7 +81,7 @@
for_all(p)
output[p] = ntg::min(input1_[p].value(), input2_[p].value());
- *this->image_ = output;
+ this->image_ = output;
}
};
Index: oln/arith/max.hh
===================================================================
--- oln/arith/max.hh (revision 98)
+++ oln/arith/max.hh (working copy)
@@ -29,6 +29,7 @@
# define OLENA_ARITH_MAX_HH
# include <oln/basics.hh>
+# include <oln/core/abstract/op.hh>
# include <ntg/all.hh>
namespace oln {
@@ -60,7 +61,7 @@
namespace impl {
template <class I>
- struct max_type : abstract::op<I, max_type<I> >
+ struct max_type : public abstract::op<I, max_type<I> >
{
box<const I> input1_;
box<const I> input2_;
@@ -80,7 +81,7 @@
for_all(p)
output[p] = ntg::max(input1_[p].value(), input2_[p].value());
- *this->image_ = output; // FIXME: remove * when image_ is oln::box
+ this->image_ = output;
}
};