https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Add volume closing and opening.
* mln/accu/volume.hh: New.
* mln/morpho/closing_volume.hh,
* mln/morpho/opening_volume.hh:
New.
* mln/morpho/closing_attribute.hh
(mln::morho::impl::closing_attribute_tinit): Add a FIXME.
* mln/morpho/opening_attribute.hh: Aesthetic changes.
* tests/morpho/closing_volume.cc,
* tests/morpho/opening_volume.cc:
New tests.
* tests/morpho/Makefile.am (check_PROGRAMS): Add closing_volume.
(closing_volume_SOURCES): New.
mln/accu/volume.hh | 91 ++++++++++++++++++++++++----------------
mln/morpho/closing_attribute.hh | 11 +++-
mln/morpho/closing_volume.hh | 22 ++++-----
mln/morpho/opening_attribute.hh | 6 --
mln/morpho/opening_volume.hh | 22 ++++-----
tests/morpho/Makefile.am | 5 ++
tests/morpho/closing_volume.cc | 12 +----
tests/morpho/opening_volume.cc | 12 +----
8 files changed, 98 insertions(+), 83 deletions(-)
Index: mln/accu/volume.hh
--- mln/accu/volume.hh (revision 1988)
+++ mln/accu/volume.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// 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
@@ -25,17 +25,19 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_ACCU_COUNT_HH
-# define MLN_ACCU_COUNT_HH
+#ifndef MLN_ACCU_VOLUME_HH
+# define MLN_ACCU_VOLUME_HH
-/*! \file mln/accu/count.hh
- *
- * \brief Define an accumulator that counts.
- */
+/** \file mln/accu/volume.hh
+ \brief Define an accumulator that computes a volume.
+
+ \see mln::morpho::closing_volume
+ \see mln::morpho::opening_volume */
# include <mln/accu/internal/base.hh>
# include <mln/core/concept/meta_accumulator.hh>
+# include <mln/literal/zero.hh>
namespace mln
{
@@ -44,42 +46,45 @@
{
- /*!
- * \brief Generic counter accumulator class.
- *
- * The parameter \a T is the type to be count.
- */
+ /* FIXME: We should probably ``inline'' the parameter T of the
+ sole use of accu::volume_ (in volume closing and opening, where
+ T = util::pix<I>), since volume is not as generic as
+ accu::count_, for instance. Hence, we would get rid of the
+ FIXME of this file on the constraints on T. */
+
+ /// \brief Generic volume accumulator class.
+ /// The parameter \p T is the type of value whose volume is computed.
template <typename T>
- struct count_ : public mln::accu::internal::base_< std::size_t , count_<T>
>
+ struct volume_
+ : public mln::accu::internal::base_< std::size_t , volume_<T> >
{
typedef T argument;
typedef std::size_t result; // FIXME: Up in Accumulator.
- count_();
+ volume_();
void init();
- // FIXME : should we add a take() without argument?
void take(const argument&);
- void take(const count_<T>& other);
+ void take(const volume_<T>& other);
std::size_t to_result() const;
void set_value(std::size_t c);
protected:
-
- std::size_t count__;
+ // FIXME: This attributes expects a typedef `value' from T.
+ typename argument::value height__;
+ std::size_t area__;
+ std::size_t volume__;
};
- /*!
- * \brief Meta accumulator for count.
- */
- struct count : public Meta_Accumulator< count >
+ /// \brief Meta accumulator for volume.
+ struct volume : public Meta_Accumulator< volume >
{
template <typename T>
struct with
{
- typedef count_<T> ret;
+ typedef volume_<T> ret;
};
};
@@ -88,7 +93,7 @@
template <typename T>
inline
- count_<T>::count_()
+ volume_<T>::volume_()
{
init();
}
@@ -96,41 +101,57 @@
template <typename T>
inline
void
- count_<T>::init()
+ volume_<T>::init()
{
- count__ = 0;
+ height__ = literal::zero;
+ volume__ = 0;
+ volume__ = 0;
}
template <typename T>
inline
void
- count_<T>::take(const argument&)
+ volume_<T>::take(const argument& t)
{
- ++count__;
+ /* FIXME: This accumulator will only work with types T providing
+ a method v() (e.g., a util::pix<I>). */
+ height__ = t.v();
+ ++area__;
+ ++volume__;
}
template <typename T>
inline
void
- count_<T>::take(const count_<T>& other)
+ volume_<T>::take(const volume_<T>& other)
{
- count__ += other.count__;
+ // Member height__ is not touched.
+
+ /* FIXME: This accumulator will only work with types T providing
+ a method v() (e.g., a util::pix<I>). */
+ area__ += other.area__;
+ /* FIXME: Is it `t.area__' or `area__' ? Th�o said it was
+ the latter, but both the ISMM 2005 paper and Olena 0.11 use
+ the former. */
+ volume__ +=
+ other.volume__ + other.area__ * math::abs(other.height__ - height__);
}
template <typename T>
inline
std::size_t
- count_<T>::to_result() const
+ volume_<T>::to_result() const
{
- return count__;
+ return volume__;
}
template <typename T>
inline
void
- count_<T>::set_value(std::size_t c)
+ volume_<T>::set_value(std::size_t c)
{
- count__ = c;
+ volume__ = c;
+ // FIXME: What about area__ and height__ ?
}
# endif // ! MLN_INCLUDE_ONLY
@@ -140,4 +161,4 @@
} // end of namespace mln
-#endif // ! MLN_ACCU_COUNT_HH
+#endif // ! MLN_ACCU_VOLUME_HH
Index: mln/morpho/closing_volume.hh
--- mln/morpho/closing_volume.hh (revision 1987)
+++ mln/morpho/closing_volume.hh (working copy)
@@ -25,16 +25,14 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_MORPHO_CLOSING_AREA_HH
-# define MLN_MORPHO_CLOSING_AREA_HH
+#ifndef MLN_MORPHO_CLOSING_VOLUME_HH
+# define MLN_MORPHO_CLOSING_VOLUME_HH
-/*! \file mln/morpho/closing_area.hh
- *
- * \brief Morphological area closing.
- */
+/// \file mln/morpho/closing_volume.hh
+/// \brief Morphological volume closing.
# include <mln/morpho/closing_attribute.hh>
-# include <mln/accu/count.hh>
+# include <mln/accu/volume.hh>
namespace mln
@@ -43,9 +41,9 @@
namespace morpho
{
- /// Morphological area closing.
+ /// Morphological volume closing.
template <typename I, typename N, typename O>
- void closing_area(const Image<I>& input, const Neighborhood<N>&
nbh,
+ void closing_volume(const Image<I>& input, const Neighborhood<N>&
nbh,
std::size_t lambda, Image<O>& output);
@@ -53,13 +51,13 @@
template <typename I, typename N, typename O>
inline
- void closing_area(const Image<I>& input, const Neighborhood<N>&
nbh,
+ void closing_volume(const Image<I>& input, const Neighborhood<N>&
nbh,
std::size_t lambda, Image<O>& output)
{
mln_precondition(exact(output).domain() == exact(input).domain());
typedef util::pix<I> pix_t;
// FIXME: Change sig of closing_attribute!
- closing_attribute< accu::count_<pix_t> >(input, nbh, lambda, output);
+ closing_attribute< accu::volume_<pix_t> >(input, nbh, lambda, output);
}
# endif // ! MLN_INCLUDE_ONLY
@@ -69,4 +67,4 @@
} // end of namespace mln
-#endif // ! MLN_MORPHO_CLOSING_AREA_HH
+#endif // ! MLN_MORPHO_CLOSING_VOLUME_HH
Index: mln/morpho/opening_volume.hh
--- mln/morpho/opening_volume.hh (revision 1988)
+++ mln/morpho/opening_volume.hh (working copy)
@@ -25,16 +25,14 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_MORPHO_OPENING_AREA_HH
-# define MLN_MORPHO_OPENING_AREA_HH
+#ifndef MLN_MORPHO_OPENING_VOLUME_HH
+# define MLN_MORPHO_OPENING_VOLUME_HH
-/*! \file mln/morpho/opening_area.hh
- *
- * \brief Morphological area opening.
- */
+/// \file mln/morpho/opening_volume.hh
+/// \brief Morphological volume opening.
# include <mln/morpho/opening_attribute.hh>
-# include <mln/accu/count.hh>
+# include <mln/accu/volume.hh>
namespace mln
@@ -43,9 +41,9 @@
namespace morpho
{
- /// Morphological area opening.
+ /// Morphological volume opening.
template <typename I, typename N, typename O>
- void opening_area(const Image<I>& input, const Neighborhood<N>&
nbh,
+ void opening_volume(const Image<I>& input, const Neighborhood<N>&
nbh,
std::size_t lambda, Image<O>& output);
@@ -53,13 +51,13 @@
template <typename I, typename N, typename O>
inline
- void opening_area(const Image<I>& input, const Neighborhood<N>&
nbh,
+ void opening_volume(const Image<I>& input, const Neighborhood<N>&
nbh,
std::size_t lambda, Image<O>& output)
{
mln_precondition(exact(output).domain() == exact(input).domain());
typedef util::pix<I> pix_t;
// FIXME: Change sig of opening_attribute!
- opening_attribute< accu::count_<pix_t> >(input, nbh, lambda, output);
+ opening_attribute< accu::volume_<pix_t> >(input, nbh, lambda, output);
}
# endif // ! MLN_INCLUDE_ONLY
@@ -69,4 +67,4 @@
} // end of namespace mln
-#endif // ! MLN_MORPHO_OPENING_AREA_HH
+#endif // ! MLN_MORPHO_OPENING_VOLUME_HH
Index: mln/morpho/closing_attribute.hh
--- mln/morpho/closing_attribute.hh (revision 1988)
+++ mln/morpho/closing_attribute.hh (working copy)
@@ -28,10 +28,8 @@
#ifndef MLN_MORPHO_CLOSING_ATTRIBUTE_HH
# define MLN_MORPHO_CLOSING_ATTRIBUTE_HH
-/*! \file mln/morpho/closing_attribute.hh
- *
- * \brief Morphological attribute closing.
- */
+/// \file mln/morpho/closing_attribute.hh
+/// \brief Morphological attribute closing.
# include <mln/morpho/includes.hh>
# include <mln/canvas/morpho/algebraic_union_find.hh>
@@ -83,6 +81,11 @@
void init()
{
// FIXME: border::fill(input, mln_max(mln_value(I)));
+ /* FIXME: Shouldn't it be
+
+ border::fill(input, mln_max(mln_value(I)))
+
+ instead? */
}
inline
Index: mln/morpho/opening_attribute.hh
--- mln/morpho/opening_attribute.hh (revision 1988)
+++ mln/morpho/opening_attribute.hh (working copy)
@@ -28,10 +28,8 @@
#ifndef MLN_MORPHO_OPENING_ATTRIBUTE_HH
# define MLN_MORPHO_OPENING_ATTRIBUTE_HH
-/*! \file mln/morpho/opening_attribute.hh
- *
- * \brief Morphological attribute opening.
- */
+/// \file mln/morpho/opening_attribute.hh
+/// \brief Morphological attribute opening.
# include <mln/morpho/includes.hh>
# include <mln/canvas/morpho/algebraic_union_find.hh>
Index: tests/morpho/closing_volume.cc
--- tests/morpho/closing_volume.cc (revision 1988)
+++ tests/morpho/closing_volume.cc (working copy)
@@ -25,10 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/morpho/closing_area.cc
- *
- * \brief Test on mln::morpho::closing_area.
- */
+/// \file tests/morpho/closing_volume.cc
+/// \brief Test on mln::morpho::closing_volume.
#include <mln/core/image2d.hh>
#include <mln/value/int_u8.hh>
@@ -37,12 +35,10 @@
#include <mln/io/pgm/load.hh>
#include <mln/io/pgm/save.hh>
-#include <mln/morpho/closing_area.hh>
+#include <mln/morpho/closing_volume.hh>
#include "tests/data.hh"
-
-
int main()
{
using namespace mln;
@@ -52,6 +48,6 @@
io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
image2d<int_u8> out(lena.domain());
- morpho::closing_area(lena, c4(), 510, out);
+ morpho::closing_volume(lena, c4(), 10000, out);
io::pgm::save(out, "out.pgm");
}
Index: tests/morpho/opening_volume.cc
--- tests/morpho/opening_volume.cc (revision 1988)
+++ tests/morpho/opening_volume.cc (working copy)
@@ -25,10 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/morpho/opening_area.cc
- *
- * \brief Test on mln::morpho::opening_area.
- */
+/// \file tests/morpho/opening_volume.cc
+/// \brief Test on mln::morpho::opening_volume.
#include <mln/core/image2d.hh>
#include <mln/value/int_u8.hh>
@@ -37,12 +35,10 @@
#include <mln/io/pgm/load.hh>
#include <mln/io/pgm/save.hh>
-#include <mln/morpho/opening_area.hh>
+#include <mln/morpho/opening_volume.hh>
#include "tests/data.hh"
-
-
int main()
{
using namespace mln;
@@ -52,6 +48,6 @@
io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
image2d<int_u8> out(lena.domain());
- morpho::opening_area(lena, c4(), 510, out);
+ morpho::opening_volume(lena, c4(), 10000, out);
io::pgm::save(out, "out.pgm");
}
Index: tests/morpho/Makefile.am
--- tests/morpho/Makefile.am (revision 1988)
+++ tests/morpho/Makefile.am (working copy)
@@ -5,6 +5,7 @@
check_PROGRAMS = \
artificial_line_graph_image_wst \
closing_area \
+ closing_volume \
combined \
contrast \
dilation \
@@ -19,6 +20,7 @@
meyer_wst \
meyer_wst_long \
opening_area \
+ opening_volume \
thinning
# -------------- #
@@ -34,6 +36,9 @@
opening_area_SOURCES = opening_area.cc
closing_area_SOURCES = closing_area.cc
+closing_volume_SOURCES = closing_volume.cc
+opening_volume_SOURCES = opening_volume.cc
+
contrast_SOURCES = contrast.cc
gradient_SOURCES = gradient.cc
hit_or_miss_SOURCES = hit_or_miss.cc