https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix minor bugs.
* doc/examples/tuto_bis.cc
(fill, gradient, dilation): Remove dedicated code; instead use
library routines. Their proper arg is nbh.win().
(ima): Ensure there is no outer border.
(include): Update.
* mln/core/image/extended.hh: Upgrade doc style.
* mln/core/image/extension_ima.hh: Likewise.
(ext_io): Fix wrong definition.
(todo): New.
* mln/core/routine/primary.hh: Upgrade doc style.
* mln/math/diff_abs.hh: Fix doc.
* mln/accu/transform.hh (transform): Fix missing test.
* mln/accu/transform_stop.hh: Likewise.
* mln/accu/volume.hh: Use diff_abs instead of abs.
Remember that (1u - 2u) is not equal to -1 in C.
* mln/border/resize.hh: Revamp.
(todo): Done.
(todo): New.
* mln/border/adjust.hh: Remove erroneous post-condition.
* mln/morpho/tree/utils.hh: Fix guard.
* mln/canvas/labeling.hh: Fix warning.
* mln/extension/fill.hh: Upgrade doc style.
doc/examples/tuto_bis.cc | 100 +++-------------------------------------
mln/accu/transform.hh | 2
mln/accu/transform_stop.hh | 2
mln/accu/volume.hh | 7 +-
mln/border/adjust.hh | 3 -
mln/border/resize.hh | 87 ++++++++++++----------------------
mln/canvas/labeling.hh | 2
mln/core/image/extended.hh | 18 +++----
mln/core/image/extension_ima.hh | 22 ++++----
mln/core/routine/primary.hh | 14 ++---
mln/extension/fill.hh | 15 ++----
mln/math/diff_abs.hh | 2
mln/morpho/tree/utils.hh | 2
13 files changed, 84 insertions(+), 192 deletions(-)
Index: doc/examples/tuto_bis.cc
--- doc/examples/tuto_bis.cc (revision 2969)
+++ doc/examples/tuto_bis.cc (working copy)
@@ -2,6 +2,7 @@
# include <mln/core/image/image2d.hh>
# include <mln/core/image/image_if.hh>
+# include <mln/core/image/sub_image.hh>
# include <mln/core/image/extended.hh>
# include <mln/core/routine/extend.hh>
@@ -23,6 +24,8 @@
# include <mln/extension/fill.hh>
# include <mln/morpho/meyer_wst.hh>
+# include <mln/morpho/gradient.hh>
+# include <mln/morpho/dilation.hh>
# include <mln/debug/println.hh>
@@ -31,29 +34,6 @@
namespace mln
{
- namespace border
- {
-
- template <typename I>
- void
- fill(I& ima, const mln_value(I)& v)
- {
- const int nrows = ima.nrows();
- const int ncols = ima.ncols();
- for (int r = -1; r <= nrows; ++r)
- {
- ima.at(r, -1) = v;
- ima.at(r, ncols) = v;
- }
- for (int c = -1; c <= ncols; ++c)
- {
- ima.at(-1, c) = v;
- ima.at(nrows, c) = v;
- }
- }
-
- } // mln::border
-
namespace accu
{
@@ -86,54 +66,6 @@
} // mln::accu
- namespace morpho
- {
-
- template <typename I, typename N>
- mln_concrete(I)
- gradient(const I& input, const N& nbh)
- {
- mln_concrete(I) output;
- initialize(output, input);
- accu::min_max<mln_value(I)> mm;
-
- mln_piter(I) p(input.domain());
- mln_niter(N) n(nbh, p);
- for_all(p)
- {
- mm.init();
- for_all(n) if (input.has(n))
- mm.take(input(n));
- output(p) = mm.second() - mm.first();
- }
- return output;
- }
-
- template <typename I, typename N>
- mln_concrete(I)
- dilation(const I& input, const N& nbh)
- {
- typedef mln_value(I) V;
- // FIXME: extension::fill(input, mln_min(V));
-
- mln_concrete(I) output;
- initialize(output, input);
- accu::max<V> m;
-
- mln_piter(I) p(input.domain());
- mln_niter(N) n(nbh, p);
- for_all(p)
- {
- m.init();
- for_all(n) if (input.has(n))
- m.take(input(n));
- output(p) = m;
- }
- return output;
- }
-
- } // mln::morpho
-
} // mln
@@ -208,19 +140,8 @@
-// {
-// p_centered<e2e_t::window> wc(e2e.to_window(), literal::origin);
-// std::cout << wc << std::endl;
-
-// p_set<point2d> s;
-// s += wc;
-// std::cout << s << std::endl;
-// }
-
-
- border::thickness = 0;
-
- image2d<int> ima(3, 5);
+ image2d<unsigned> ima_(3, 5);
+ mln_VAR(ima, ima_ | ima_.domain());
mln_VAR(cell, ima | is_cell);
level::fill(cell, fun::p2v::iota());
@@ -229,11 +150,9 @@
//
// 4 5 6
+ mln_VAR(edge, extend((ima | is_edge).rw(), ima));
-
- mln_VAR(edge, extend((ima | is_edge).rw(),
- pw::value(ima)));
- level::paste(morpho::gradient(edge, e2c), edge);
+ level::paste(morpho::gradient(edge, e2c.win()), edge);
// ^^^
// edge -> neighboring cells
debug::println(edge);
@@ -241,7 +160,6 @@
// 3 3 3
// 1 1
-
image2d<unsigned> label(ima.bbox(), 0);
level::fill(label, 9);
debug::println(label);
@@ -313,7 +231,7 @@
level::paste(morpho::dilation(extend(lab, label),
- c4()),
+ c4().win()),
label);
debug::println(label);
@@ -351,6 +269,6 @@
// //
// // 5 5 5
-
// DONE!
+
}
Index: mln/core/image/extended.hh
--- mln/core/image/extended.hh (revision 2969)
+++ mln/core/image/extended.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,15 +28,13 @@
#ifndef MLN_CORE_IMAGE_EXTENDED_HH
# define MLN_CORE_IMAGE_EXTENDED_HH
-/*!
- * \file mln/core/image/extended.hh
- *
- * \brief Definition of morpher that makes an image become restricted
- * given by a point set.
- *
- * \todo Add a special case for "ima | box"; think about some other
- * special cases...
- */
+/// \file mln/core/image/extended.hh
+///
+/// Definition of morpher that makes an image become restricted
+/// given by a point set.
+///
+/// \todo Add a special case for "ima | box"; think about some other
+/// special cases...
# include <mln/core/internal/image_domain_morpher.hh>
# include <mln/core/site_set/box.hh>
Index: mln/core/image/extension_ima.hh
--- mln/core/image/extension_ima.hh (revision 2969)
+++ mln/core/image/extension_ima.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,15 +28,15 @@
#ifndef MLN_CORE_IMAGE_EXTENSION_IMA_HH
# define MLN_CORE_IMAGE_EXTENSION_IMA_HH
-/*!
- * \file mln/core/image/extension_ima.hh
- *
- * \brief Definition of a morpher that extends the domain of an image
- * with a function.
- *
- * \todo Use the 'instant' mechanism.
- * \todo Use an envelop as lvalue to test extension writing.
- */
+/// \file mln/core/image/extension_ima.hh
+///
+/// Definition of a morpher that extends the domain of an image
+/// with a function.
+///
+/// \todo Use an envelop as lvalue to test extension writing.
+///
+/// \todo Handle the couple of cases: either J is value_io::read_write
+/// or value_io::read_only; then ext_io can be read_write...
# include <mln/core/internal/image_identity.hh>
# include <mln/level/fill_with_value.hh>
@@ -80,7 +80,7 @@
// extended domain
typedef trait::image::ext_domain::extendable ext_domain;
typedef trait::image::ext_value::multiple ext_value;
- typedef mln_trait_image_value_io(J) ext_io;
+ typedef trait::image::ext_io::read_only ext_io; // FIXME: Too restrictive?
};
template <typename I, typename J, typename V>
Index: mln/core/routine/primary.hh
--- mln/core/routine/primary.hh (revision 2969)
+++ mln/core/routine/primary.hh (working copy)
@@ -28,13 +28,12 @@
#ifndef MLN_CORE_ROUTINE_PRIMARY_HH
# define MLN_CORE_ROUTINE_PRIMARY_HH
-/*! \file mln/core/routine/primary.hh
- *
- * \brief FIXME
- *
- * \todo We also need to get the extension image to handle border
- * routines.
- */
+/// \file mln/core/routine/primary.hh
+///
+/// Get the primary image behind any image.
+///
+/// \todo We also need to get the extension image to handle border
+/// routines.
# include <mln/core/concept/image.hh>
@@ -55,6 +54,7 @@
primary(const Image<I>& input);
+
# ifndef MLN_INCLUDE_ONLY
Index: mln/math/diff_abs.hh
--- mln/math/diff_abs.hh (revision 2969)
+++ mln/math/diff_abs.hh (working copy)
@@ -31,7 +31,7 @@
/// \file mln/math/diff_abs.hh
///
-/// \brief Define diff_abs routine.
+/// Define diff_abs routine.
namespace mln
Index: mln/accu/transform.hh
--- mln/accu/transform.hh (revision 2969)
+++ mln/accu/transform.hh (working copy)
@@ -95,7 +95,7 @@
for_all(p)
{
a.init();
- for_all(q)
+ for_all(q) if (input.has(q))
a.take(input(q));
output(p) = a.to_result();
}
Index: mln/accu/transform_stop.hh
--- mln/accu/transform_stop.hh (revision 2969)
+++ mln/accu/transform_stop.hh (working copy)
@@ -91,7 +91,7 @@
for_all(p)
{
a.init();
- for_all(q)
+ for_all(q) if (input.has(q))
{
a.take(input(q));
if (a.can_stop())
Index: mln/accu/volume.hh
--- mln/accu/volume.hh (revision 2969)
+++ mln/accu/volume.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -43,7 +44,7 @@
# include <mln/accu/internal/base.hh>
# include <mln/core/concept/meta_accumulator.hh>
-# include <mln/math/abs.hh>
+# include <mln/math/diff_abs.hh>
# include <mln/util/pix.hh>
# include <mln/literal/zero.hh>
@@ -171,7 +172,7 @@
the former. */
volume_ +=
other.volume_ +
- other.area__ * math::abs(other.ref_level__ - ref_level__);
+ other.area__ * math::diff_abs(other.ref_level__, ref_level__);
// Member ref_level__ is not touched.
}
Index: mln/border/resize.hh
--- mln/border/resize.hh (revision 2969)
+++ mln/border/resize.hh (working copy)
@@ -29,17 +29,18 @@
#ifndef MLN_BORDER_RESIZE_HH
# define MLN_BORDER_RESIZE_HH
-/*! \file mln/border/resize.hh
- *
- * \brief Define a function that resizes the virtual border of an
- * image.
- *
- * \todo Test with a primary image with no notion of border; I guess
- * it does not work.
- */
+/// \file mln/border/resize.hh
+///
+/// Define a function that resizes the virtual border of an
+/// image.
+///
+/// \todo This code is not complete: an image can be composed of
+/// several images whose multiple borders have to be resized! For
+/// instance an image extended by an image, or a stack of images.
# include <mln/core/concept/image.hh>
# include <mln/core/routine/clone.hh>
+# include <mln/core/routine/primary.hh>
# include <mln/border/get.hh>
# include <mln/level/fill.hh>
@@ -71,94 +72,66 @@
namespace impl
{
- // Effective resizing.
-
template <typename I>
inline
- void resize_(trait::image::category::morpher,
- const I& ima, unsigned thickness)
+ void resize(I& ima, unsigned thickness)
{
- return resize(*ima.delegatee_(), thickness);
- }
-
- template <typename I>
- inline
- void resize_(trait::image::category::primary,
- const I& ima_, unsigned thickness)
- {
- I& ima = const_cast<I&>(ima_);
+ if (border::get(ima) == thickness)
+ return; // No-op.
mln_concrete(I) memo = clone(ima);
ima.resize_(thickness);
level::fill(ima, memo);
+
+ mln_postcondition(border::get(ima) == thickness);
}
-// ext_domain: /any/
-// |
-// + -- none
-// |
-// + -- /some/
-// |
-// + -- fixed
-// | |
-// | + -- infinite
-// |
-// + -- extendable
+ } // end of namespace mln::border::impl
- template <typename I>
- inline
- void resize_(trait::image::ext_domain::none,
- const I&, unsigned)
+
+ namespace internal
{
- // No-op.
- }
template <typename I>
inline
- void resize_(trait::image::ext_domain::fixed,
- const I&, unsigned)
+ void resize_dispatch(trait::image::ext_domain::any,
+ const Image<I>& ima, unsigned thickness)
{
// No-op.
}
template <typename I>
inline
- void resize_(trait::image::ext_domain::extendable,
- const I& ima, unsigned thickness)
+ void resize_dispatch(trait::image::ext_domain::extendable,
+ const Image<I>& ima, unsigned thickness)
{
- if (border::get(ima) == thickness)
- return; // No-op.
- resize_(mln_trait_image_category(I)(),
- ima, thickness);
- mln_postcondition(border::get(ima) == thickness);
+ // Effective resizing.
+ impl::resize(const_cast<I&>(exact(ima)), thickness);
}
-
- // Selector.
-
template <typename I>
inline
- void resize_(const I& ima, unsigned thickness)
+ void resize_dispatch(const Image<I>& ima, unsigned thickness)
{
- resize_(mln_trait_image_ext_domain(I)(),
+ resize_dispatch(mln_trait_image_ext_domain(I)(),
ima, thickness);
}
- } // end of namespace mln::border::resize
+ } // end of namespace mln::border::internal
/// Facade.
template <typename I>
inline
- void resize(const Image<I>& ima_, unsigned thickness)
+ void resize(const Image<I>& ima, unsigned thickness)
{
trace::entering("border::resize");
- const I& ima = exact(ima_);
- mln_precondition(ima.has_data());
+ mln_precondition(exact(ima).has_data());
- impl::resize_(ima, thickness);
+ // Try to resize the primary image behind ima.
+ internal::resize_dispatch(primary(ima), thickness);
trace::exiting("border::resize");
}
Index: mln/border/adjust.hh
--- mln/border/adjust.hh (revision 2969)
+++ mln/border/adjust.hh (working copy)
@@ -71,7 +71,8 @@
if (border::get(ima) < min_thickness)
border::resize(ima, min_thickness);
- mln_postcondition(border::get(ima) >= min_thickness);
+ // We cannot run here a postcondition since we do not know if
+ // ima (or an underlying image) has a border or not.
trace::exiting("border::adjust");
}
Index: mln/morpho/tree/utils.hh
--- mln/morpho/tree/utils.hh (revision 2969)
+++ mln/morpho/tree/utils.hh (working copy)
@@ -140,4 +140,4 @@
} // end of namespace mln
-#endif // ! MLN_MORPHO_TREE_MAX_HH
+#endif // ! MLN_MORPHO_TREE_UTILS_HH
Index: mln/canvas/labeling.hh
--- mln/canvas/labeling.hh (revision 2969)
+++ mln/canvas/labeling.hh (working copy)
@@ -74,6 +74,8 @@
(void) input;
(void) nbh;
+ (void) f;
+ (void) nlabels;
}
} // end of namespace mln::canvas::internal
Index: mln/extension/fill.hh
--- mln/extension/fill.hh (revision 2969)
+++ mln/extension/fill.hh (working copy)
@@ -1,4 +1,5 @@
// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,14 +29,12 @@
#ifndef MLN_CORE_EXTENSION_FILL_HH
# define MLN_CORE_EXTENSION_FILL_HH
-/*! \file mln/extension/fill.hh
- *
- * \brief Define function that fills domain extension.
- *
- *
- * \todo Test the compatibility between val and mln_value(I) because,
- * while unmorphing, this type can change...
- */
+/// \file mln/extension/fill.hh
+///
+/// Define function that fills domain extension.
+///
+/// \todo Test the compatibility between val and mln_value(I) because,
+/// while unmorphing, this type can change...
# include <mln/core/concept/image.hh>
# include <mln/trait/image/props.hh>