nonconst.hh doesn't exist but was (maybe is) still included.
image2d<bool> + morpho compile but error at execution
: Assertion `this->owns_(p)' failed.
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Algo MorphoMath : and, or, opening, closing, elementary algo.
* oln/accumulator/and.hh: New.
* oln/accumulator/or.hh: New.
* oln/core/internal/max_value.hh,
* oln/core/internal/op_image_plus_nbh.hh,
* oln/morpho/elementary_erosion.hh,
* oln/morpho/dilation.hh: Update.
* oln/morpho/elementary_closing.hh,
* oln/morpho/elementary_opening.hh: New.
* oln/morpho/elementary_dilation.hh: Update.
* oln/morpho/erosion.hh: New.
* oln/morpho/opening.hh: New.
* oln/level/local.hh: .
accumulator/and.hh | 95 ++++++++++++++++++++++++++++++++++++
accumulator/or.hh | 97 +++++++++++++++++++++++++++++++++++++
core/internal/max_value.hh | 4 +
core/internal/op_image_plus_nbh.hh | 1
level/local.hh | 81 +++++++++++++++++++++++++++++-
morpho/dilation.hh | 2
morpho/elementary_closing.hh | 85 ++++++++++++++++++++++++++++++++
morpho/elementary_dilation.hh | 10 +--
morpho/elementary_erosion.hh | 1
morpho/elementary_opening.hh | 85 ++++++++++++++++++++++++++++++++
morpho/erosion.hh | 86 ++++++++++++++++++++++++++++++++
morpho/opening.hh | 87 +++++++++++++++++++++++++++++++++
12 files changed, 623 insertions(+), 11 deletions(-)
Index: oln/accumulator/and.hh
--- oln/accumulator/and.hh (revision 0)
+++ oln/accumulator/and.hh (revision 0)
@@ -0,0 +1,95 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_ACCUMULATOR_AND_HH
+# define OLN_ACCUMULATOR_AND_HH
+
+# include <oln/core/concept/accumulator.hh>
+# include <oln/core/internal/max_value.hh>
+
+
+namespace oln
+{
+
+ namespace accumulator
+ {
+
+ template <typename T>
+ struct and_ : public Accumulator< and_<T> >
+ {
+ typedef T argument;
+ typedef T result;
+
+ and_();
+
+ void init() const;
+ const T& value() const;
+
+ void operator()(const T& val) const;
+
+ private:
+ mutable T val_;
+ };
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename T>
+ and_<T>::and_()
+ {
+ this->init();
+ }
+
+ template <typename T>
+ void
+ and_<T>::init() const
+ {
+ this->val_ = oln_min(T);
+ }
+
+ template <typename T>
+ const T&
+ and_<T>::value() const
+ {
+ return this->val_;
+ }
+
+ template <typename T>
+ void
+ and_<T>::operator()(const T& val) const
+ {
+ if (val < this->val_)
+ this->val_ = val;
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+ } // end of namespace oln::accumulator
+
+} // end of namespace oln
+
+#endif // ! OLN_ACCUMULATOR_AND_HH
Index: oln/accumulator/or.hh
--- oln/accumulator/or.hh (revision 0)
+++ oln/accumulator/or.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_ACCUMULATOR_OR_HH
+# define OLN_ACCUMULATOR_OR_HH
+
+# include <oln/core/concept/accumulator.hh>
+# include <oln/core/internal/max_value.hh>
+
+
+namespace oln
+{
+
+ namespace accumulator
+ {
+
+ template <typename T>
+ struct or_ : public Accumulator< or_<T> >
+ {
+ typedef T argument;
+ typedef T result;
+
+ or_();
+
+ void init() const;
+ const T& value() const;
+
+ void operator()(const T& val) const;
+
+ mutable T ultimate;
+ private:
+ mutable T val_;
+ };
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename T>
+ or_<T>::or_()
+ {
+ this->init();
+ }
+
+ template <typename T>
+ void
+ or_<T>::init() const
+ {
+ this->val_ = oln_min(T);
+ this->ultimate = oln_max(T);
+ }
+
+ template <typename T>
+ const T&
+ or_<T>::value() const
+ {
+ return this->val_;
+ }
+
+ template <typename T>
+ void
+ or_<T>::operator()(const T& val) const
+ {
+ if (val < this->val_)
+ this->val_ = val;
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+ } // end of namespace oln::accumulator
+
+} // end of namespace oln
+
+#endif // ! OLN_ACCUMULATOR_OR_HH
Index: oln/core/internal/max_value.hh
--- oln/core/internal/max_value.hh (revision 892)
+++ oln/core/internal/max_value.hh (working copy)
@@ -30,6 +30,8 @@
# include <limits>
-# define oln_max(T) std::numeric_limits< T >::max()
+#define oln_max(T) std::numeric_limits< T >::max() // FIXME std lib
+#define oln_min(T) std::numeric_limits< T >::min() // FIXME std lib
#endif // ! OLN_CORE_INTERNAL_MAX_VALUE_HH
+
Index: oln/core/internal/op_image_plus_nbh.hh
--- oln/core/internal/op_image_plus_nbh.hh (revision 892)
+++ oln/core/internal/op_image_plus_nbh.hh (working copy)
@@ -28,7 +28,6 @@
#ifndef OLN_CORE_INTERNAL_OP_IMAGE_PLUS_NBH_HH
# define OLN_CORE_INTERNAL_OP_IMAGE_PLUS_NBH_HH
-# include <mlc/unconst.hh>
# include <oln/core/concept/neighborhood.hh>
# include <oln/core/gen/op.hh>
# include <oln/core/gen/dpoints_piter.hh>
Index: oln/morpho/elementary_erosion.hh
--- oln/morpho/elementary_erosion.hh (revision 892)
+++ oln/morpho/elementary_erosion.hh (working copy)
@@ -32,7 +32,6 @@
#include <oln/border/fill.hh>
#include <oln/accumulator/min.hh>
-
namespace oln
{
Index: oln/morpho/dilation.hh
--- oln/morpho/dilation.hh (revision 892)
+++ oln/morpho/dilation.hh (working copy)
@@ -32,6 +32,8 @@
#include <oln/border/fill.hh>
#include <oln/accumulator/max.hh>
+namespace oln
+{
namespace morpho
{
Index: oln/morpho/elementary_closing.hh
--- oln/morpho/elementary_closing.hh (revision 0)
+++ oln/morpho/elementary_closing.hh (revision 0)
@@ -0,0 +1,85 @@
+// 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_CLOSING_HH
+# define OLN_MORPHO_ELEMENTARY_CLOSING_HH
+
+#include <oln/level/apply_local.hh>
+#include <oln/border/fill.hh>
+#include <oln/morpho/elementary_erosion.hh>
+#include <oln/morpho/elementary_dilation.hh>
+
+namespace oln
+{
+
+ namespace morpho
+ {
+
+ // Fwd decl.
+
+ template <typename I, typename W>
+ oln_plain(I)
+ elementary_closing(const Image<I>& input, const Window<W>& win);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ // Generic version.
+
+ template <typename I, typename W>
+ oln_plain(I)
+ elementary_closing_(const Image<I>& input,
+ const Window<W>& win)
+ {
+ return elementary_erosion(elementary_dilation(input, win), win); // FIXME : memory
+ }
+
+ // FIXME: Add a fast version.
+
+ } // end of namespace oln::morpho::impl
+
+
+ // Facade.
+
+ template <typename I, typename W>
+ oln_plain(I)
+ elementary_closing(const Image<I>& input, const Window<W>& win)
+ {
+ return impl::elementary_closing_(exact(input), exact(win));
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+
+#endif // ! OLN_MORPHO_ELEMENTARY_CLOSING_HH
Index: oln/morpho/elementary_opening.hh
--- oln/morpho/elementary_opening.hh (revision 0)
+++ oln/morpho/elementary_opening.hh (revision 0)
@@ -0,0 +1,85 @@
+// 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_OPENING_HH
+# define OLN_MORPHO_ELEMENTARY_OPENING_HH
+
+#include <oln/level/apply_local.hh>
+#include <oln/border/fill.hh>
+#include <oln/morpho/elementary_erosion.hh>
+#include <oln/morpho/elementary_dilation.hh>
+
+namespace oln
+{
+
+ namespace morpho
+ {
+
+ // Fwd decl.
+
+ template <typename I, typename W>
+ oln_plain(I)
+ elementary_opening(const Image<I>& input, const Window<W>& win);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ // Generic version.
+
+ template <typename I, typename W>
+ oln_plain(I)
+ elementary_opening_(const Image<I>& input,
+ const Window<W>& win)
+ {
+ return elementary_dilation(elementary_erosion(input, win), win); // FIXME : memory
+ }
+
+ // FIXME: Add a fast version.
+
+ } // end of namespace oln::morpho::impl
+
+
+ // Facade.
+
+ template <typename I, typename W>
+ oln_plain(I)
+ elementary_opening(const Image<I>& input, const Window<W>& win)
+ {
+ return impl::elementary_opening_(exact(input), exact(win));
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+
+#endif // ! OLN_MORPHO_ELEMENTARY_OPENING_HH
Index: oln/morpho/elementary_dilation.hh
--- oln/morpho/elementary_dilation.hh (revision 892)
+++ oln/morpho/elementary_dilation.hh (working copy)
@@ -31,7 +31,7 @@
#include <oln/level/apply_local.hh>
#include <oln/border/fill.hh>
#include <oln/accumulator/max.hh>
-
+#include <oln/accumulator/or.hh>
namespace oln
{
@@ -66,11 +66,11 @@
template <typename I>
oln_plain(I)
elementary_dilation_on_set_(const Image<I>&,
- const I&)
+ const I& input)
{
- oln_plain(I) tmp;
- std::cerr << "morpho::impl::elementary_dilation_on_set_ is not yet
impled!" << std::endl;
- return tmp;
+ border::fill(input, oln_min(oln_value(I)));
+ accumulator::or_<oln_value(I)> accu_or;
+ return level::apply_local(accu_or, input);
}
// FIXME: Add a fast version.
Index: oln/morpho/erosion.hh
--- oln/morpho/erosion.hh (revision 0)
+++ oln/morpho/erosion.hh (revision 0)
@@ -0,0 +1,86 @@
+// 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_EROSION_HH
+# define OLN_MORPHO_EROSION_HH
+
+#include <oln/level/apply_local.hh>
+#include <oln/border/fill.hh>
+#include <oln/accumulator/min.hh>
+
+namespace oln
+{
+
+ namespace morpho
+ {
+
+ // Fwd decl.
+
+ template <typename I, typename W>
+ oln_plain(I)
+ erosion(const Image<I>& input, const Window<W>& win);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ // Generic version.
+
+ template <typename I, typename W>
+ oln_plain(I)
+ elementary_erosion_(const Image<I>& input,
+ const Window<W>& win)
+ {
+ border::fill(input, oln_min(oln_value(I)));
+ accumulator::min_<oln_value(I)> min;
+ return level::apply_local(min, input, win);
+ }
+
+ // FIXME: Add a fast version.
+
+ } // end of namespace oln::morpho::impl
+
+
+ // Facade.
+
+ template <typename I, typename W>
+ oln_plain(I)
+ erosion(const Image<I>& input, const Window<W>& win)
+ {
+ return impl::erosion_(exact(input), exact(win));
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+
+#endif // ! OLN_MORPHO_EROSION_HH
Index: oln/morpho/opening.hh
--- oln/morpho/opening.hh (revision 0)
+++ oln/morpho/opening.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_OPENING_HH
+# define OLN_MORPHO_OPENING_HH
+
+#include <oln/level/apply_local.hh>
+#include <oln/border/fill.hh>
+#include <oln/morpho/elementary_erosion.hh>
+#include <oln/morpho/elementary_dilation.hh>
+
+namespace oln
+{
+
+ namespace morpho
+ {
+
+ // Fwd decl.
+
+ template <typename I, typename W>
+ oln_plain(I)
+ opening(const Image<I>& input, const Window<W>& win);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ // Generic version.
+
+ template <typename I, typename W>
+ oln_plain(I)
+ opening_(const Image<I>& input,
+ const Window<W>& win)
+ {
+ border::fill(input, oln_min(oln_value(I)));
+ accumulator::max_<oln_value(I)> max;
+ return level::apply_local(max, input, win);
+ }
+
+ // FIXME: Add a fast version.
+
+ } // end of namespace oln::morpho::impl
+
+
+ // Facade.
+
+ template <typename I, typename W>
+ oln_plain(I)
+ opening(const Image<I>& input, const Window<W>& win)
+ {
+ return impl::opening_(exact(input), exact(win));
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+ } // end of namespace oln::morpho
+
+} // end of namespace oln
+
+
+#endif // ! OLN_MORPHO_DILATION_HH
Index: oln/level/local.hh
--- oln/level/local.hh (revision 892)
+++ oln/level/local.hh (working copy)
@@ -31,7 +31,8 @@
# include <oln/core/concept/image.hh>
# include <oln/core/concept/window.hh>
# include <oln/core/concept/accumulator.hh>
-
+# include <oln/accumulator/or.hh>
+# include <oln/accumulator/and.hh>
namespace oln
{
@@ -67,7 +68,8 @@
const oln_point(I)& p)
{
f.init_with(input(p));
- oln_niter(I) n(p, input.nbhood()); // FIXME: 2nd arg should be 'input'!
+ oln_niter(I) n(p, input.nbhood()); // FIXME: 2nd arg should be
+ // 'input'!
for_all(n)
f(input(n));
return f.value();
@@ -76,7 +78,6 @@
// FIXME: Generic version with nbh given as argument?
-
// Generic version with window.
template <typename A, typename I, typename W>
@@ -93,6 +94,80 @@
return f.value();
}
+
+ // Optimised version for OR operator with neighborhood.
+
+ template <typename A, typename I>
+ typename A::result
+ local_(const ::oln::accumulator::or_< oln_value(I) > f,
+ const Binary_Image<I>& input,
+ const oln_point(I)& p)
+ {
+ f.init_with(input(p));
+ oln_niter(I) n(p, input.nbhood()); // FIXME: 2nd arg should be
+ // 'input'!
+ for_all(n)
+ if (f(input(n)) == f.ultimate)
+ return (f.ultimate);
+ return f.value();
+ }
+
+
+ // Optimised version for OR operator with window.
+
+ template <typename A, typename I, typename W>
+ typename A::result
+ local_(const ::oln::accumulator::or_< oln_value(I) > f,
+ const Binary_Image<I>& input,
+ const oln_point(I)& p,
+ const Window<W>& win)
+ {
+ f.init();
+ oln_qiter(W) q(p, win);
+ for_all(q)
+ if (f(input(q)) == f.ultimate)
+ return (f.ultimate);
+ return f.value();
+ }
+
+
+ // FIXME : same function for OR.
+
+ // Optimised version for AND operator with neighborhood.
+
+ template <typename A, typename I>
+ typename A::result
+ local_(const ::oln::accumulator::and_< oln_value(I) > f,
+ const Binary_Image<I>& input,
+ const oln_point(I)& p)
+ {
+ f.init_with(input(p));
+ oln_niter(I) n(p, input.nbhood()); // FIXME: 2nd arg should be
+ // 'input'!
+ for_all(n)
+ if (f(input(n)) == f.ultimate)
+ return (f.ultimate);
+ return f.value();
+ }
+
+
+ // Optimised version for AND operator with window.
+
+ template <typename A, typename I, typename W>
+ typename A::result
+ local_(const ::oln::accumulator::and_< oln_value(I) > f,
+ const Image<I>& input,
+ const oln_point(I)& p,
+ const Window<W>& win)
+ {
+ f.init();
+ oln_qiter(W) q(p, win);
+ for_all(q)
+ if (f(input(q)) == f.ultimate)
+ return (f.ultimate);
+ return f.value();
+ }
+
} // end of namespace oln::level::impl