* morpho.ixx (instantiate_max_tree): New macro.
Call it...
(instantiate_morpho): ...here.
* python/max-tree.py: New test.
* python/Makefile.am (TESTS): Add max-tree.py.
---
swilena/ChangeLog | 10 ++++++
swilena/morpho.ixx | 18 +++++++++++
swilena/python/Makefile.am | 3 +-
swilena/python/{morpho-segm.py => max-tree.py} | 40 +++++++++++++----------
4 files changed, 53 insertions(+), 18 deletions(-)
copy swilena/python/{morpho-segm.py => max-tree.py} (53%)
diff --git a/swilena/ChangeLog b/swilena/ChangeLog
index b0145d8..9790b3f 100644
--- a/swilena/ChangeLog
+++ b/swilena/ChangeLog
@@ -1,5 +1,15 @@
2010-04-01 Roland Levillain <roland(a)lrde.epita.fr>
+ Wrap function mln::morpho::tree::max<I, N>.
+
+ * morpho.ixx (instantiate_max_tree): New macro.
+ Call it...
+ (instantiate_morpho): ...here.
+ * python/max-tree.py: New test.
+ * python/Makefile.am (TESTS): Add max-tree.py.
+
+2010-04-01 Roland Levillain <roland(a)lrde.epita.fr>
+
Add a Swilena wrapper for mln::image2d<mln::point2d>.
* image2d_point2d.i: New.
diff --git a/swilena/morpho.ixx b/swilena/morpho.ixx
index 7807694..d917ac0 100644
--- a/swilena/morpho.ixx
+++ b/swilena/morpho.ixx
@@ -166,6 +166,22 @@ namespace mln
%template(Name) mln::morpho::meyer_wst< L, I, N >;
%enddef
+/*-----------.
+| Max-tree. |
+`-----------*/
+
+%{
+#include "mln/morpho/tree/max.hh"
+%}
+
+%include "mln/morpho/tree/max.hh"
+
+%define instantiate_max_tree(Name, I, N)
+ // Explicit instantiation of this trait for the return type.
+ %template() mln::trait::ch_value< I, mln_psite(I) >;
+ %template(Name) mln::morpho::tree::max< I, N >;
+%enddef
+
/*-------------------------.
| Instantiate everything. |
`-------------------------*/
@@ -185,4 +201,6 @@ namespace mln
instantiate_opening_area(opening_area, I, N)
instantiate_meyer_wst(meyer_wst, mln_value(I), I, N)
+
+ instantiate_max_tree(max_tree, I, N)
%enddef
diff --git a/swilena/python/Makefile.am b/swilena/python/Makefile.am
index 71ca9e7..ea4b25d 100644
--- a/swilena/python/Makefile.am
+++ b/swilena/python/Makefile.am
@@ -339,7 +339,8 @@ $(srcdir)/run.stamp: $(RUN_IN)
# as `--python' to `run'.
TESTS = \
box2d-misc.py \
- image2d-misc.py morpho-fun.py morpho-segm.py dynamic-image2d-misc.py
+ image2d-misc.py morpho-fun.py morpho-segm.py max-tree.py \
+ dynamic-image2d-misc.py
EXTRA_DIST += $(TESTS)
diff --git a/swilena/python/morpho-segm.py b/swilena/python/max-tree.py
similarity index 53%
copy from swilena/python/morpho-segm.py
copy to swilena/python/max-tree.py
index 654aa95..0c5dd65 100644
--- a/swilena/python/morpho-segm.py
+++ b/swilena/python/max-tree.py
@@ -1,6 +1,6 @@
#! /usr/bin/env python
-# Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+# Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
#
# This file is part of Olena.
#
@@ -16,27 +16,33 @@
# You should have received a copy of the GNU General Public License
# along with Olena. If not, see <http://www.gnu.org/licenses/>.
-# \file python/morpho-segm.py
-# \brief Test on watershed transform-based segmentation.
+# \file python/max-tree.py
+# \brief Test on the max-tree.
import data
from swilena import *
-# Module alias.
+# Module aliases.
image = image2d_int_u8
+par_image = image2d_point2d
ima = image.load(data.lena)
+ima = image.image2d_int_u8(3, 3)
-# Gradient.
-gradient = image.gradient(ima, win_c4p())
-image.save(gradient, "gradient.pgm")
-# Area closing of the gradient.
-closed_gradient = image.closing_area(ima, c4(), 50)
-# Watershed transform.
-nbasins = int_u8()
-ws = image.meyer_wst (closed_gradient, c4(), nbasins)
-print nbasins
-image.save(ws, "segm.pgm")
-
-# FIXME: Also re-enable the naive segmentation with no gradient
-# simplification, and an output on an image2d<int_u32>.
+values = [5, 6, 6,
+ 8, 9, 9,
+ 8, 9, 9]
+
+v = values.__iter__()
+
+for p in ima.domain():
+ ima.set(p, int_u8(v.next()))
+image.println("ima =", ima)
+
+max_tree_parent = image.max_tree(ima, c4());
+# FIXME: Why can't we use
+#
+# image2d_point2d.println("max_tree_parent =", max_tree_parent)
+#
+# ?
+par_image.println(max_tree_parent)
--
1.5.6.5