https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix labeling fill holes and add a 3D ball window.
* mln/labeling/fill_holes.hh: Fix.
* mln/labeling/all.hh: Update.
* tests/labeling/fill_holes.cc: New.
* tests/labeling/Makefile.am: Update.
* mln/win/ball3d.hh: New.
* mln/win/all.hh: Update.
mln/labeling/all.hh | 4 ++-
mln/labeling/fill_holes.hh | 14 +++++-----
mln/win/all.hh | 11 ++++----
mln/win/ball3d.hh | 41 ++++++++++++++++----------------
tests/labeling/Makefile.am | 2 +
tests/labeling/fill_holes.cc | 55 +++++++++++++++++++++++++++++++++++++++++++
6 files changed, 94 insertions(+), 33 deletions(-)
Index: mln/win/ball3d.hh
--- mln/win/ball3d.hh (revision 3368)
+++ mln/win/ball3d.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 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
@@ -26,39 +26,39 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_WIN_DISK2D_HH
-# define MLN_WIN_DISK2D_HH
+#ifndef MLN_WIN_BALL3D_HH
+# define MLN_WIN_BALL3D_HH
-/// \file mln/win/disk2d.hh
+/// \file mln/win/ball3d.hh
///
-/// Definition of the mln::win::disk2d window.
+/// Definition of the mln::win::ball3d window.
# include <mln/core/internal/classical_window_base.hh>
-# include <mln/core/alias/dpoint2d.hh>
+# include <mln/core/alias/dpoint3d.hh>
namespace mln
{
- mln_internal_add_classical_window_trait(disk2d);
+ mln_internal_add_classical_window_trait(ball3d);
namespace win
{
- /*! \brief Disk window defined on the 2D square grid.
+ /*! \brief Ball (sphere) window defined on the 3D square grid.
*
- * A disk2d is centered and symmetric.
+ * A ball3d is centered and symmetric.
*
*/
- struct disk2d : public internal::classical_window_base< dpoint2d, disk2d >
+ struct ball3d : public internal::classical_window_base< dpoint3d, ball3d >
{
/*! \brief Constructor.
*
* \param[in] length Length, thus diameter.
*
*/
- disk2d(unsigned length);
+ ball3d(unsigned length);
/*! \brief Give the disk diameter.
*/
@@ -80,7 +80,7 @@
# ifndef MLN_INCLUDE_ONLY
inline
- disk2d::disk2d(unsigned length)
+ ball3d::ball3d(unsigned length)
: length_(length)
{
mln_precondition(length % 2 == 1);
@@ -90,26 +90,27 @@
r2 = static_cast<def::coord>(r * r);
for (def::coord a = minus_r; a <= r; ++a)
for (def::coord b = minus_r; b <= r; ++b)
- if (a * a + b * b <= r2)
- insert(dpoint2d(a, b));
+ for (def::coord c = minus_r; c <= r; ++c)
+ if (a * a + b * b + c * c <= r2)
+ insert(dpoint3d(a, b, c));
}
inline
- unsigned disk2d::length() const
+ unsigned ball3d::length() const
{
return length_;
}
inline
- unsigned disk2d::delta_() const
+ unsigned ball3d::delta_() const
{
return length_ / 2;
}
inline
- void disk2d::print_(std::ostream& ostr) const
+ void ball3d::print_(std::ostream& ostr) const
{
- ostr << "[disk2d: length=" << length_ << ']';
+ ostr << "[ball3d: length=" << length_ << ']';
}
# endif // ! MLN_INCLUDE_ONLY
@@ -120,4 +121,4 @@
-#endif // ! MLN_WIN_DISK2D_HH
+#endif // ! MLN_WIN_BALL3D_HH
Property changes on: mln/win/ball3d.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/win/all.hh
--- mln/win/all.hh (revision 3372)
+++ mln/win/all.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA, 2009 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,10 +29,9 @@
#ifndef MLN_WIN_ALL_HH
# define MLN_WIN_ALL_HH
-/*! \file mln/win/all.hh
- *
- * \brief File that includes all win-related routines.
- */
+/// \file mln/win/all.hh
+///
+/// File that includes all win-related routines.
namespace mln
@@ -46,6 +46,7 @@
// Types.
# include <mln/win/backdiag2d.hh>
+# include <mln/win/ball3d.hh>
# include <mln/win/cube3d.hh>
# include <mln/win/cuboid3d.hh>
# include <mln/win/diag2d.hh>
Index: mln/labeling/all.hh
--- mln/labeling/all.hh (revision 3372)
+++ mln/labeling/all.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008, 2009 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
@@ -55,6 +56,7 @@
# include <mln/labeling/background.hh>
# include <mln/labeling/blobs.hh>
# include <mln/labeling/compute.hh>
+# include <mln/labeling/fill_holes.hh>
# include <mln/labeling/flat_zones.hh>
# include <mln/labeling/foreground.hh>
# include <mln/labeling/level.hh>
Index: mln/labeling/fill_holes.hh
--- mln/labeling/fill_holes.hh (revision 3372)
+++ mln/labeling/fill_holes.hh (working copy)
@@ -36,10 +36,9 @@
# include <mln/labeling/background.hh>
# include <mln/labeling/compute.hh>
+# include <mln/core/image/image_if.hh>
# include <mln/accu/count.hh>
-# include <mln/value/int_u8.hh>
-
namespace mln
{
@@ -81,19 +80,20 @@
mln_precondition(exact(input).is_valid());
mln_precondition(exact(nbh).is_valid());
- using value::int_u8;
-
mln_ch_value(I, bool) output;
initialize(output, input);
data::fill(output, false);
- accu::count<int_u8> a_;
mln_ch_value(I, L) lbls = labeling::background(input, nbh, nlabels);
+
+ accu::count<mln_value(I)> a_;
util::array<unsigned> arr = labeling::compute(a_, input, lbls, nlabels);
+
int bg_count = 0;
int bg_lbl = 0;
- for (int i = 0; i < arr.nelements(); ++i)
+ // We start at 1 to ignore the object.
+ for (int i = 1; i < arr.nelements(); ++i)
{
if (arr[i] > bg_count)
{
@@ -102,7 +102,7 @@
}
}
- data::fill((output | pw::value(lbls) != bg_lbl).rw(), true);
+ data::fill((output | (pw::value(lbls) != bg_lbl)).rw(), true);
trace::exiting("labeling::fill_holes");
return output;
Index: tests/labeling/fill_holes.cc
--- tests/labeling/fill_holes.cc (revision 0)
+++ tests/labeling/fill_holes.cc (revision 0)
@@ -0,0 +1,55 @@
+// Copyright (C) 2009 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
+// 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.
+
+/// \file tests/labeling/fill_holes.cc
+///
+/// Test on mln::labeling::fill_holes.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/io/pbm/load.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/labeling/fill_holes.hh>
+#include <mln/value/label_8.hh>
+
+#include <mln/debug/println.hh>
+#include <mln/io/pbm/save.hh>
+
+#include "tests/data.hh"
+
+
+int main()
+{
+ using namespace mln;
+
+ image2d<bool> pic = io::pbm::load(MLN_IMG_DIR "/picasso.pbm");
+ debug::println(pic);
+ value::label_8 n;
+ image2d<bool> out = labeling::fill_holes(pic, c4(), n);
+ debug::println(out);
+ io::pbm::save(out, "out.pbm");
+// mln_assertion(n == 33);
+}
Index: tests/labeling/Makefile.am
--- tests/labeling/Makefile.am (revision 3372)
+++ tests/labeling/Makefile.am (working copy)
@@ -6,6 +6,7 @@
background \
blobs \
compute \
+ fill_holes \
flat_zones \
foreground \
level \
@@ -16,6 +17,7 @@
background_SOURCES = background.cc
blobs_SOURCES = blobs.cc
compute_SOURCES = compute.cc
+fill_holes_SOURCES = fill_holes.cc
flat_zones_SOURCES = flat_zones.cc
foreground_SOURCES = foreground.cc
level_SOURCES = level.cc