Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
March 2009
- 9 participants
- 202 discussions
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add morpho approximate dil, ero, clo and ope.
* mln/morpho/approx: New directory.
* mln/morpho/approx/dilation.hh: New.
* mln/morpho/approx/erosion.hh: New.
* mln/morpho/approx/all.hh: New.
* mln/morpho/closing/approx: New directory.
* mln/morpho/closing/approx/all.hh: New.
* mln/morpho/closing/approx/structural.hh: New.
* mln/morpho/opening/approx: New directory.
* mln/morpho/opening/approx/structural.hh: New.
* mln/morpho/opening/approx/all.hh: New.
* mln/morpho/all.hh: Update.
* tests/morpho/approx: New directory.
* tests/morpho/approx/erosion.cc: New.
* tests/morpho/approx/dilation.cc: New.
* tests/morpho/approx/Makefile.am: New.
* tests/morpho/closing/approx: New directory.
* tests/morpho/closing/approx/structural.cc: New.
* tests/morpho/closing/approx/Makefile.am: New.
* tests/morpho/closing/Makefile.am: Update.
* tests/morpho/opening/approx: New directory.
* tests/morpho/opening/approx/structural.cc: New.
* tests/morpho/opening/approx/Makefile.am: New.
* tests/morpho/opening/Makefile.am: Update.
* tests/morpho/Makefile.am: Update.
mln/morpho/all.hh | 1
mln/morpho/approx/all.hh | 57 +++++++
mln/morpho/approx/dilation.hh | 229 ++++++++++++++++++++++++++++++
mln/morpho/approx/erosion.hh | 219 ++++++++++++++++++++++++++++
mln/morpho/closing/approx/all.hh | 56 +++++++
mln/morpho/closing/approx/structural.hh | 31 ++--
mln/morpho/opening/approx/all.hh | 56 +++++++
mln/morpho/opening/approx/structural.hh | 31 ++--
tests/morpho/Makefile.am | 1
tests/morpho/approx/Makefile.am | 12 +
tests/morpho/approx/dilation.cc | 63 ++++++++
tests/morpho/approx/erosion.cc | 63 ++++++++
tests/morpho/closing/Makefile.am | 3
tests/morpho/closing/approx/Makefile.am | 10 +
tests/morpho/closing/approx/structural.cc | 62 ++++++++
tests/morpho/opening/Makefile.am | 3
tests/morpho/opening/approx/Makefile.am | 10 +
tests/morpho/opening/approx/structural.cc | 62 ++++++++
18 files changed, 949 insertions(+), 20 deletions(-)
Index: mln/morpho/closing/approx/all.hh
--- mln/morpho/closing/approx/all.hh (revision 0)
+++ mln/morpho/closing/approx/all.hh (revision 0)
@@ -0,0 +1,56 @@
+// 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.
+
+#ifndef MLN_MORPHO_CLOSING_APPROX_ALL_HH
+# define MLN_MORPHO_CLOSING_APPROX_ALL_HH
+
+/// \file mln/morpho/closing/approx/all.hh
+///
+/// File that includes all approximate mathematical morphology closing
+/// routines.
+
+
+namespace mln
+{
+ namespace morpho
+ {
+ namespace closing
+ {
+
+ /// Namespace of approximate mathematical morphology closing
+ /// routines.
+ namespace approx {}
+
+ }
+ }
+}
+
+
+# include <mln/morpho/closing/approx/structural.hh>
+
+
+#endif // ! MLN_MORPHO_CLOSING_APPROX_ALL_HH
Index: mln/morpho/closing/approx/structural.hh
--- mln/morpho/closing/approx/structural.hh (revision 0)
+++ mln/morpho/closing/approx/structural.hh (working copy)
@@ -26,14 +26,15 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_MORPHO_CLOSING_STRUCTURAL_HH
-# define MLN_MORPHO_CLOSING_STRUCTURAL_HH
+#ifndef MLN_MORPHO_CLOSING_APPROX_STRUCTURAL_HH
+# define MLN_MORPHO_CLOSING_APPROX_STRUCTURAL_HH
-/// \file mln/morpho/closing/structural.hh
+/// \file mln/morpho/closing/approx/structural.hh
///
-/// Morphological structural closing.
+/// Approximate of morphological structural closing.
-# include <mln/morpho/includes.hh>
+# include <mln/morpho/approx/dilation.hh>
+# include <mln/morpho/approx/erosion.hh>
namespace mln
@@ -45,7 +46,10 @@
namespace closing
{
- /// Morphological structural closing.
+ namespace approx
+ {
+
+ /// Approximate of morphological structural closing.
///
/// This operator is e_{-B} o d_B.
///
@@ -63,22 +67,29 @@
mln_concrete(I)
structural(const Image<I>& input, const Window<W>& win)
{
- trace::entering("morpho::closing::structural");
+ trace::entering("morpho::closing::approx::structural");
mln_precondition(exact(input).is_valid());
mln_precondition(! exact(win).is_empty());
- mln_concrete(I) output = erosion(dilation(input, win), win::sym(win));
+ using mln::morpho::approx::dilation;
+ using mln::morpho::approx::erosion;
+
+ mln_concrete(I) output = erosion(dilation(input,
+ win),
+ win::sym(win));
mln_postcondition(output >= input);
- trace::exiting("morpho::closing::structural");
+ trace::exiting("morpho::closing::approx::structural");
return output;
}
# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::morpho::closing::approx
+
} // end of namespace mln::morpho::closing
} // end of namespace mln::morpho
@@ -86,4 +97,4 @@
} // end of namespace mln
-#endif // ! MLN_MORPHO_CLOSING_STRUCTURAL_HH
+#endif // ! MLN_MORPHO_CLOSING_APPROX_STRUCTURAL_HH
Index: mln/morpho/all.hh
--- mln/morpho/all.hh (revision 3483)
+++ mln/morpho/all.hh (working copy)
@@ -80,6 +80,7 @@
// Sub-directories.
+# include <mln/morpho/approx/all.hh>
# include <mln/morpho/attribute/all.hh>
# include <mln/morpho/closing/all.hh>
# include <mln/morpho/elementary/all.hh>
Index: mln/morpho/approx/dilation.hh
--- mln/morpho/approx/dilation.hh (revision 0)
+++ mln/morpho/approx/dilation.hh (revision 0)
@@ -0,0 +1,229 @@
+// 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.
+
+#ifndef MLN_MORPHO_APPROX_DILATION_HH
+# define MLN_MORPHO_APPROX_DILATION_HH
+
+/// \file mln/morpho/approx/dilation.hh
+///
+/// Approximate mathematical morphology dilation.
+
+# include <mln/core/concept/image.hh>
+
+# include <mln/core/routine/duplicate.hh>
+# include <mln/level/compare.hh>
+
+# include <mln/transform/distance_front.hh>
+# include <mln/pw/all.hh>
+
+# include <mln/core/alias/neighb2d.hh>
+# include <mln/make/w_window2d_int.hh>
+# include <mln/win/disk2d.hh>
+
+# include <mln/core/alias/neighb3d.hh>
+# include <mln/make/w_window3d_int.hh>
+# include <mln/win/sphere3d.hh>
+
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace approx
+ {
+
+
+ template <typename I, typename W>
+ mln_concrete(I)
+ dilation(const Image<I>& input, const Window<W>& win);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // Implementations.
+
+ namespace impl
+ {
+
+
+ // By distance thresholding.
+
+ template <typename I>
+ mln_concrete(I)
+ dilation_by_distance_thresholding_2d(const Image<I>& input_,
+ const Window< win::disk2d >& win_)
+ {
+ trace::entering("morpho::approx::impl::dilation_by_distance_thresholding_2d");
+
+ const I& input = exact(input_);
+ const win::disk2d& win = exact(win_);
+
+ mln_precondition(input.is_valid());
+ mln_precondition(win.is_valid());
+
+ int ws[] = { 00, 11, 0, 11, 0,
+ 11, 7, 5, 7, 11,
+ 00, 5, 0, 5, 0,
+ 11, 7, 5, 7, 11,
+ 00, 11, 0, 11, 0 };
+ const unsigned coef = 5;
+
+ unsigned
+ radius = coef * win.diameter() / 2,
+ dmax = radius + 1;
+
+ mln_ch_value(I, unsigned) dmap = transform::distance_front(input,
+ c4(), make::w_window2d_int(ws),
+ dmax);
+ mln_concrete(I) output;
+ output = duplicate((pw::value(dmap) <= pw::cst(radius)) | input.domain());
+
+ trace::exiting("morpho::approx::impl::dilation_by_distance_thresholding_2d");
+ return output;
+ }
+
+
+
+ template <typename I>
+ mln_concrete(I)
+ dilation_by_distance_thresholding_3d(const Image<I>& input_,
+ const Window< win::sphere3d >& win_)
+ {
+ trace::entering("morpho::approx::impl::dilation_by_distance_thresholding_3d");
+
+ const I& input = exact(input_);
+ const win::sphere3d& win = exact(win_);
+
+ mln_precondition(input.is_valid());
+ mln_precondition(win.is_valid());
+
+ int ws[] = { 00, 21, 00,
+ 21, 17, 21,
+ 00, 21, 00,
+
+ 17, 12, 17,
+ 12, 00, 12,
+ 17, 12, 17,
+
+ 00, 21, 00,
+ 21, 17, 21,
+ 00, 21, 00 };
+ const unsigned coef = 12;
+
+ unsigned
+ radius = coef * win.diameter() / 2,
+ dmax = radius + 1;
+
+ mln_ch_value(I, unsigned) dmap = transform::distance_front(input,
+ c6(), make::w_window3d_int(ws),
+ dmax);
+ mln_concrete(I) output;
+ output = duplicate((pw::value(dmap) <= pw::cst(radius)) | input.domain());
+
+ trace::exiting("morpho::approx::impl::dilation_by_distance_thresholding_3d");
+ return output;
+ }
+
+
+ } // end of namespace mln::morpho::approx::impl
+
+
+
+ // Dispatch.
+
+ namespace internal
+ {
+
+ template <typename I>
+ mln_concrete(I)
+ dilation_dispatch(trait::image::kind::logic,
+ const I& input,
+ const win::disk2d& win)
+ {
+ return impl::dilation_by_distance_thresholding_2d(input, win);
+ }
+
+ template <typename I>
+ mln_concrete(I)
+ dilation_dispatch(trait::image::kind::logic,
+ const I& input,
+ const win::sphere3d& win)
+ {
+ return impl::dilation_by_distance_thresholding_3d(input, win);
+ }
+
+ // Entry point.
+
+ template <typename I, typename W>
+ mln_concrete(I)
+ dilation_dispatch(const I& input, const W& win)
+ {
+ return dilation_dispatch(mln_trait_image_kind(I)(),
+ input, win);
+ }
+
+ } // end of namespace mln::morpho::approx::internal
+
+
+ // Facade.
+
+ template <typename I, typename W>
+ inline
+ mln_concrete(I)
+ dilation(const Image<I>& input, const Window<W>& win)
+ {
+ trace::entering("morpho::approx::dilation");
+
+ mln_precondition(exact(input).is_valid());
+ mln_precondition(exact(win).is_valid());
+
+ mln_concrete(I) output;
+ output = internal::dilation_dispatch(exact(input), exact(win));
+
+ if (exact(win).is_centered())
+ mln_postcondition(output >= input);
+
+ trace::exiting("morpho::approx::dilation");
+ return output;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho::approx
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_APPROX_DILATION_HH
Index: mln/morpho/approx/all.hh
--- mln/morpho/approx/all.hh (revision 0)
+++ mln/morpho/approx/all.hh (revision 0)
@@ -0,0 +1,57 @@
+// 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.
+
+#ifndef MLN_MORPHO_APPROX_ALL_HH
+# define MLN_MORPHO_APPROX_ALL_HH
+
+/// \file mln/morpho/approx/all.hh
+///
+/// File that includes all approximate mathematical morphology
+/// routines.
+
+
+namespace mln
+{
+ namespace morpho
+ {
+
+ /// Namespace of approximate mathematical morphology routines.
+ namespace approx {}
+
+ }
+}
+
+
+# include <mln/morpho/approx/dilation.hh>
+# include <mln/morpho/approx/erosion.hh>
+
+// Sub-directories.
+# include <mln/morpho/closing/approx/all.hh>
+# include <mln/morpho/opening/approx/all.hh>
+
+
+#endif // ! MLN_MORPHO_APPROX_ALL_HH
Index: mln/morpho/approx/erosion.hh
--- mln/morpho/approx/erosion.hh (revision 0)
+++ mln/morpho/approx/erosion.hh (revision 0)
@@ -0,0 +1,219 @@
+// 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.
+
+#ifndef MLN_MORPHO_APPROX_EROSION_HH
+# define MLN_MORPHO_APPROX_EROSION_HH
+
+/// \file mln/morpho/approx/erosion.hh
+///
+/// Approximate mathematical morphology erosion.
+
+# include <mln/morpho/approx/dilation.hh>
+# include <mln/logical/not.hh>
+
+
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ namespace approx
+ {
+
+
+ template <typename I, typename W>
+ mln_concrete(I)
+ erosion(const Image<I>& input, const Window<W>& win);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // Implementations.
+
+ namespace impl
+ {
+
+
+ // By distance thresholding.
+
+ template <typename I>
+ mln_concrete(I)
+ erosion_by_distance_thresholding_2d(const Image<I>& input_,
+ const Window< win::disk2d >& win_)
+ {
+ trace::entering("morpho::approx::impl::erosion_by_distance_thresholding_2d");
+
+ const I& input = exact(input_);
+ const win::disk2d& win = exact(win_);
+
+ mln_precondition(input.is_valid());
+ mln_precondition(win.is_valid());
+
+ int ws[] = { 00, 11, 0, 11, 0,
+ 11, 7, 5, 7, 11,
+ 00, 5, 0, 5, 0,
+ 11, 7, 5, 7, 11,
+ 00, 11, 0, 11, 0 };
+ const unsigned coef = 5;
+
+ unsigned
+ radius = coef * win.diameter() / 2,
+ dmax = radius + 1;
+
+
+ mln_concrete(I) background = logical::not_(input);
+ mln_ch_value(I, unsigned) dmap = transform::distance_front(background,
+ c4(), make::w_window2d_int(ws),
+ dmax);
+ mln_concrete(I) output;
+ output = duplicate((pw::value(dmap) > pw::cst(radius)) | input.domain());
+
+ trace::exiting("morpho::approx::impl::erosion_by_distance_thresholding_2d");
+ return output;
+ }
+
+
+
+ template <typename I>
+ mln_concrete(I)
+ erosion_by_distance_thresholding_3d(const Image<I>& input_,
+ const Window< win::sphere3d >& win_)
+ {
+ trace::entering("morpho::approx::impl::erosion_by_distance_thresholding_3d");
+
+ const I& input = exact(input_);
+ const win::sphere3d& win = exact(win_);
+
+ mln_precondition(input.is_valid());
+ mln_precondition(win.is_valid());
+
+ int ws[] = { 00, 21, 00,
+ 21, 17, 21,
+ 00, 21, 00,
+
+ 17, 12, 17,
+ 12, 00, 12,
+ 17, 12, 17,
+
+ 00, 21, 00,
+ 21, 17, 21,
+ 00, 21, 00 };
+ const unsigned coef = 12;
+
+ unsigned
+ radius = coef * win.diameter() / 2,
+ dmax = radius + 1;
+
+ mln_concrete(I) background = logical::not_(input);
+ mln_ch_value(I, unsigned) dmap = transform::distance_front(background,
+ c6(), make::w_window3d_int(ws),
+ dmax);
+ mln_concrete(I) output;
+ output = duplicate((pw::value(dmap) > pw::cst(radius)) | input.domain());
+
+ trace::exiting("morpho::approx::impl::erosion_by_distance_thresholding_3d");
+ return output;
+ }
+
+
+ } // end of namespace mln::morpho::approx::impl
+
+
+
+ // Dispatch.
+
+ namespace internal
+ {
+
+ template <typename I>
+ mln_concrete(I)
+ erosion_dispatch(trait::image::kind::logic,
+ const I& input,
+ const win::disk2d& win)
+ {
+ return impl::erosion_by_distance_thresholding_2d(input, win);
+ }
+
+ template <typename I>
+ mln_concrete(I)
+ erosion_dispatch(trait::image::kind::logic,
+ const I& input,
+ const win::sphere3d& win)
+ {
+ return impl::erosion_by_distance_thresholding_3d(input, win);
+ }
+
+ // Entry point.
+
+ template <typename I, typename W>
+ mln_concrete(I)
+ erosion_dispatch(const I& input, const W& win)
+ {
+ return erosion_dispatch(mln_trait_image_kind(I)(),
+ input, win);
+ }
+
+ } // end of namespace mln::morpho::approx::internal
+
+
+ // Facade.
+
+ template <typename I, typename W>
+ inline
+ mln_concrete(I)
+ erosion(const Image<I>& input, const Window<W>& win)
+ {
+ trace::entering("morpho::approx::erosion");
+
+ mln_precondition(exact(input).is_valid());
+ mln_precondition(exact(win).is_valid());
+
+ mln_concrete(I) output;
+ output = internal::erosion_dispatch(exact(input), exact(win));
+
+ if (exact(win).is_centered())
+ mln_postcondition(output <= input);
+
+ trace::exiting("morpho::approx::erosion");
+ return output;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho::approx
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_APPROX_EROSION_HH
Index: mln/morpho/opening/approx/all.hh
--- mln/morpho/opening/approx/all.hh (revision 0)
+++ mln/morpho/opening/approx/all.hh (revision 0)
@@ -0,0 +1,56 @@
+// 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.
+
+#ifndef MLN_MORPHO_OPENING_APPROX_ALL_HH
+# define MLN_MORPHO_OPENING_APPROX_ALL_HH
+
+/// \file mln/morpho/opening/approx/all.hh
+///
+/// File that includes all approximate mathematical morphology opening
+/// routines.
+
+
+namespace mln
+{
+ namespace morpho
+ {
+ namespace opening
+ {
+
+ /// Namespace of approximate mathematical morphology opening
+ /// routines.
+ namespace approx {}
+
+ }
+ }
+}
+
+
+# include <mln/morpho/opening/approx/structural.hh>
+
+
+#endif // ! MLN_MORPHO_OPENING_APPROX_ALL_HH
Index: mln/morpho/opening/approx/structural.hh
--- mln/morpho/opening/approx/structural.hh (revision 0)
+++ mln/morpho/opening/approx/structural.hh (working copy)
@@ -26,14 +26,15 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_MORPHO_OPENING_STRUCTURAL_HH
-# define MLN_MORPHO_OPENING_STRUCTURAL_HH
+#ifndef MLN_MORPHO_OPENING_APPROX_STRUCTURAL_HH
+# define MLN_MORPHO_OPENING_APPROX_STRUCTURAL_HH
-/// \file mln/morpho/opening/structural.hh
+/// \file mln/morpho/opening/approx/structural.hh
///
-/// Morphological structural opening.
+/// Approximate of morphological structural opening.
-# include <mln/morpho/includes.hh>
+# include <mln/morpho/approx/dilation.hh>
+# include <mln/morpho/approx/erosion.hh>
namespace mln
@@ -45,7 +46,10 @@
namespace opening
{
- /// Morphological structural opening.
+ namespace approx
+ {
+
+ /// Approximate of morphological structural opening.
///
/// This operator is d_{-B} o e_B.
template <typename I, typename W>
@@ -62,22 +66,29 @@
mln_concrete(I)
structural(const Image<I>& input, const Window<W>& win)
{
- trace::entering("morpho::opening::structural");
+ trace::entering("morpho::opening::approx::structural");
mln_precondition(exact(input).is_valid());
mln_precondition(! exact(win).is_empty());
- mln_concrete(I) output = dilation(erosion(input, win), win::sym(win));
+ using mln::morpho::approx::dilation;
+ using mln::morpho::approx::erosion;
+
+ mln_concrete(I) output = dilation(erosion(input,
+ win),
+ win::sym(win));
mln_postcondition(output <= input);
- trace::exiting("morpho::opening::structural");
+ trace::exiting("morpho::opening::approx::structural");
return output;
}
# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::morpho::closing::approx
+
} // end of namespace mln::morpho::opening
} // end of namespace mln::morpho
@@ -85,4 +96,4 @@
} // end of namespace mln
-#endif // ! MLN_MORPHO_OPENING_STRUCTURAL_HH
+#endif // ! MLN_MORPHO_OPENING_APPROX_STRUCTURAL_HH
Index: tests/morpho/closing/Makefile.am
--- tests/morpho/closing/Makefile.am (revision 3483)
+++ tests/morpho/closing/Makefile.am (working copy)
@@ -2,6 +2,9 @@
include $(top_srcdir)/milena/tests/tests.mk
+SUBDIRS = \
+ approx
+
check_PROGRAMS = \
leveling \
algebraic \
Index: tests/morpho/closing/approx/Makefile.am
--- tests/morpho/closing/approx/Makefile.am (revision 0)
+++ tests/morpho/closing/approx/Makefile.am (revision 0)
@@ -0,0 +1,10 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ structural
+
+structural_SOURCES = structural.cc
+
+TESTS = $(check_PROGRAMS)
Index: tests/morpho/closing/approx/structural.cc
--- tests/morpho/closing/approx/structural.cc (revision 0)
+++ tests/morpho/closing/approx/structural.cc (revision 0)
@@ -0,0 +1,62 @@
+// 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/morpho/closing/approx/structural.cc
+///
+/// Test on mln::morpho::closing::approx::structural.
+
+#include <mln/core/image/image2d.hh>
+
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pbm/save.hh>
+
+#include <mln/morpho/closing/approx/structural.hh>
+#include <mln/morpho/closing/structural.hh>
+
+#include "tests/data.hh"
+
+
+int main()
+{
+ using namespace mln;
+
+ image2d<bool> lena, out, ref;
+ io::pbm::load(lena, MLN_IMG_DIR "/lena.pbm");
+
+ win::disk2d dsk(51);
+
+ {
+ ref = morpho::closing::structural(lena, dsk);
+ io::pbm::save(ref, "ref.pbm");
+ }
+
+ {
+ out = morpho::closing::approx::structural(lena, dsk);
+ io::pbm::save(out, "out.pbm");
+ }
+
+}
Index: tests/morpho/approx/erosion.cc
--- tests/morpho/approx/erosion.cc (revision 0)
+++ tests/morpho/approx/erosion.cc (revision 0)
@@ -0,0 +1,63 @@
+// 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/morpho/approx/erosion.cc
+///
+/// Test on mln::morpho::approx::erosion.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/win/disk2d.hh>
+
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pbm/save.hh>
+
+#include <mln/morpho/approx/erosion.hh>
+#include <mln/morpho/erosion.hh>
+
+#include "tests/data.hh"
+
+
+int main()
+{
+ using namespace mln;
+
+ image2d<bool> lena;
+ io::pbm::load(lena, MLN_IMG_DIR "/lena.pbm");
+
+ win::disk2d dsk(51);
+
+ {
+ image2d<bool> ref = morpho::erosion(lena, dsk);
+ io::pbm::save(ref, "ref.pbm");
+ }
+
+ {
+ image2d<bool> out = morpho::approx::erosion(lena, dsk);
+ io::pbm::save(out, "out.pbm");
+ }
+
+}
Index: tests/morpho/approx/dilation.cc
--- tests/morpho/approx/dilation.cc (revision 0)
+++ tests/morpho/approx/dilation.cc (revision 0)
@@ -0,0 +1,63 @@
+// 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/morpho/approx/dilation.cc
+///
+/// Test on mln::morpho::approx::dilation.
+
+#include <mln/core/image/image2d.hh>
+#include <mln/win/disk2d.hh>
+
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pbm/save.hh>
+
+#include <mln/morpho/approx/dilation.hh>
+#include <mln/morpho/dilation.hh>
+
+#include "tests/data.hh"
+
+
+int main()
+{
+ using namespace mln;
+
+ image2d<bool> lena;
+ io::pbm::load(lena, MLN_IMG_DIR "/lena.pbm");
+
+ win::disk2d dsk(51);
+
+ {
+ image2d<bool> ref = morpho::dilation(lena, dsk);
+ io::pbm::save(ref, "ref.pbm");
+ }
+
+ {
+ image2d<bool> out = morpho::approx::dilation(lena, dsk);
+ io::pbm::save(out, "out.pbm");
+ }
+
+}
Index: tests/morpho/approx/Makefile.am
--- tests/morpho/approx/Makefile.am (revision 0)
+++ tests/morpho/approx/Makefile.am (revision 0)
@@ -0,0 +1,12 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ dilation \
+ erosion
+
+dilation_SOURCES = dilation.cc
+erosion_SOURCES = erosion.cc
+
+TESTS = $(check_PROGRAMS)
Index: tests/morpho/opening/Makefile.am
--- tests/morpho/opening/Makefile.am (revision 3483)
+++ tests/morpho/opening/Makefile.am (working copy)
@@ -2,6 +2,9 @@
include $(top_srcdir)/milena/tests/tests.mk
+SUBDIRS = \
+ approx
+
check_PROGRAMS = \
leveling \
algebraic \
Index: tests/morpho/opening/approx/Makefile.am
--- tests/morpho/opening/approx/Makefile.am (revision 0)
+++ tests/morpho/opening/approx/Makefile.am (revision 0)
@@ -0,0 +1,10 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ structural
+
+structural_SOURCES = structural.cc
+
+TESTS = $(check_PROGRAMS)
Index: tests/morpho/opening/approx/structural.cc
--- tests/morpho/opening/approx/structural.cc (revision 0)
+++ tests/morpho/opening/approx/structural.cc (revision 0)
@@ -0,0 +1,62 @@
+// 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/morpho/opening/approx/structural.cc
+///
+/// Test on mln::morpho::opening::approx::structural.
+
+#include <mln/core/image/image2d.hh>
+
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pbm/save.hh>
+
+#include <mln/morpho/opening/approx/structural.hh>
+#include <mln/morpho/opening/structural.hh>
+
+#include "tests/data.hh"
+
+
+int main()
+{
+ using namespace mln;
+
+ image2d<bool> lena, out, ref;
+ io::pbm::load(lena, MLN_IMG_DIR "/lena.pbm");
+
+ win::disk2d dsk(51);
+
+ {
+ ref = morpho::opening::structural(lena, dsk);
+ io::pbm::save(ref, "ref.pbm");
+ }
+
+ {
+ out = morpho::opening::approx::structural(lena, dsk);
+ io::pbm::save(out, "out.pbm");
+ }
+
+}
Index: tests/morpho/Makefile.am
--- tests/morpho/Makefile.am (revision 3483)
+++ tests/morpho/Makefile.am (working copy)
@@ -3,6 +3,7 @@
include $(top_srcdir)/milena/tests/tests.mk
SUBDIRS = \
+ approx \
attribute \
closing \
elementary \
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add 2D distance chamfer values.
* theo/dmap.txt: New.
dmap.txt | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 92 insertions(+)
Index: theo/dmap.txt
--- theo/dmap.txt (revision 0)
+++ theo/dmap.txt (revision 0)
@@ -0,0 +1,92 @@
+
+ -*- outline -*-
+
+
+* ref
+
+B.J.H. Verwer, Local distances for distance transformations in two and
+three dimensions, Pattern Recognition Letters 12 (1991) 671-682
+
+2 cases :
+
+** mse
+unbiased minimal mean square error for integer local distances (Table 5)
+
+** mae
+maximum absolute error for integer local distances (Table 2)
+
+
+
+* 2D chamfers
+
+** shapes
+
+ . d10 .
+d10 x
+
+
+d11 d10 d11
+d10 x
+
+
+ . d21 . d21 .
+d21 d11 d10 d11 d21
+ . d10 x
+
+** values
+
+*** d10 c
+
+1 1. cityblock
+
+*** d10 d11 c
+
+**** mse
+
+ 1 1 0.9003 chessboard
+ 1 2 1.2732 cityblock-like
+ 2 3 2.1736
+ 5 7 5.2474
+12 17 12.6684
+
+***** non-discrete
+0.9481 1.3408 1
+
+**** mae
+
+ 1 1 0.8536 chessboard
+ 1 2 1.2071 cityblock-like
+ 2 3 2.1180
+ 5 7 5.1675
+12 17 12.5000
+
+***** non-discrete
+1/f sqrt(2)/f 1 with f = 1.0412
+
+*** d10 d11 d21
+
+**** mse
+
+ 4 6 9 4.1203
+ 5 7 11 5.0206
+ 9 13 20 9.1409
+16 23 36 16.3351
+
+***** non-discrete
+0.9801 1.4060 2.2044 1
+
+**** mae
+
+ 4 6 9 4.1213
+ 5 7 11 5.0092
+ 9 13 20 9.0819
+17 24 38 17.2174
+
+***** non-discrete
+1/f sqrt(2)/f sqrt(5)/f 1 with f = 1.0137
+
+
+
+* 3D chamfers
+
+FIXME
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-03-05 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Add source for dicom2dump tool.
* fabien/TODO: Simple TODO reminder.
* fabien/bin/Makefile: Makefile to compile dicom binaries.
* fabien/bin/dicom2dump.cc: Binary to convert dicom to dump.
* fabien/bin/dicom_mask.cc: Binary to extract simple mask
from dicom images.
* fabien/igr/Makefile: Update.
* fabien/igr/launch2d.sh: Update.
* fabien/igr/launch3d.sh: Update.
* fabien/igr/seg2d.cc: Update.
* fabien/igr/seg3d.cc: Update.
* fabien/igr/seg_vol_irm.hh: Implement different threshold
techniques: double and deviation.
---
TODO | 13 +++++++-
bin/Makefile | 23 ++++++++++++++
bin/dicom2dump.cc | 32 ++++++++++++++++++++
bin/dicom_mask.cc | 38 ++++++++++++++++++++++++
igr/Makefile | 6 +++
igr/launch2d.sh | 14 ++++++---
igr/launch3d.sh | 12 +++++--
igr/seg2d.cc | 17 ++++++++++
igr/seg3d.cc | 17 ++++++++++
igr/seg_vol_irm.hh | 82 +++++++++++++++++++++++++++++++++++++++--------------
10 files changed, 221 insertions(+), 33 deletions(-)
Index: trunk/milena/sandbox/fabien/igr/seg_vol_irm.hh
===================================================================
--- trunk/milena/sandbox/fabien/igr/seg_vol_irm.hh (revision 3481)
+++ trunk/milena/sandbox/fabien/igr/seg_vol_irm.hh (revision 3482)
@@ -39,6 +39,7 @@
#include <mln/value/int_u12.hh>
#include <mln/value/int_u16.hh>
#include <mln/value/rgb8.hh>
+#include <mln/value/label_16.hh>
#include <mln/io/pgm/all.hh>
#include <mln/io/pbm/all.hh>
@@ -56,6 +57,7 @@
#include <mln/labeling/blobs.hh>
#include <mln/labeling/compute.hh>
+#include <mln/labeling/foreground.hh>
#include <mln/labeling/fill_holes.hh>
#include <mln/labeling/n_max.hh>
@@ -85,7 +87,6 @@
#include <mln/pw/all.hh>
#include <mln/morpho/elementary/gradient_internal.hh>
-#include <mln/morpho/closing.hh>
#include <mln/morpho/dilation.hh>
#include <mln/morpho/erosion.hh>
@@ -149,12 +150,30 @@
+template <typename I>
+void
+save_regions_color(const Image<I>& ima, metal::int_<2>)
+{
+ io::ppm::save(ima, "regions_color.ppm");
+}
+
+
+
+template <typename I>
+void
+save_regions_color(const Image<I>& ima, metal::int_<3>)
+{
+ io::dump::save(ima, "regions_color.dump");
+}
+
+
+
template <typename I, typename N>
unsigned
find_threshold_value(const Image<I>& input, const Neighborhood<N>& nbh)
{
- int bg_thres = 30;
- int obj_thres = 15;
+ int bg_thres = 20;
+ int obj_thres = 10;
mln_ch_value(I, bool) ima_bg;
initialize(ima_bg, input);
@@ -166,15 +185,16 @@
unsigned result = 0;
- histo::array<mln_value(I)> arr_histo = histo::compute(input);
+ // We remove the 0 value because it is not part of the image.
+ histo::array<mln_value(I)> arr_histo = histo::compute(input | pw::value(input) != 0);
image1d<unsigned> ima_histo;
convert::from_to(arr_histo, ima_histo);
- // We remove the 0 value because it is not part of the image.
- ima_histo(point1d(0)) = 0;
-
+ std::ofstream fout("histo.plot");
+ fout << "0 0" << std::endl;
for (unsigned int i = 1; i < ima_histo.nelements(); ++i)
{
+ fout << i << " " << ima_histo(point1d(i)) << std::endl;
ima_histo(point1d(i)) += ima_histo(point1d(i - 1));
}
accu::max<unsigned> max_accu;
@@ -207,26 +227,41 @@
io::dump::save(ima_obj, "obj.dump");
}
- ima_bg = close_threshold(ima_bg, metal::int_<I::site::dim>(), 3, 5); // 5, 7?
- ima_obj = close_threshold(ima_obj, metal::int_<I::site::dim>(), 3, 5);
+ ima_bg = close_threshold(ima_bg, metal::int_<I::site::dim>(), 9, 15);
+ ima_obj = close_threshold(ima_obj, metal::int_<I::site::dim>(), 9, 11);
// Debug output images
mln_ch_value(I, rgb8) out = level::convert(rgb8(), level::stretch(int_u8(), input));
data::fill((out | pw::value(morpho::elementary::gradient_internal(ima_bg, nbh)) == true).rw(), literal::red);
data::fill((out | pw::value(morpho::elementary::gradient_internal(ima_obj, nbh)) == true).rw(), literal::green);
+ save_regions_color(out, metal::int_<I::site::dim>());
if (I::site::dim == 2)
{
io::pbm::save(ima_bg, "bg_closed.pbm");
io::pbm::save(ima_obj, "obj_closed.pbm");
- io::ppm::save(out, "regions_color.ppm");
}
if (I::site::dim == 3)
{
io::dump::save(ima_bg, "bg_closed.dump");
io::dump::save(ima_obj, "obj_closed.dump");
- io::dump::save(out, "regions_color.dump");
}
+ // Labeling
+ /*label_16 nlabels = 0;
+
+ mln_ch_value(I, label_16) bg_labels = labeling::foreground(ima_bg, nbh, nlabels);
+ mln_ch_value(I, label_16) obj_labels = labeling::foreground(ima_obj, nbh, nlabels);
+
+ accu::count<int_u8> a_;
+ util::array<unsigned> arr_label = labeling::compute(a_, ima_bg, bg_labels, nlabels);
+ util::array<label_16> arr_big = labeling::n_max<label_16>(arr_label, 1);
+ data::fill((ima_bg | (pw::value(bg_labels) != pw::cst(arr_big[1]))).rw(), false);
+
+ arr_label = labeling::compute(a_, ima_obj, obj_labels, nlabels);
+ arr_big = labeling::n_max<label_16>(arr_label, 1);
+ data::fill((ima_obj | (pw::value(obj_labels) != pw::cst(arr_big[1]))).rw(), false);*/
+
+ // Histo
histo::array<mln_value(I)> bg_histo = histo::compute(input | pw::value(ima_bg) == true);
histo::array<mln_value(I)> obj_histo = histo::compute(input | pw::value(ima_obj) == true);
@@ -236,23 +271,27 @@
ima_bg_histo(point1d(0)) = 0;
unsigned bg_sum = level::compute(sum_accu, ima_bg_histo);
// We remove the 0 value because it is not part of the image.
- std::ofstream fout_bg("bg_histo_norm.plot");
+ std::ofstream fout_bg("bg_histo.plot");
+ std::ofstream fout_p_bg("bg_histo_norm.plot");
for (unsigned int i = 0; i < ima_bg_histo.nelements(); ++i)
{
+ fout_bg << i << " " << ima_bg_histo(point1d(i)) << std::endl;
ima_bg_histo(point1d(i)) *= 10000;
ima_bg_histo(point1d(i)) /= bg_sum;
- fout_bg << i << " " << ima_bg_histo(point1d(i)) << std::endl;
+ fout_p_bg << i << " " << ima_bg_histo(point1d(i)) << std::endl;
}
image1d<unsigned> ima_obj_histo;
convert::from_to(obj_histo, ima_obj_histo);
unsigned obj_sum = level::compute(sum_accu, ima_obj_histo);
- std::ofstream fout_obj("obj_histo_norm.plot");
+ std::ofstream fout_obj("obj_histo.plot");
+ std::ofstream fout_p_obj("obj_histo_norm.plot");
for (unsigned int i = 0; i < ima_obj_histo.nelements(); ++i)
{
+ fout_obj << i << " " << ima_obj_histo(point1d(i)) << std::endl;
ima_obj_histo(point1d(i)) *= 10000;
ima_obj_histo(point1d(i)) /= obj_sum;
- fout_obj << i << " " << ima_obj_histo(point1d(i)) << std::endl;
+ fout_p_obj << i << " " << ima_obj_histo(point1d(i)) << std::endl;
}
// Search for the index with the min distance between histogrammes.
@@ -275,7 +314,7 @@
unsigned
find_threshold_mean(const Image<I>& input, const Neighborhood<N>& nbh)
{
- unsigned result = 0;
+ unsigned coef = 1;
accu::mean<unsigned> mean_accu;
unsigned mean = level::compute(mean_accu, (input | (pw::value(input) != 0)));
@@ -283,13 +322,13 @@
accu::stat::deviation<unsigned, unsigned, float> dev_accu(mean);
float deviation = level::compute(dev_accu, (input | pw::value(input) != 0));
- std::cout << "mean = " << mean << std::endl << "deviation = " << deviation << std::endl;
- return floor(deviation);
+ std::cout << "[mean = " << mean << " | deviation = " << deviation << "]";
+ return floor(mean + coef * deviation);
}
-template <typename I, typename N, typename L>
+/*template <typename I, typename N, typename L>
mln_ch_value(I, bool)
igr_seg(const Image<I>& input_, const Neighborhood<N>& nbh_, L& nlabels)
{
@@ -301,9 +340,10 @@
mln_ch_value(I, bool) ima_thres;
initialize(ima_thres, input);
data::fill(ima_thres, false);
- //unsigned threshold_value = find_threshold_value(input, nbh);
+ std::cout << "double threshold value = " << find_threshold_value(input, nbh) << std::endl;
unsigned threshold_value = find_threshold_mean(input, nbh);
+ std::cout << " deviation threshold value = " << threshold_value << std::endl;
data::fill((ima_thres | pw::value(input) < pw::cst(threshold_value)).rw(), true);
return ima_thres;
-}
+}*/
Index: trunk/milena/sandbox/fabien/igr/seg2d.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/seg2d.cc (revision 3481)
+++ trunk/milena/sandbox/fabien/igr/seg2d.cc (revision 3482)
@@ -34,7 +34,22 @@
label_16 nlabels;
image2d<int_u12> ima;
io::dicom::load(ima, argv[1]);
- io::pbm::save(igr_seg(ima, c4(), nlabels), "result.pbm");
+
+ image2d<bool> ima_thres;
+ initialize(ima_thres, ima);
+ data::fill(ima_thres, false);
+ unsigned threshold_value = find_threshold_value(ima, c4());
+ std::cout << "double threshold value = " << threshold_value << std::endl;
+ data::fill((ima_thres | pw::value(ima) < pw::cst(threshold_value)).rw(), true);
+
+ io::pbm::save(ima_thres, "result_double.pbm");
+
+ data::fill(ima_thres, false);
+ threshold_value = find_threshold_mean(ima, c4());
+ std::cout << " deviation threshold value = " << threshold_value << std::endl;
+ data::fill((ima_thres | pw::value(ima) < pw::cst(threshold_value)).rw(), true);
+
+ io::pbm::save(ima_thres, "result_deviation.pbm");
return 0;
}
Index: trunk/milena/sandbox/fabien/igr/launch2d.sh
===================================================================
--- trunk/milena/sandbox/fabien/igr/launch2d.sh (revision 3481)
+++ trunk/milena/sandbox/fabien/igr/launch2d.sh (revision 3482)
@@ -3,8 +3,9 @@
process_file ()
{
./seg2d $1
- if [ -f result.pbm ]; then
- mv result.pbm results/${2}_06_result.pbm
+ if [ -f result_double.pbm ]; then
+ mv result_double.pbm results/${2}_06_result_double.pbm
+ mv result_deviation.pbm results/${2}_07_result_deviation.pbm
fi
if [ -f bg.pbm ]; then
@@ -14,10 +15,15 @@
mv bg_closed.pbm results/${2}_02_bg_closed.pbm
mv obj_closed.pbm results/${2}_04_obj_closed.pbm
+ if [ -f regions_color.ppm ]; then
mv regions_color.ppm results/${2}_05_regions_color.ppm
+ fi
- mv bg_histo_norm.plot results/${2}_bg.plot
- mv obj_histo_norm.plot results/${2}_obj.plot
+ mv histo.plot results/${2}.plot
+ mv bg_histo.plot results/${2}_bg.plot
+ mv obj_histo.plot results/${2}_obj.plot
+ mv bg_histo_norm.plot results/${2}_p_bg.plot
+ mv obj_histo_norm.plot results/${2}_p_obj.plot
fi
}
Index: trunk/milena/sandbox/fabien/igr/seg3d.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/seg3d.cc (revision 3481)
+++ trunk/milena/sandbox/fabien/igr/seg3d.cc (revision 3482)
@@ -36,7 +36,22 @@
label_16 nlabels;
image3d<int_u12> ima;
io::dicom::load(ima, argv[1]);
- io::dump::save(igr_seg(ima, c6(), nlabels), "result.dump");
+
+ image3d<bool> ima_thres;
+ initialize(ima_thres, ima);
+ data::fill(ima_thres, false);
+ unsigned threshold_value = find_threshold_value(ima, c6());
+ std::cout << "double threshold value = " << threshold_value << std::endl;
+ data::fill((ima_thres | pw::value(ima) < pw::cst(threshold_value)).rw(), true);
+
+ io::dump::save(ima_thres, "result_double.dump");
+
+ data::fill(ima_thres, false);
+ threshold_value = find_threshold_mean(ima, c6());
+ std::cout << " deviation threshold value = " << threshold_value << std::endl;
+ data::fill((ima_thres | pw::value(ima) < pw::cst(threshold_value)).rw(), true);
+
+ io::dump::save(ima_thres, "result_deviation.dump");
return 0;
}
Index: trunk/milena/sandbox/fabien/igr/launch3d.sh
===================================================================
--- trunk/milena/sandbox/fabien/igr/launch3d.sh (revision 3481)
+++ trunk/milena/sandbox/fabien/igr/launch3d.sh (revision 3482)
@@ -3,7 +3,8 @@
process_file ()
{
./seg3d $1
- ../bin/dump2pbm result.dump results/${2}_06_result.pbm
+ ../bin/dump2pbm result_double.dump results/${2}_06_result_double.pbm
+ ../bin/dump2pbm result_deviation.dump results/${2}_07_result_deviation.pbm
../bin/dump2pbm bg.dump results/${2}_01_bg.pbm
../bin/dump2pbm obj.dump results/${2}_03_obj.pbm
@@ -11,12 +12,15 @@
../bin/dump2pbm bg_closed.dump results/${2}_02_bg_closed.pbm
../bin/dump2pbm obj_closed.dump results/${2}_04_obj_closed.pbm
-#../bin/dump2ppm regions_color.dump results/${2}_05_colors.ppm
+ ../bin/dump2ppm regions_color.dump results/${2}_05_regions_colors.ppm
rm *.dump
- mv bg_histo_norm.plot results/${2}_bg.plot
- mv obj_histo_norm.plot results/${2}_obj.plot
+ mv histo.plot results/${2}.plot
+ mv bg_histo.plot results/${2}_bg.plot
+ mv obj_histo.plot results/${2}_obj.plot
+ mv bg_histo_norm.plot results/${2}_p_bg.plot
+ mv obj_histo_norm.plot results/${2}_p_obj.plot
}
process_file "/Users/HiSoKa/Work/IGR/souris18/irm/IM_0052.dcm" "52"
Index: trunk/milena/sandbox/fabien/igr/Makefile
===================================================================
--- trunk/milena/sandbox/fabien/igr/Makefile (revision 3481)
+++ trunk/milena/sandbox/fabien/igr/Makefile (revision 3482)
@@ -16,5 +16,11 @@
3d: seg_vol_irm.hh seg3d.cc
g++ -I../../../ ${DICOM_INC} ${DICOM_LIB} ${CXXFLAGS} seg3d.cc -o seg3d
+grad: grad_clo_and_wshd.cc
+ g++ -I../../../ ${DICOM_INC} ${DICOM_LIB} ${CXXFLAGS} $^ -o grad_clo
+
+wst: wst_rag.cc
+ g++ -I../../../ ${DICOM_INC} ${DICOM_LIB} ${CXXFLAGS} $^ -o wst_rag
+
clean:
rm -rf *.dump *.p?m *.plot *.log *.csv
Index: trunk/milena/sandbox/fabien/TODO
===================================================================
--- trunk/milena/sandbox/fabien/TODO (revision 3481)
+++ trunk/milena/sandbox/fabien/TODO (revision 3482)
@@ -9,5 +9,14 @@
[X] Create binaries
[X] Create scripts shell
-[ ] Check standard deviation
-
+[X] Generate color images for regions
+[X] Generate histograms (normal, bg, obj, p_bg, p_obj)
+[ ] Test processing chain on US
+[X] Create README file for special images
+[ ] Implement watershed
+[X] Create tool for dicom mask
+[X] Check conversion for mask (everything except int_u12(0))
+[ ] Extract ROI (projection or fill holes)
+[ ] Create routine for region colors
+[ ] Create dicom2dump (2d, 3d, int_u8, int_u12)
+[ ] After threshold, take biggest object and then erode, dilate
Index: trunk/milena/sandbox/fabien/bin/dicom2dump.cc
===================================================================
--- trunk/milena/sandbox/fabien/bin/dicom2dump.cc (revision 0)
+++ trunk/milena/sandbox/fabien/bin/dicom2dump.cc (revision 3482)
@@ -0,0 +1,32 @@
+#include <mln/core/concept/image.hh>
+#include <mln/core/image/image3d.hh>
+
+#include <mln/value/int_u12.hh>
+#include <mln/io/dicom/load.hh>
+#include <mln/io/dump/save.hh>
+
+
+
+int usage(char* argv[])
+{
+ std::cerr << "usage: " << argv[0] << " input.dcm output.dump" << std::endl;
+ std::cerr << "\t work for 3D images encoded in int_u12" << std::endl;
+ return 1;
+}
+
+
+
+int main(int argc, char* argv[])
+{
+ using namespace mln;
+ using value::int_u12;
+
+ if (argc != 3)
+ return usage(argv);
+
+ image3d<int_u12> ima;
+ io::dicom::load(ima, argv[1]);
+ io::dump::save(ima, argv[2]);
+
+ return 0;
+}
Index: trunk/milena/sandbox/fabien/bin/dicom_mask.cc
===================================================================
--- trunk/milena/sandbox/fabien/bin/dicom_mask.cc (revision 0)
+++ trunk/milena/sandbox/fabien/bin/dicom_mask.cc (revision 3482)
@@ -0,0 +1,38 @@
+#include <mln/core/concept/image.hh>
+#include <mln/core/image/image2d.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/io/dicom/load.hh>
+#include <mln/io/pbm/save.hh>
+
+#include <mln/literal/colors.hh>
+
+#include <mln/level/transform.hh>
+#include <mln/fun/v2b/threshold.hh>
+
+#include <mln/data/fill.hh>
+#include <mln/pw/all.hh>
+
+
+void usage(char* argv[])
+{
+ std::cerr << "usage: " << argv[0] << " input.dcm output.pbm" << std::endl;
+ abort();
+}
+
+
+
+int main(int argc, char* argv[])
+{
+ using namespace mln;
+ using value::int_u8;
+
+ if (argc != 3)
+ usage(argv);
+
+ image2d<int_u8> input;
+ io::dicom::load(input, argv[1]);
+
+ image2d<bool> ima = level::transform(input, fun::v2b::threshold<int_u8>(1));
+ io::pbm::save(ima, argv[2]);
+}
Index: trunk/milena/sandbox/fabien/bin/Makefile
===================================================================
--- trunk/milena/sandbox/fabien/bin/Makefile (revision 0)
+++ trunk/milena/sandbox/fabien/bin/Makefile (revision 3482)
@@ -0,0 +1,23 @@
+GDCM_SRC_DIR = /Users/HiSoKa/Downloads/gdcm-2.0.10
+GDCM_BIN_DIR = /Users/HiSoKa/Downloads/gdcmbin
+
+DICOM_INC = -I${GDCM_SRC_DIR}/Source/Common/ \
+ -I${GDCM_BIN_DIR}/Source/Common/ \
+ -I${GDCM_SRC_DIR}/Source/DataDictionary/ \
+ -I${GDCM_SRC_DIR}/Source/MediaStorageAndFileFormat/ \
+ -I${GDCM_SRC_DIR}/Source/DataStructureAndEncodingDefinition/
+
+# "-framework CoreFoundation" is a Mac OS X specific flag
+DICOM_LIB = -L${GDCM_BIN_DIR}/bin \
+ -lgdcmCommon -lgdcmDICT -lgdcmDSED -lgdcmIOD -lgdcmMSFF -lgdcmexpat -lgdcmjpeg12 -lgdcmjpeg16 -lgdcmjpeg8 -lgdcmopenjpeg -lgdcmuuid -lgdcmzlib \
+ -framework CoreFoundation
+
+CXXFLAGS = -DNDEBUG -O1
+
+all: mask dump
+
+mask: dicom_mask.cc
+ g++ -I../../../ ${DICOM_INC} ${DICOM_LIB} ${CXXFLAGS} $^ -o dicom_mask
+
+dump: dicom2dump.cc
+ g++ -I../../../ ${DICOM_INC} ${DICOM_LIB} ${CXXFLAGS} $^ -o dicom2dump
1
0
05 Mar '09
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add fastest version for thick front distance transform.
* mln/core/concept/weighted_window.hh
(mln_is_simple_weighted_window): New.
* sandbox/folio/distance_front_new.hh: Copy to and rename as...
* mln/canvas/distance_front.hh: ...this.
Update doc.
(distance_front_dispatch): Fix missing test.
canvas/distance_front.hh | 10 ++++++----
core/concept/weighted_window.hh | 10 ++++++++--
2 files changed, 14 insertions(+), 6 deletions(-)
Index: mln/core/concept/weighted_window.hh
--- mln/core/concept/weighted_window.hh (revision 3480)
+++ mln/core/concept/weighted_window.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
@@ -40,6 +40,12 @@
# include <mln/trait/windows.hh>
+
+# define mln_is_simple_weighted_window(W) \
+ mln_is_simple_window(typename W::window)
+
+
+
namespace mln
{
Index: mln/canvas/distance_front.hh
--- mln/canvas/distance_front.hh (revision 3480)
+++ mln/canvas/distance_front.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 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
@@ -30,7 +31,7 @@
/// \file mln/canvas/distance_front.hh
///
-/// Discrete distance canvas by front propagation.
+/// Canvas of discrete distance computation by thick front propagation.
# include <vector>
# include <mln/core/concept/image.hh>
@@ -47,7 +48,7 @@
namespace canvas
{
- /// Discrete front distance canvas.
+ /// Canvas of discrete distance computation by thick front propagation.
template <typename I,
typename N, typename W, typename D,
typename F>
@@ -360,7 +361,6 @@
D max, F& functor)
{
return impl::distance_front_fastest(input, nbh, w_win, max, functor);
- // return impl::generic::distance_front(input, nbh, w_win, max, functor);
}
template <typename I,
@@ -377,6 +377,8 @@
trait::image::speed::fastest)::value
&&
mln_is_simple_neighborhood(N)::value
+ &&
+ mln_is_simple_weighted_window(W)::value
};
return distance_front_dispatch(metal::bool_<test>(),
input, nbh, w_win, max, functor);
Property changes on: mln/canvas/distance_front.hh
___________________________________________________________________
Added: svn:mergeinfo
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix fastest distance computation.
* folio/distance_front.cc (main): Remove echo.
Test equality between generic and fastest results.
* folio/distance_front_new.hh
(distance_front_fastest): Fix erroneous line moves.
distance_front.cc | 6 ++++--
distance_front_new.hh | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
Index: folio/distance_front.cc
--- folio/distance_front.cc (revision 3479)
+++ folio/distance_front.cc (working copy)
@@ -38,6 +38,7 @@
#include <mln/data/fill.hh>
#include <mln/debug/println.hh>
#include <mln/opt/at.hh>
+#include <mln/level/compare.hh>
# include <mln/transform/internal/distance_functor.hh>
# include "distance_front_new.hh"
@@ -74,13 +75,14 @@
w_win,
dmax,
f);
- debug::println("ref", ref);
+ // debug::println("ref", ref);
output = canvas::impl::distance_front_fastest(input,
nbh,
w_win,
dmax,
f);
- debug::println("output", output);
+ // debug::println("output", output);
+ mln_invariant(output == ref);
}
Index: folio/distance_front_new.hh
--- folio/distance_front_new.hh (revision 3479)
+++ folio/distance_front_new.hh (working copy)
@@ -316,10 +316,10 @@
}
}
}
+ }
bucket_size -= bucket_d.size();
bucket_d.clear();
}
- }
} // end of Propagation.
trace::exiting("canvas::impl::distance_front_fastest");
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Complete Etienne's work.
* folio/distance_front.cc: New.
* folio/distance_front_new.hh: Make it compile.
Fix missing work.
distance_front.cc | 38 ++++++++++++++++++++++++------
distance_front_new.hh | 63 ++++++++++++++++++++++++++------------------------
2 files changed, 65 insertions(+), 36 deletions(-)
Index: folio/distance_front.cc
--- folio/distance_front.cc (revision 3478)
+++ folio/distance_front.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 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
@@ -29,6 +30,7 @@
///
/// Test on mln::transform::distance_front.
+#include <mln/core/var.hh>
#include <mln/core/image/image2d.hh>
#include <mln/core/alias/neighb2d.hh>
#include <mln/make/w_window2d_int.hh>
@@ -37,7 +39,8 @@
#include <mln/debug/println.hh>
#include <mln/opt/at.hh>
-#include <mln/transform/distance_front.hh>
+# include <mln/transform/internal/distance_functor.hh>
+# include "distance_front_new.hh"
int main()
@@ -45,18 +48,39 @@
using namespace mln;
using value::int_u8;
- image2d<bool> input(9, 9);
+ typedef image2d<bool> I;
+
+ I input(9, 9);
data::fill(input, false);
opt::at(input, 4, 4) = true;
+
+ int_u8 dmax = 18;
+ mln_VAR(nbh, c4());
+
int ws[] = { 0, 9, 0, 9, 0,
9, 6, 4, 6, 9,
0, 4, 0, 4, 0,
9, 6, 4, 6, 9,
0, 9, 0, 9, 0 };
+ mln_VAR(w_win, make::w_window2d_int(ws));
+
+
+ transform::internal::distance_functor<I> f;
+ image2d<int_u8> ref, output;
+
+ ref = canvas::impl::generic::distance_front(input,
+ nbh,
+ w_win,
+ dmax,
+ f);
+ debug::println("ref", ref);
+
+ output = canvas::impl::distance_front_fastest(input,
+ nbh,
+ w_win,
+ dmax,
+ f);
+ debug::println("output", output);
- image2d<int_u8> output = transform::distance_front(input,
- c4(), make::w_window2d_int(ws),
- int_u8(18));
- debug::println(output);
}
Index: folio/distance_front_new.hh
--- folio/distance_front_new.hh (revision 3478)
+++ folio/distance_front_new.hh (working copy)
@@ -38,11 +38,7 @@
# include <mln/core/concept/weighted_window.hh>
# include <mln/data/fill.hh>
# include <mln/accu/max.hh>
-
-//# include <mln/core/routine/duplicate.hh>
-//# include <mln/core/site_set/p_queue_fast.hh>
-//# include <queue>
-//# include <mln/extension/adjust_fill.hh>
+# include <mln/extension/adjust_fill.hh>
namespace mln
@@ -75,11 +71,14 @@
typename F>
void
distance_front_tests(const Image<I>& input_,
- const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win, D max,
+ const Neighborhood<N>& nbh_,
+ const Weighted_Window<W>& w_win_,
+ D max,
F& functor)
{
const I& input = exact(input_);
const N& nbh = exact(nbh_);
+ const W& w_win = exact(w_win_);
mln_precondition(input.is_valid());
mln_precondition(nbh.is_valid());
@@ -108,7 +107,9 @@
typename F>
mln_ch_value(I, D)
distance_front(const Image<I>& input_,
- const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win, D max,
+ const Neighborhood<N>& nbh_,
+ const Weighted_Window<W>& w_win_,
+ D max,
F& functor)
{
trace::entering("canvas::impl::generic::distance_front");
@@ -159,7 +160,7 @@
break;
}
}
- }
+ } // end of Initialization.
// Propagation.
{
@@ -199,11 +200,11 @@
bucket_size -= bucket_d.size();
bucket_d.clear();
}
+ } // end of Propagation.
trace::exiting("canvas::impl::generic::distance_front");
return dmap;
}
- }
} // of namespace mln::canvas::impl::generic
@@ -216,7 +217,8 @@
typename F>
mln_ch_value(I, D)
distance_front_fastest(const Image<I>& input_,
- const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win,
+ const Neighborhood<N>& nbh_,
+ const Weighted_Window<W>& w_win_,
D max, F& functor)
{
trace::entering("canvas::impl::distance_front_fastest");
@@ -225,12 +227,14 @@
const N& nbh = exact(nbh_);
const W& w_win = exact(w_win_);
-// mln_precondition(input.is_valid()); // ?x
-// mln_precondition(w_win.is_valid()); // ?x
- extension::adjust(input, w_win); // ?
+ mln_precondition(input.is_valid());
+ mln_precondition(w_win.is_valid());
-// typedef mln_site(I) P;
- typedef std::vector<unsigned> bucket_t;
+ // Handling w_win.
+ extension::adjust(input, w_win);
+ const unsigned n_ws = w_win.size();
+ util::array<int> dp = offsets_wrt(input, w_win.win());
+ mln_invariant(dp.nelements() == n_ws);
// Distance map.
mln_ch_value(I, D) dmap;
@@ -247,6 +251,7 @@
}
// Aux data.
+ typedef std::vector<unsigned> bucket_t;
std::vector<bucket_t> bucket(mod);
unsigned bucket_size = 0;
@@ -254,14 +259,14 @@
{
functor.init_(input); // <-- init
- // For the extension to be ignored: // ?
- extension::fill(input, true); // ?
- extension::fill(dmap, D(0)); // ?
+ // For the extension to be ignored:
+ extension::fill(input, true);
+ extension::fill(dmap, D(0));
mln_pixter(const I) p(input);
mln_nixter(const I, N) n(p, nbh);
for_all(p)
- if (functor.inqueue_p_wrt_input_p_(input(p))) // <-- inqueue_p_wrt_input_p
+ if (functor.inqueue_p_wrt_input_p_(p.val())) // <-- inqueue_p_wrt_input_p
{
dmap.element(p.offset()) = 0;
for_all(n)
@@ -272,14 +277,12 @@
break;
}
}
- }
+ } // end of Initialization.
// Propagation.
{
unsigned p;
- mln_qiter(W) q(w_win, p); // ?x-
-
for (unsigned d = 0; bucket_size != 0; ++d)
{
bucket_t& bucket_d = bucket[d % mod];
@@ -298,15 +301,16 @@
// p has already been processed, having a distance less than d.
continue;
- for_all(q)
+ for (unsigned i = 0; i < n_ws; ++i)
{
- if (dmap.domain().has(q) && dmap(q) > d)
+ unsigned q = p + dp[i];
+ if (dmap.element(q) > d)
{
- unsigned d_ = d + q.w();
- if (d_ < dmap(q))
+ unsigned d_ = d + w_win.w(i);
+ if (d_ < dmap.element(q))
{
- dmap(q) = d_;
- functor.process_(dmap.element(p), q); // <- process
+ dmap.element(q) = d_;
+ functor.process_(p, q); // <- process
bucket[d_ % mod].push_back(q);
++bucket_size;
}
@@ -315,11 +319,12 @@
bucket_size -= bucket_d.size();
bucket_d.clear();
}
+ }
+ } // end of Propagation.
trace::exiting("canvas::impl::distance_front_fastest");
return dmap;
}
- }
} // of namespace mln::canvas::impl
1
0
05 Mar '09
Etienne FOLIO wrote:
> URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
>
> ChangeLog:
> 2009-03-04 Etienne FOLIO <folio(a)lrde.epita.fr>
>
> New fast front propagation.
> * sandbox/folio/distance_front_new.hh: New fast front propagation
> (not tested).
> ...
règles de base :
- utiliser un outil qui gère l'indentation et signale les
blocs non balancés (genre, il manque un '{' ou '}')
- ne pas régresser quand on récupère du code
(genre : apparition d'une erreur de compil dans du code
copié-collé de mln et qui ne devait pas être modifié)
- commettre les changements
(genre, là, je suis obligé de refaire ce que l'on a
fait ensemble hier)
- noter dans un cahier les infos que je vous transmets
(genre : pour m'éviter de vous ré-expliquer votre sujet
de séminaire de l'année passée !!!)
pas content :-(
1
0
* mln/canvas/morpho/attribute_filter.hh: add a missing inline.
* mln/registration/icp.hh: fix compilation issues.
* tests/registration/registration.cc: enlarge the closest_point image
bbox.
* tests/transform/bench_closest_point_geodesic.cc: Update call to
distance_and_closest_point_geodesic.
* tests/transform/distance_and_closest_point_geodesic.cc: fix
reference resut.
---
milena/ChangeLog | 17 +++++++++++++++++
milena/mln/canvas/morpho/attribute_filter.hh | 1 +
milena/mln/registration/icp.hh | 4 ++--
milena/tests/registration/registration.cc | 3 +--
.../transform/bench_closest_point_geodesic.cc | 13 ++++++-------
.../distance_and_closest_point_geodesic.cc | 19 ++++++++++---------
6 files changed, 37 insertions(+), 20 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 8cc165f..c8d86e9 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,20 @@
+2009-03-05 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Fix tests.
+
+ * mln/canvas/morpho/attribute_filter.hh: add a missing inline.
+
+ * mln/registration/icp.hh: fix compilation issues.
+
+ * tests/registration/registration.cc: enlarge the closest_point image
+ bbox.
+
+ * tests/transform/bench_closest_point_geodesic.cc: Update call to
+ distance_and_closest_point_geodesic.
+
+ * tests/transform/distance_and_closest_point_geodesic.cc: fix
+ reference resut.
+
2009-03-04 Etienne FOLIO <folio(a)lrde.epita.fr>
New fast front propagation.
diff --git a/milena/mln/canvas/morpho/attribute_filter.hh b/milena/mln/canvas/morpho/attribute_filter.hh
index 298c236..4d21f9c 100644
--- a/milena/mln/canvas/morpho/attribute_filter.hh
+++ b/milena/mln/canvas/morpho/attribute_filter.hh
@@ -446,6 +446,7 @@ namespace mln
// Facade.
template <typename I, typename N, typename A>
+ inline
mln_concrete(I)
attribute_filter(const Image<I>& input,
const Neighborhood<N>& nbh,
diff --git a/milena/mln/registration/icp.hh b/milena/mln/registration/icp.hh
index 6adc0b3..17eebff 100644
--- a/milena/mln/registration/icp.hh
+++ b/milena/mln/registration/icp.hh
@@ -197,8 +197,8 @@ namespace mln
mln_piter(I) pi(cp_ima_.domain());
for_all(pi)
{
- debug(pi) = debug(cp_ima_(pi));
- debug2(pi) = debug2(cp_ima_(pi));
+ debug(pi) = debug(X[cp_ima_(pi)]);
+ debug2(pi) = debug2(X[cp_ima_(pi)]);
}
io::pbm::save(slice(debug2,0), "debug2-b.ppm");
diff --git a/milena/tests/registration/registration.cc b/milena/tests/registration/registration.cc
index 9433f5a..16d23c4 100644
--- a/milena/tests/registration/registration.cc
+++ b/milena/tests/registration/registration.cc
@@ -56,8 +56,7 @@ int main()
arr_t arr2 = convert::to<arr_t>(img2);
box3d bbox = img2.bbox();
- bbox.enlarge(1, 10);
- bbox.enlarge(2, 10);
+ bbox.enlarge(10);
registration::registration1(bbox, arr1, arr2);
//FIXME: Auto test result
}
diff --git a/milena/tests/transform/bench_closest_point_geodesic.cc b/milena/tests/transform/bench_closest_point_geodesic.cc
index 06a6b44..b92b690 100644
--- a/milena/tests/transform/bench_closest_point_geodesic.cc
+++ b/milena/tests/transform/bench_closest_point_geodesic.cc
@@ -35,9 +35,9 @@
#include <mln/core/alias/neighb3d.hh>
#include <mln/data/fill.hh>
#include <mln/opt/at.hh>
-#include <mln/transform/closest_point_geodesic.hh>
+#include <mln/transform/distance_and_closest_point_geodesic.hh>
#include <mln/value/int_u8.hh>
-
+#include <mln/util/couple.hh>
int main()
{
@@ -56,9 +56,8 @@ int main()
std::rand() % nrows,
std::rand() % ncols) = true;
- trace::quiet = false;
-
- image3d<point3d> output = transform::closest_point_geodesic(input,
- c6(),
- mln_max(unsigned));
+ util::couple<image3d<unsigned>, image3d<point3d> > output =
+ transform::distance_and_closest_point_geodesic(input,
+ c6(),
+ mln_max(unsigned));
}
diff --git a/milena/tests/transform/distance_and_closest_point_geodesic.cc b/milena/tests/transform/distance_and_closest_point_geodesic.cc
index d3544ab..368256b 100644
--- a/milena/tests/transform/distance_and_closest_point_geodesic.cc
+++ b/milena/tests/transform/distance_and_closest_point_geodesic.cc
@@ -51,15 +51,16 @@ unsigned dmap_ref[] = { 4, 4, 4, 3, 2, 3, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4 };
-unsigned cp_idx_ref[] = { 0 , 0 , 82 , 82 , 82 , 82, 82, 0 , 0 ,
- 0 , 82 , 82 , 82 , 82 , 82, 82, 82, 0 ,
- 110, 82 , 82 , 82 , 82 , 82, 82, 82, 82,
- 110, 110, 110, 82 , 82 , 82, 82, 82, 0 ,
- 110, 110, 110, 110, 82 , 82, 82, 0 , 0 ,
- 110, 110, 110, 110, 82 , 82, 0 , 0 , 0 ,
- 110, 110, 110, 110, 110, 0 , 0 , 0 , 0 ,
- 0 , 110, 110, 110, 0 , 0 , 0 , 0 , 0 ,
- 0 , 0 , 110, 0 , 0 , 0 , 0 , 0 , 0 };
+unsigned cp_idx_ref[] = { 2, 2, 0, 0, 0, 0, 0, 2, 2,
+ 2, 0, 0, 0, 0, 0, 0, 0, 2,
+ 1, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 0, 0, 0, 0, 0, 2,
+ 1, 1, 1, 1, 0, 0, 0, 2, 2,
+ 1, 1, 1, 1, 0, 0, 2, 2, 2,
+ 1, 1, 1, 1, 1, 2, 2, 2, 2,
+ 2, 1, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 1, 2, 2, 2, 2, 2, 2 };
+
int main()
{
--
1.5.6.5
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-03-04 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Add methods to check attribute computing.
* edwin/tree/propagate.hh,
* edwin/tree/tree.cc: Fix bugs and add check function.
* edwin/tree/routines.hh: Some utils about tree manipulation.
---
Makefile | 14 +--
propagate.hh | 2
routines.hh | 109 +++++++++++++++++++++++++++++++
tree.cc | 207 +++++++++++++++++++++++++++++++----------------------------
4 files changed, 227 insertions(+), 105 deletions(-)
Index: trunk/milena/sandbox/edwin/tree/propagate.hh
===================================================================
--- trunk/milena/sandbox/edwin/tree/propagate.hh (revision 3476)
+++ trunk/milena/sandbox/edwin/tree/propagate.hh (revision 3477)
@@ -62,7 +62,7 @@
{
mln_bkd_piter(T) p(t.domain());
for_all(p)
- if (a(t.parent(p)) == v)
+ if (t.is_a_node(p) && a(t.parent(p)) == v)
{
mln_assertion(t.is_a_node(t.parent(p)));
a(p) = a(t.parent(p));
Index: trunk/milena/sandbox/edwin/tree/tree.cc
===================================================================
--- trunk/milena/sandbox/edwin/tree/tree.cc (revision 3476)
+++ trunk/milena/sandbox/edwin/tree/tree.cc (revision 3477)
@@ -1,4 +1,3 @@
-
#include <mln/core/var.hh>
#include <mln/core/image/image2d.hh>
#include <mln/core/alias/neighb2d.hh>
@@ -12,149 +11,167 @@
#include <mln/io/pbm/save.hh>
#include <mln/level/sort_psites.hh>
-#include <mln/morpho/elementary/gradient.hh>
#include <mln/morpho/tree/data.hh>
#include <mln/morpho/tree/compute_attribute_image.hh>
+
#include <mln/morpho/attribute/card.hh>
-#include "../attributes/occupation.hh"
-#include "propagate.hh"
+#include <mln/morpho/attribute/sharpness.hh>
+// to check:
+#include <mln/labeling/blobs.hh>
+#include <mln/labeling/compute.hh>
+#include <mln/accu/count.hh>
#include <mln/debug/println.hh>
+#include <../../theo/color/change_attributes.hh>
+//-----------------
+
+
+#include <string>
+
+#include "propagate.hh"
+#include "routines.hh"
namespace mln
{
- template <typename T, typename A>
+ /// Structure to simplify filtering using min tree.
+ template <typename I>
+ struct treefilter : Object< treefilter<I> >
+ {
+ typedef p_array< mln_site(I) > S;
+ typedef morpho::tree::data<I,S> tree_t;
+
+ /// Constructor: Make the min tree based on the image \p f_, then
+ /// performs calculus using \p a_ attribute. To finish, it filters
+ /// tree's nodes which values are in [lambda1, lambda2] set.
+ template <typename A>
+ treefilter(Image<I>& f_,
+ Accumulator<A> a_,
+ double lambda1 = mln_min(double),
+ double lambda2 = mln_max(double));
+
+ /// Get the min tree performed.
+ tree_t& tree() { return tree_; };
+
+ /// Get the boolean image got after filtering.
+ mln_ch_value(I, bool)& img() {return img_; };
+
+ private:
+ S sorted_sites_;
+ tree_t tree_;
+ mln_ch_value(I, bool) img_;
+ };
+
+
+ template <typename I>
+ template <typename A>
inline
- void
- sample(const T& t, const A& a, int echo)
+ treefilter<I>::treefilter(Image<I>& f_,
+ Accumulator<A> a_,
+ double lambda1,
+ double lambda2)
+ : sorted_sites_(level::sort_psites_decreasing(exact(f_))),
+ tree_(exact(f_), sorted_sites_, c4())
{
- A aa;
- initialize(aa, a);
- data::fill(aa, false); // 'aa' is false /a priori/.
-
- typedef typename T::nodes_t N;
- mln_fwd_piter(N) n(t.nodes());
- for_all(n)
- // We only keep "highest" nodes at 'true' => largest component.
- // aa(n) = (a(n) == true && a(t.parent(n)) == false);
- aa(n) = a(n);
-
- if (echo) io::pbm::save(aa, "before.pbm");
- if (echo > 1) debug::println("aa (before)", aa);
-
- back_propagate_subbranch(t, aa, true);
- if (echo > 1) debug::println("aa (After subbranch propagation)", aa);
- back_propagate_level(t, aa);
+ mln_VAR(a, morpho::tree::compute_attribute_image(a_, tree_));
- if (echo > 1) debug::println("aa (Final)", aa);
- io::pbm::save(aa, "out.pbm");
+ img_ = duplicate((pw::cst(lambda1) < pw::value(a) &&
+ pw::value(a) < pw::cst(lambda2))
+ | a.domain());
+ debug::println("attribut", a);
}
+// template <typename T>
+// inline
+// float
+// find_treshold(const T& t)
+// {
+// mln_bkd_piter(T) = p(t.domain());
-} // mln
+// for_all(p)
+// if (t.is_a_node(p))
+// {
+// if
-using namespace mln;
-int echo = 0;
+// }
+// }
template <typename I, typename A>
-inline
-void
-create_tree_and_compute(Image<I>& f_, Accumulator<A> a_, float lambda, float lambda2 = mln_max(float))
+ void filtercheck(const Image<I>& img, const Meta_Accumulator<A>& a)
{
- using value::int_u8;
-
- I f = exact(f_);
-
- typedef p_array< mln_site(I) > S;
- S s = level::sort_psites_decreasing(f);
- typedef morpho::tree::data<I,S> tree_t;
- tree_t t(f, s, c4());
-
- mln_VAR(a, morpho::tree::compute_attribute_image(a_, t));
+ using value::label_8;
+ label_8 n;
+ util::array<unsigned int> counts;
- if (echo > 1)
+ debug::println("binaire:", img);
+ mln_VAR(lbl, labeling::blobs(img, c4(), n));
+ debug::println("blob:", lbl);
+ counts = labeling::compute(a, lbl, n);
+ for (unsigned i = 0; i < counts.nelements(); i++)
{
- debug::println("parent imagee", t.parent_image());
- debug::println("a", a);
- debug::println("a | nodes", a | t.nodes());
+ std::cout << "counts[" << i << "]: " << counts[i]
+ << std::endl;
}
-
- std::cout << lambda;
- image2d<bool> b = duplicate((pw::cst(lambda) < pw::value(a) && pw::value(a) < pw::cst(lambda2)) | a.domain());
- sample(t, b, echo);
}
+} // end of namespace mln
+
+
void usage(char* argv[])
{
- std::cerr << "usage: " << argv[0] << " input.pgm echo lambda1 lamda2" << std::endl;
- std::cerr << "\techo:\t0 (none)" << std::endl
- << "\t\t1 (img output)" << std::endl
- << "\t\t2 (debug)" << std::endl;
+ std::cerr << "usage: " << argv[0] << " input.pgm accumulator lambda1 [lambda2]"
+ << std::endl;
abort();
}
+
int main(int argc, char* argv[])
{
+ using namespace mln;
using value::int_u8;
- mln_VAR(nbh, c4());
+ typedef image2d<int_u8> I;
+
+ float lambda1;
+ float lambda2;
+ I input;
if (argc < 4)
usage(argv);
- echo = std::atoi(argv[2]);
- float lambda1 = atof(argv[3]);
- float lambda2 = (argc == 5) ? atof(argv[4]) : mln_max(float);
-
- typedef image2d<int_u8> I;
-
- I input;
io::pgm::load(input, argv[1]);
- if (echo > 1) debug::println("input", input);
- I f = input;
- // I f = morpho::elementary::gradient(input, nbh);
- if (echo > 1) debug::println("f", f);
-
- // test de volume
- typedef image1d<int> IM;
- IM img(6);
- morpho::attribute::volume<IM> accu;
- img.element(0) = 50;
- img.element(1) = 50;
- img.element(2) = 40;
- img.element(3) = 40;
- img.element(4) = 20;
- img.element(5) = 20;
+ lambda1 = atof(argv[3]);
+ lambda2 = (argc == 5) ? atof(argv[4]) : mln_max(float);
- mln_piter_(image1d<int>) p(img.domain());
+ std::string s(argv[2]);
+ treefilter<I>* f = 0;
+ if (s == "card")
+ f = new treefilter<I>(input, morpho::attribute::card<I>(), lambda1, lambda2);
+ else if (s == "sharpness")
+ f = new treefilter<I>(input, morpho::attribute::sharpness<I>(), lambda1, lambda2);
+ else
+ usage(argv);
- int tab[6] = { 50, 50, 40, 40, 20, 20 };
+ back_propagate_subbranch(f->tree(), f->img() ,true);
+ back_propagate_level(f->tree(), f->img());
- for (int i = 0; i < 6; i++)
- {
- accu.take(tab[i]);
- std::cout << "(" << tab[i] << "," << accu.to_result() << "):";
- }
- std::cout << "Volume:" << accu.to_result() << std::endl;
+ filtercheck(f->img(), accu::meta::count());
- accu.init ();
- for (int i = 5; i >= 0; i--)
- {
- accu.take(tab[i]);
- std::cout << "(" << tab[i] << "," << accu.to_result() << "):";
- }
- std::cout << "Volume:" << accu.to_result() << std::endl;
- //create_tree_and_compute(img, morpho::attribute::volume<I2>());
- //
+ util::array< mln_psite_(I) > counts;
+ counts = morpho::tree::get_first_nodes(f->img(), f->tree());
+ for (unsigned i = 0; i < counts.nelements(); i++)
+ std::cout << "counts[" << i << "]: " << counts[i] << std::endl;
- create_tree_and_compute(f, morpho::attribute::occupation<I>(), lambda1, lambda2);
+ mln_VAR(a, morpho::tree::compute_attribute_image(morpho::attribute::card<I>(), f->tree()));
+ display_tree_attributes(f->tree(), a);
+ io::pbm::save(f->img(), "out.pbm");
+ delete f;
}
Index: trunk/milena/sandbox/edwin/tree/routines.hh
===================================================================
--- trunk/milena/sandbox/edwin/tree/routines.hh (revision 0)
+++ trunk/milena/sandbox/edwin/tree/routines.hh (revision 3477)
@@ -0,0 +1,109 @@
+// 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
+// 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 ROUTINES_HH_
+# define ROUTINES_HH_
+
+# include <mln/morpho/tree/data.hh>
+# include <mln/core/concept/image.hh>
+# include <mln/data/fill.hh>
+
+namespace mln {
+ namespace morpho {
+ namespace tree {
+
+ template <typename I, typename T>
+ util::array< mln_psite(I) >
+ get_first_nodes(const Image<I>& img_, const T& tree)
+ {
+ I bin = exact(img_);
+ mln_ch_value(I, bool) deja_vu;
+ util::array< mln_psite(I) > fnodes;
+
+ initialize(deja_vu, img_);
+ data::fill(deja_vu, false);
+
+ bool can_break = false;
+ mln_bkd_piter(T) p(tree.domain());
+ for_all(p)
+ {
+ if (tree.is_a_node(p) && bin(p) && bin(t.parent(p))
+ {
+ fnodes.append(p);
+ }
+ }
+
+ // else if (can_break)
+// {
+// std::cout << p << std::endl;
+// break;
+// }
+
+ return fnodes;
+ }
+
+ }
+ }
+
+// namespace debug {
+
+// template <typename T, typename I>
+// void
+// println(const T& t, const Image<I> f_)
+// {
+// //theo's code
+// typedef mln_site(I) P;
+// I f = exact(f_);
+
+// mln_ch_value(I, bool) deja_vu;
+// initialize(deja_vu, f);
+// data::fill(deja_vu, false);
+
+// typedef typename T::nodes_t nodes_t;
+// mln_fwd_piter(T) p(t.nodes());
+// for_all(p)
+// {
+// if (deja_vu(p))
+// continue;
+// P e = p;
+// do
+// {
+// std::cout << f(e) << ':' << e << " -> ";
+// deja_vu(e) = true;
+// e = t.parent(e);
+// }
+// while (! deja_vu(e));
+// std::cout << f(e) << ':' << e << std::endl;
+// }
+// std::cout << std::endl;
+// }
+// }
+}
+
+
+#endif /* !ROUTINES_HH_ */
Index: trunk/milena/sandbox/edwin/tree/Makefile
===================================================================
--- trunk/milena/sandbox/edwin/tree/Makefile (revision 3476)
+++ trunk/milena/sandbox/edwin/tree/Makefile (revision 3477)
@@ -1,28 +1,25 @@
-TARGET=a.out
+TARGET=tree
SRC=tree.cc
OBJS=${SRC:.cc=.o}
-OLENADIR=../../../..
+OLENADIR=$(MLN_DIR)/..
MILENADIR=$(OLENADIR)/milena
CXXFLAGS=-I$(MILENADIR) -I./
-CXXFLAGS += "-DNDEBUG -O1"
-
+CXXFLAGS += -DNDEBUG -O1
CXX=g++
LD=g++
LDFLAGS=
all: clean $(TARGET)
+ #chmod +x exo2.sh
+ #./exo2.sh
$(TARGET): $(OBJS) $(SRC)
$(LD) $(LDFLAGS) -o $@ $(OBJS)
-
-$(REF): $(OBJS_REF) $(SRC_REF)
- $(LD) $(LDFLAGS) -o $@ $(OBJS_REF)
-
%.o: %.cc
$(CXX) $(CXXFLAGS) -c $<
@@ -30,4 +27,6 @@
$(CXX) $(CXXFLAGS) -c $<
clean:
- rm -f *.o $(REF) $(TARGET)
\ No newline at end of file
+ rm -f *.o $(TARGET)
+ rm -f *.pbm
+ find -name "*.pgm" \! -regex ".*/affiche2?.pgm" -delete
\ No newline at end of file
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-03-04 Etienne FOLIO <folio(a)lrde.epita.fr>
New fast front propagation.
* sandbox/folio/distance_front_new.hh: New fast front propagation
(not tested).
---
distance_front_new.hh | 415 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 415 insertions(+)
Index: trunk/milena/sandbox/folio/distance_front_new.hh
===================================================================
--- trunk/milena/sandbox/folio/distance_front_new.hh (revision 0)
+++ trunk/milena/sandbox/folio/distance_front_new.hh (revision 3475)
@@ -0,0 +1,415 @@
+// 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
+// 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 MLN_CANVAS_DISTANCE_FRONT_HH
+# define MLN_CANVAS_DISTANCE_FRONT_HH
+
+/// \file mln/canvas/distance_front.hh
+///
+/// Discrete distance canvas by front propagation.
+
+# include <vector>
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/concept/weighted_window.hh>
+# include <mln/data/fill.hh>
+# include <mln/accu/max.hh>
+
+//# include <mln/core/routine/duplicate.hh>
+//# include <mln/core/site_set/p_queue_fast.hh>
+//# include <queue>
+//# include <mln/extension/adjust_fill.hh>
+
+
+namespace mln
+{
+
+ namespace canvas
+ {
+
+ /// Discrete front distance canvas.
+ template <typename I,
+ typename N, typename W, typename D,
+ typename F>
+ mln_ch_value(I, D)
+ distance_front(const Image<I>& input,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win, D max,
+ F& functor);
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // Tests.
+
+ namespace internal
+ {
+
+ template <typename I,
+ typename N, typename W, typename D,
+ typename F>
+ void
+ distance_front_tests(const Image<I>& input_,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win, D max,
+ F& functor)
+ {
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+
+ mln_precondition(input.is_valid());
+ mln_precondition(nbh.is_valid());
+
+ (void) input;
+ (void) nbh;
+ (void) max;
+ (void) functor;
+ }
+
+
+ } // of namespace mln::canvas::internal
+
+
+
+ // Implementations.
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+
+ template <typename I,
+ typename N, typename W, typename D,
+ typename F>
+ mln_ch_value(I, D)
+ distance_front(const Image<I>& input_,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win, D max,
+ F& functor)
+ {
+ trace::entering("canvas::impl::generic::distance_front");
+
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+ const W& w_win = exact(w_win_);
+
+ mln_precondition(input.is_valid());
+ mln_precondition(w_win.is_valid());
+
+ typedef mln_site(I) P;
+ typedef std::vector<P> bucket_t;
+
+ // Distance map.
+ mln_ch_value(I, D) dmap;
+ initialize(dmap, input);
+ data::fill(dmap, max);
+
+ // Mod determination.
+ unsigned mod;
+ {
+ accu::max<unsigned> m;
+ for (unsigned i = 0; i < w_win.size(); ++i)
+ m.take(w_win.w(i));
+ mod = unsigned(m) + 1;
+ }
+
+ // Aux data.
+ std::vector<bucket_t> bucket(mod);
+ unsigned bucket_size = 0;
+
+ // Initialization.
+ {
+ functor.init(input); // <-- init
+ mln_piter(I) p(input.domain());
+ mln_niter(N) n(nbh, p);
+ for_all(p)
+ if (functor.inqueue_p_wrt_input_p(input(p))) // <-- inqueue_p_wrt_input_p
+ {
+ dmap(p) = 0;
+ for_all(n)
+ if (input.domain().has(n) &&
+ functor.inqueue_p_wrt_input_n(input(n))) // <-- inqueue_p_wrt_input_n
+ {
+ bucket[0].push_back(p);
+ ++bucket_size;
+ break;
+ }
+ }
+ }
+
+ // Propagation.
+ {
+ P p;
+ mln_qiter(W) q(w_win, p);
+ for (unsigned d = 0; bucket_size != 0; ++d)
+ {
+ bucket_t& bucket_d = bucket[d % mod];
+ for (unsigned i = 0; i < bucket_d.size(); ++i)
+ {
+ p = bucket_d[i];
+
+ if (dmap(p) == max)
+ {
+ // Saturation so stop.
+ bucket_size = bucket_d.size(); // So at end bucket_size == 0.
+ break;
+ }
+
+ if (dmap(p) < d)
+ // p has already been processed, having a distance less than d.
+ continue;
+
+ for_all(q)
+ if (dmap.domain().has(q) && dmap(q) > d)
+ {
+ unsigned d_ = d + q.w();
+ if (d_ < dmap(q))
+ {
+ dmap(q) = d_;
+ functor.process(p, q); // <- process
+ bucket[d_ % mod].push_back(q);
+ ++bucket_size;
+ }
+ }
+ }
+ bucket_size -= bucket_d.size();
+ bucket_d.clear();
+ }
+
+ trace::exiting("canvas::impl::generic::distance_front");
+ return dmap;
+ }
+ }
+
+ } // of namespace mln::canvas::impl::generic
+
+
+
+ // Fastest version.
+
+ template <typename I,
+ typename N, typename W, typename D,
+ typename F>
+ mln_ch_value(I, D)
+ distance_front_fastest(const Image<I>& input_,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win,
+ D max, F& functor)
+ {
+ trace::entering("canvas::impl::distance_front_fastest");
+
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+ const W& w_win = exact(w_win_);
+
+// mln_precondition(input.is_valid()); // ?x
+// mln_precondition(w_win.is_valid()); // ?x
+ extension::adjust(input, w_win); // ?
+
+// typedef mln_site(I) P;
+ typedef std::vector<unsigned> bucket_t;
+
+ // Distance map.
+ mln_ch_value(I, D) dmap;
+ initialize(dmap, input);
+ data::fill(dmap, max);
+
+ // Mod determination.
+ unsigned mod;
+ {
+ accu::max<unsigned> m;
+ for (unsigned i = 0; i < w_win.size(); ++i)
+ m.take(w_win.w(i));
+ mod = unsigned(m) + 1;
+ }
+
+ // Aux data.
+ std::vector<bucket_t> bucket(mod);
+ unsigned bucket_size = 0;
+
+ // Initialization.
+ {
+ functor.init_(input); // <-- init
+
+ // For the extension to be ignored: // ?
+ extension::fill(input, true); // ?
+ extension::fill(dmap, D(0)); // ?
+
+ mln_pixter(const I) p(input);
+ mln_nixter(const I, N) n(p, nbh);
+ for_all(p)
+ if (functor.inqueue_p_wrt_input_p_(input(p))) // <-- inqueue_p_wrt_input_p
+ {
+ dmap.element(p.offset()) = 0;
+ for_all(n)
+ if (functor.inqueue_p_wrt_input_n_(n.val())) // <-- inqueue_p_wrt_input_n
+ {
+ bucket[0].push_back(p.offset());
+ ++bucket_size;
+ break;
+ }
+ }
+ }
+
+ // Propagation.
+ {
+ unsigned p;
+
+ mln_qiter(W) q(w_win, p); // ?x-
+
+ for (unsigned d = 0; bucket_size != 0; ++d)
+ {
+ bucket_t& bucket_d = bucket[d % mod];
+ for (unsigned i = 0; i < bucket_d.size(); ++i)
+ {
+ p = bucket_d[i];
+
+ if (dmap.element(p) == max)
+ {
+ // Saturation so stop.
+ bucket_size = bucket_d.size(); // So at end bucket_size == 0.
+ break;
+ }
+
+ if (dmap.element(p) < d)
+ // p has already been processed, having a distance less than d.
+ continue;
+
+ for_all(q)
+ {
+ if (dmap.domain().has(q) && dmap(q) > d)
+ {
+ unsigned d_ = d + q.w();
+ if (d_ < dmap(q))
+ {
+ dmap(q) = d_;
+ functor.process_(dmap.element(p), q); // <- process
+ bucket[d_ % mod].push_back(q);
+ ++bucket_size;
+ }
+ }
+ }
+ bucket_size -= bucket_d.size();
+ bucket_d.clear();
+ }
+
+ trace::exiting("canvas::impl::distance_front_fastest");
+ return dmap;
+ }
+ }
+
+
+ } // of namespace mln::canvas::impl
+
+
+
+ // Dispatch.
+
+ namespace internal
+ {
+
+ template <typename I,
+ typename N, typename W, typename D,
+ typename F>
+ inline
+ mln_ch_value(I, D)
+ distance_front_dispatch(metal::false_,
+ const Image<I>& input,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win,
+ D max, F& functor)
+ {
+ return impl::generic::distance_front(input, nbh, max, w_win, functor);
+ }
+
+ template <typename I,
+ typename N, typename W, typename D,
+ typename F>
+ inline
+ mln_ch_value(I, D)
+ distance_front_dispatch(metal::true_,
+ const Image<I>& input,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win,
+ D max, F& functor)
+ {
+ return impl::distance_front_fastest(input, nbh, w_win, max, functor);
+// return impl::generic::distance_front(input, nbh, w_win, max, functor);
+ }
+
+ template <typename I,
+ typename N, typename W, typename D,
+ typename F>
+ inline
+ mln_ch_value(I, D)
+ distance_front_dispatch(const Image<I>& input,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win,
+ D max, F& functor)
+ {
+ enum {
+ test = mlc_equal(mln_trait_image_speed(I),
+ trait::image::speed::fastest)::value
+ &&
+ mln_is_simple_neighborhood(N)::value
+ };
+ return distance_front_dispatch(metal::bool_<test>(),
+ input, nbh, w_win, max, functor);
+ }
+
+
+ } // of namespace mln::canvas::internal
+
+
+
+ // Facade.
+
+ template <typename I,
+ typename N, typename W, typename D,
+ typename F>
+ inline
+ mln_ch_value(I, D)
+ distance_front(const Image<I>& input,
+ const Neighborhood<N>& nbh, const Weighted_Window<W>& w_win,
+ D max, F& functor)
+ {
+ trace::entering("canvas::distance_front");
+
+ internal::distance_front_tests(input, nbh, w_win, max, functor);
+
+ mln_ch_value(I,D) output;
+ output = internal::distance_front_dispatch(input, nbh, w_win, max, functor);
+
+ trace::exiting("canvas::distance_front");
+ return output;
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::canvas
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CANVAS_DISTANCE_FRONT_HH
1
0