2137: Wrap morphological gradient and area closing.

https://svn.lrde.epita.fr/svn/oln/trunk/swilena Index: ChangeLog from Roland Levillain <roland@lrde.epita.fr> Wrap morphological gradient and area closing. * morpho.ixx: Wrap mln::morpho::gradient and mln::morpho::closing_area. * image2d_int_u8.i (meyer_wst): Rename as... (meyer_wst32): ...this. (gradient, closing_area, meyer_wst): New wrappings. * python/lena.py: Exercise gradient and area closing (along with Meyer's watershed transform). image2d_int_u8.i | 31 +++++++++++++++++++++++-------- morpho.ixx | 31 ++++++++++++++++++++++++++++--- python/lena.py | 18 ++++++++++-------- 3 files changed, 61 insertions(+), 19 deletions(-) Index: python/lena.py --- python/lena.py (revision 2136) +++ python/lena.py (working copy) @@ -46,17 +46,19 @@ dilated = image.dilation (ima, win_c4p()) image.save(dilated, "dilated.pgm") -# Watershed Transform. -# FIXME: Run a gradient and an area closing first. -nbasins = int_u32(); -ws = image.meyer_wst (ima, c4(), nbasins) -print (type (ws)) -# FIXME: Ugly name; move int_u32 methods outside image2d_int_u8. -image.println32(ws) -# FIXME: Actualy print the number of basins; for the moment, thus +# Gradient. +gradient = image.gradient(ima, win_c4p()) +# Area closing. +closed_gradient = image.image2d_int_u8(gradient.domain()) +image.closing_area(ima, c4(), 50, closed_gradient) +# Watershed transform. +nbasins = int_u8(); +ws = image.meyer_wst (closed_gradient, c4(), nbasins) +# FIXME: Actualy print the number of basins; for the moment, this # statement outputs something like # # <int_u32.int_u32; proxy of <Swig Object of type 'mln::value::int_u< 32 > *' # at 0x816e160> > # print nbasins +image.save(ws, "ws.pgm") Index: image2d_int_u8.i --- image2d_int_u8.i (revision 2136) +++ image2d_int_u8.i (working copy) @@ -61,8 +61,9 @@ %include "morpho.ixx" // Explicit instantiation of this trait for the return type of -// mln::morpho::dilation and mln::morpho::erosion. +// mln::morpho::dilation, mln::morpho::erosion and mln::morpho::gradient. %template() mln::trait::concrete< mln::image2d< mln::value::int_u<8> > >; + /* FIXME: Can't we use `mln::value::int8' directlt here (as we can use `mln::window2d', which is a really just typedef for `mln::window< mln::dpoint_<mln::grid::square, int> >')? */ @@ -71,20 +72,34 @@ %template(erosion) mln::morpho::erosion< mln::image2d< mln::value::int_u<8> >, mln::window2d >; -// Explicit instantiation of this trait for the return type of -// mln::morpho::meyer_wst. +%template(gradient) mln::morpho::gradient< mln::image2d< mln::value::int_u<8> >, + mln::window2d >; + +%template(closing_area) +mln::morpho::closing_area< mln::image2d< mln::value::int_u<8> >, + mln::neighb2d, + mln::image2d< mln::value::int_u<8> > >; + %template() mln::trait::ch_value< mln::image2d< mln::value::int_u<8> >, - mln::value::int_u<32> >; + mln::value::int_u<8> >; %template(meyer_wst) mln::morpho::meyer_wst< - mln::value::int_u<32>, + mln::value::int_u<8>, mln::image2d< mln::value::int_u<8> >, mln::neighb2d
;
+/*---------------------------------------. +| image2d<int_u8> and image2d<int_u32>. | +`---------------------------------------*/ -/*-------------------. -| image2d<int_u32>. | -`-------------------*/ +// Explicit instantiation of this trait for the return type of meyer_wst32. +%template() mln::trait::ch_value< mln::image2d< mln::value::int_u<8> >, + mln::value::int_u<32> >; +%template(meyer_wst32) mln::morpho::meyer_wst< + mln::value::int_u<32>, + mln::image2d< mln::value::int_u<8> >, + mln::neighb2d + >; // FIXME: Rearrange and move this elsewhere. instantiate_image2d(image2d_int_u32, mln::value::int_u<32>) Index: morpho.ixx --- morpho.ixx (revision 2136) +++ morpho.ixx (working copy) @@ -31,9 +31,9 @@ %module morpho -/*-----------------------. -| Dilation and erosion. | -`-----------------------*/ +/*---------------------. +| Dilation & erosion. | +`---------------------*/ %include "concrete.ixx" @@ -45,6 +45,31 @@ %include "mln/morpho/dilation.hh" %include "mln/morpho/erosion.hh" +// FIXME: Add morphological opening & closing. + +/*------------. +| Gradients. | +`------------*/ + +// FIXME: Add other gradient. + +%{ +#include "mln/morpho/gradient.hh" +%} + +%include "mln/morpho/gradient.hh" + +/*-------------------------. +| Area closing & opening. | +`-------------------------*/ + +// FIXME: Add area opening. + +%{ +#include "mln/morpho/closing_area.hh" +%} + +%include "mln/morpho/closing_area.hh" /*------------------------------------. | Meyer's Watershed Transform (WST). |
participants (1)
-
Roland Levillain