Désolé pour le patch un peu gros :(
1)
Ce patch résulte de plusieurs observations :
- Il n'est pas possible d'instantier les algos pour toutes combinaisons
type d'image / type de données disponibles dans olena dans un temps
acceptable.
- Quand on utilise swilena, on est typiquement en phase de prototypage
et/ou test, et on a pas envie de se prendre la tête avec le nombre
d'octets du type de donnée de manière très précise. On est en
python, on aime avoir de la souplesse et de la simplicité.
- Il est très difficile de retranscrire le comportement fortement typé
des types c++, par exemple l'addition de 2 int_u8 donne un int_u9,
etc. Sans ca, ca devient lourd à utiliser.
Du coup je n'ai gardé que qq types représentatifs : int_u32 (uint),
int_s32 (sint) et float_d (float).
2)
La deuxième chose (qui aurait mérité un autre checkin, re-désolé),
c'est l'instantiation des algos, qui a besoin d'une granularité plus
fine. En effet, la plupart des algos ne fonctionne que pour certains
types (image2d uniquement, que des types entiers, etc.). En attendant
de les corriger, generate_morpho_instantiation.py permet de tuner les
instantiations plus finement et simplement que des macros swig.
Index: tools/swilena/ChangeLog
from Nicolas Burrus <burrus_n(a)lrde.epita.fr>
* generate_morpho_instantiations.py: New file.
* meta/swilena_morpho.i: Cleanup. Remove make_xxx macros, since
instantiations are now performed by generate_morpho_instantiation.py.
* meta/swilena_structelt.i: Add common window and neighborhood
creation functions.
* meta/swilena_ntg_int_u.i, meta/swilena_ntg_int_s.i,
meta/swilena_ntg_cplx.i: Merge into...
* meta/swilena_ntg.i: ... this file. Declare only usual types.
* meta/Makefile.am: Adjust consequently.
* expand.sh: Generate uint, sint and float images only. Call
generate_morpho_instantiations.py. Adjust.
* python/tests/simple1.py: Adjust consequently.
* ruby/tests/simple1.rb: Likewise.
* doc/examples/python/simple.py: Likewise.
* doc/examples/ruby/simple.rb: Likewise.
+2003-09-27 Nicolas Burrus <burrus_n(a)lrde.epita.fr>
+
* meta/swilena_image.i: Add operator[] for python and ruby.
* meta/swilena_describe.i: Fix __str__ return type.
Index: tools/swilena/expand.sh
--- tools/swilena/expand.sh Mon, 22 Sep 2003 00:41:25 +0200 burrus_n (oln/s/25_expand.sh
1.9 750)
+++ tools/swilena/expand.sh Sat, 27 Sep 2003 19:02:23 +0200 burrus_n (oln/s/25_expand.sh
1.10 750)
@@ -9,14 +9,15 @@
mkdir -p "$SWILENA/python"
mkdir -p "$SWILENA/ruby"
-MODULES="$MODULES ntg ntg_cplx ntg_int_u ntg_int_s"
+MODULES="$MODULES ntg morpho"
for dim in 1 2 3; do
## {1d,2d,3d} families
for mod in point structelt w_win imagesize image; do
cat >"$SWILENA/src/swilena_$mod${dim}d.i" <<EOF
-%include swilena_$mod.i
+// Warning: this file was generated by expand.sh
%module swilena_$mod${dim}d
+%include swilena_$mod.i
decl_$mod($dim)
EOF
MODULES="$MODULES ${mod}${dim}d"
@@ -30,20 +31,20 @@
## Image instances
cat >>"$SWILENA/src/swilena_image${dim}d.i" <<EOF
%import swilena_ntg.i
-%import swilena_ntg_int_u.i
-%import swilena_ntg_int_s.i
EOF
- for t in bin \
- int_u8 int_u16 int_u32 \
- int_s8 int_s16 int_s32 \
- int_u8s int_u16s int_u32s \
- int_s8s int_s16s int_s32s \
- float_s float_d # rgb_8 rgb_16 rgb_32
- do
- short=`echo $t | sed -e 's,int_,,g;s,_,,g'`
- echo "make_image(image${dim}d_$short, $dim, ntg_$t)" >>
"$SWILENA/src/swilena_image${dim}d.i"
- done
-done
+ # int_u8 int_u16 int_s8 int_s16 int_s8s int_s16s int_s32s
+ # int_u8s int_u16s int_u32s
+ # float_s rgb_8 rgb_16 rgb_32
+ cat >> "$SWILENA/src/swilena_image${dim}d.i" <<EOF
+make_image(image${dim}d_bin, $dim, ntg_bin)
+make_image(image${dim}d_uint, $dim, ntg_uint)
+make_image(image${dim}d_sint, $dim, ntg_sint)
+make_image(image${dim}d_float, $dim, ntg_float)
+EOF
+ ## Morpho algorithms
+ MODULES="$MODULES morpho${dim}d"
+ cd "$SWILENA/src" && ../generate_morpho_instantiations.py &&
cd ..
+done # for dim ...
#################### Python stuff #######################
@@ -53,9 +54,9 @@
header_python()
{
cat <<EOF
-## Process this file through Automake to produce Makefile.in -*- Makefile -*-
+## Include this file into your Makefile.am -*- Makefile -*-
##
-## Makefile.am for swilena/python
+## makefile.swig for swilena/python
## NOTE: this file was generated automatically by expand.sh
##
@@ -111,9 +112,9 @@
header_ruby()
{
cat <<EOF
-## Process this file through Automake to produce Makefile.in -*- Makefile -*-
+## Include this file in your Makefile.am -*- Makefile -*-
##
-## Makefile.am for swilena/ruby
+## makefile.swig for swilena/ruby
## NOTE: this file was generated automatically by expand.sh
##
@@ -158,9 +159,9 @@
header_src() {
cat <<EOF
-## Process this file through Automake to produce Makefile.in -*- Makefile -*-
+## Include this file in your Makefile.am
##
-## Makefile.am for swilena/src
+## makefile.swig for swilena/src
## NOTE: this file was generated automatically by expand.sh
##
EOF
@@ -184,7 +185,6 @@
############ Output ###############
-
header_src >"$SWILENA/src/makefile.swig"
dump_src >>"$SWILENA/src/makefile.swig"
header_python >"$SWILENA/python/makefile.swig"
Index: tools/swilena/meta/Makefile.am
--- tools/swilena/meta/Makefile.am Tue, 06 May 2003 06:56:14 +0200 raph
(oln/s/26_Makefile.a 1.1 640)
+++ tools/swilena/meta/Makefile.am Sat, 27 Sep 2003 19:02:23 +0200 burrus_n
(oln/s/26_Makefile.a 1.2 640)
@@ -2,6 +2,6 @@
EXTRA_DIST = swilena_core.i swilena_decl.i swilena_describe.i \
swilena_exception.i swilena_image.i swilena_imagesize.i \
- swilena_morpho.i swilena_ntg.i swilena_ntg_cplx.i swilena_ntg_int_s.i \
- swilena_ntg_int_u.i swilena_point.i swilena_structelt.i \
+ swilena_morpho.i swilena_ntg.i swilena_point.i \
+ swilena_structelt.i \
swilena_w_win.i
Index: tools/swilena/meta/swilena_structelt.i
--- tools/swilena/meta/swilena_structelt.i Tue, 29 Jul 2003 18:21:22 +0200 david
(oln/s/28_swilena_st 1.2 640)
+++ tools/swilena/meta/swilena_structelt.i Sat, 27 Sep 2003 19:02:23 +0200 burrus_n
(oln/s/28_swilena_st 1.3 640)
@@ -109,11 +109,55 @@
structelt_methods_now(window ## Dim ## d, Dim)
};
+#if Dim == 1
+ const window1d& win_c2_only();
+ const window1d& win_c2p();
+ window1d mk_win_segment(unsigned);
+#elif Dim == 2
+ const window2d& win_c4_only();
+ const window2d& win_c4p();
+ const window2d& win_c8_only();
+ const window2d& win_c8p();
+ window2d mk_win_rectangle(unsigned, unsigned);
+ window2d mk_win_ellipse(float, float);
+ window2d mk_win_square(unsigned);
+ window2d mk_win_disc(float);
+#elif Dim == 3
+ const window3d& win_c6_only();
+ const window3d& win_c6p();
+ const window3d& win_c18_only();
+ const window3d& win_c18p();
+ const window3d& win_c26_only();
+ const window3d& win_c26p();
+ window3d mk_win_block(unsigned, unsigned, unsigned);
+ window3d mk_win_ellipsoid(float, float, float);
+ window3d mk_win_cube(unsigned);
+ window3d mk_win_ball(float);
+#endif
+
struct neighborhood ## Dim ## d
{
structelt_methods_now(neighborhood ## Dim ## d, Dim)
};
+#if Dim == 1
+ const neighborhood1d& neighb_c2();
+ neighborhood1d mk_neighb_segment(unsigned);
+ window1d mk_win_from_neighb(const neighborhood1d&);
+#elif Dim == 2
+ const neighborhood2d& neighb_c4();
+ const neighborhood2d& neighb_c8();
+ neighborhood2d mk_neighb_square(unsigned);
+ neighborhood2d mk_neighb_rectangle(unsigned, unsigned);
+ window2d mk_win_from_neighb(const neighborhood2d&);
+#elif Dim == 3
+ const neighborhood3d& neighb_c6();
+ const neighborhood3d& neighb_c18();
+ const neighborhood3d& neighb_c26();
+ neighborhood3d mk_neighb_block(unsigned, unsigned, unsigned);
+ neighborhood3d mk_neighb_cube(unsigned);
+ window3d mk_win_from_neighb(const neighborhood3d&);
+#endif
}
%enddef
Index: tools/swilena/meta/swilena_ntg.i
--- tools/swilena/meta/swilena_ntg.i Sun, 21 Sep 2003 21:59:21 +0200 burrus_n
(oln/s/33_swilena_nt 1.3 640)
+++ tools/swilena/meta/swilena_ntg.i Sat, 27 Sep 2003 19:02:23 +0200 burrus_n
(oln/s/33_swilena_nt 1.4 640)
@@ -4,7 +4,7 @@
/***** Generic class declaration for scalars ******/
%define decl_scalar_class(Ns, Name, ValueType)
-template<unsigned nbits, typename behaviour>
+template<unsigned nbits, typename behavior>
class Name
{
public:
@@ -15,65 +15,65 @@
ValueType value() const
{ return (*self); }
void value(ValueType x)
- { *self = Ns::Name<nbits, behaviour>(x); }
+ { *self = Ns::Name<nbits, behavior>(x); }
#if defined(SWIGPYTHON) || defined(SWIGRUBY)
- Ns::Name<nbits, behaviour> operator+ (const Ns::Name<nbits,
behaviour>& other) const { return (*self) + other; }
- Ns::Name<nbits, behaviour> operator- (const Ns::Name<nbits,
behaviour>& other) const { return (*self) - other; }
- Ns::Name<nbits, behaviour> operator* (const Ns::Name<nbits,
behaviour>& other) const { return (*self) * other; }
- Ns::Name<nbits, behaviour> operator/ (const Ns::Name<nbits,
behaviour>& other) const { return (*self) / other; }
- Ns::Name<nbits, behaviour> operator+ (ValueType other) const { return (*self) +
other; }
- Ns::Name<nbits, behaviour> operator- (ValueType other) const { return (*self) -
other; }
- Ns::Name<nbits, behaviour> operator* (ValueType other) const { return (*self) *
other; }
- Ns::Name<nbits, behaviour> operator/ (ValueType other) const { return (*self) /
other; }
+ Ns::Name<nbits, behavior> operator+ (const Ns::Name<nbits, behavior>&
other) const { return (*self) + other; }
+ Ns::Name<nbits, behavior> operator- (const Ns::Name<nbits, behavior>&
other) const { return (*self) - other; }
+ Ns::Name<nbits, behavior> operator* (const Ns::Name<nbits, behavior>&
other) const { return (*self) * other; }
+ Ns::Name<nbits, behavior> operator/ (const Ns::Name<nbits, behavior>&
other) const { return (*self) / other; }
+ Ns::Name<nbits, behavior> operator+ (ValueType other) const { return (*self) +
other; }
+ Ns::Name<nbits, behavior> operator- (ValueType other) const { return (*self) -
other; }
+ Ns::Name<nbits, behavior> operator* (ValueType other) const { return (*self) *
other; }
+ Ns::Name<nbits, behavior> operator/ (ValueType other) const { return (*self) /
other; }
#else
- Ns::Name<nbits, behaviour> add (const Ns::Name<nbits, behaviour>&
other) const { return (*self) + other; }
- Ns::Name<nbits, behaviour> sub (const Ns::Name<nbits, behaviour>&
other) const { return (*self) - other; }
- Ns::Name<nbits, behaviour> mul (const Ns::Name<nbits, behaviour>&
other) const { return (*self) * other; }
- Ns::Name<nbits, behaviour> div (const Ns::Name<nbits, behaviour>&
other) const { return (*self) / other; }
- Ns::Name<nbits, behaviour> add (ValueType other) const { return (*self) +
other; }
- Ns::Name<nbits, behaviour> sub (ValueType other) const { return (*self) -
other; }
- Ns::Name<nbits, behaviour> mul (ValueType other) const { return (*self) *
other; }
- Ns::Name<nbits, behaviour> div (ValueType other) const { return (*self) /
other; }
+ Ns::Name<nbits, behavior> add (const Ns::Name<nbits, behavior>&
other) const { return (*self) + other; }
+ Ns::Name<nbits, behavior> sub (const Ns::Name<nbits, behavior>&
other) const { return (*self) - other; }
+ Ns::Name<nbits, behavior> mul (const Ns::Name<nbits, behavior>&
other) const { return (*self) * other; }
+ Ns::Name<nbits, behavior> div (const Ns::Name<nbits, behavior>&
other) const { return (*self) / other; }
+ Ns::Name<nbits, behavior> add (ValueType other) const { return (*self) + other;
}
+ Ns::Name<nbits, behavior> sub (ValueType other) const { return (*self) - other;
}
+ Ns::Name<nbits, behavior> mul (ValueType other) const { return (*self) * other;
}
+ Ns::Name<nbits, behavior> div (ValueType other) const { return (*self) / other;
}
#endif
#if defined(SWIGPYTHON)
- Ns::Name<nbits, behaviour>& operator+= (const Ns::Name<nbits,
behaviour>& other) { return (*self) += other; }
- Ns::Name<nbits, behaviour>& operator-= (const Ns::Name<nbits,
behaviour>& other) { return (*self) -= other; }
- Ns::Name<nbits, behaviour>& operator*= (const Ns::Name<nbits,
behaviour>& other) { return (*self) *= other; }
- Ns::Name<nbits, behaviour>& operator/= (const Ns::Name<nbits,
behaviour>& other) { return (*self) /= other; }
- Ns::Name<nbits, behaviour>& operator+= (ValueType other) { return (*self)
+= other; }
- Ns::Name<nbits, behaviour>& operator-= (ValueType other) { return (*self)
-= other; }
- Ns::Name<nbits, behaviour>& operator*= (ValueType other) { return (*self)
*= other; }
- Ns::Name<nbits, behaviour>& operator/= (ValueType other) { return (*self)
/= other; }
+ Ns::Name<nbits, behavior>& operator+= (const Ns::Name<nbits,
behavior>& other) { return (*self) += other; }
+ Ns::Name<nbits, behavior>& operator-= (const Ns::Name<nbits,
behavior>& other) { return (*self) -= other; }
+ Ns::Name<nbits, behavior>& operator*= (const Ns::Name<nbits,
behavior>& other) { return (*self) *= other; }
+ Ns::Name<nbits, behavior>& operator/= (const Ns::Name<nbits,
behavior>& other) { return (*self) /= other; }
+ Ns::Name<nbits, behavior>& operator+= (ValueType other) { return (*self) +=
other; }
+ Ns::Name<nbits, behavior>& operator-= (ValueType other) { return (*self) -=
other; }
+ Ns::Name<nbits, behavior>& operator*= (ValueType other) { return (*self) *=
other; }
+ Ns::Name<nbits, behavior>& operator/= (ValueType other) { return (*self) /=
other; }
#elseif !defined(SWIGRUBY) // These operators are generated by default in Ruby
- Ns::Name<nbits, behaviour>& iadd (const Ns::Name<nbits,
behaviour>& other) { return (*self) += other; }
- Ns::Name<nbits, behaviour>& isub (const Ns::Name<nbits,
behaviour>& other) { return (*self) -= other; }
- Ns::Name<nbits, behaviour>& imul (const Ns::Name<nbits,
behaviour>& other) { return (*self) *= other; }
- Ns::Name<nbits, behaviour>& idiv (const Ns::Name<nbits,
behaviour>& other) { return (*self) /= other; }
- Ns::Name<nbits, behaviour>& iadd (ValueType other) { return (*self) +=
other; }
- Ns::Name<nbits, behaviour>& isub (ValueType other) { return (*self) -=
other; }
- Ns::Name<nbits, behaviour>& imul (ValueType other) { return (*self) *=
other; }
- Ns::Name<nbits, behaviour>& idiv (ValueType other) { return (*self) /=
other; }
+ Ns::Name<nbits, behavior>& iadd (const Ns::Name<nbits, behavior>&
other) { return (*self) += other; }
+ Ns::Name<nbits, behavior>& isub (const Ns::Name<nbits, behavior>&
other) { return (*self) -= other; }
+ Ns::Name<nbits, behavior>& imul (const Ns::Name<nbits, behavior>&
other) { return (*self) *= other; }
+ Ns::Name<nbits, behavior>& idiv (const Ns::Name<nbits, behavior>&
other) { return (*self) /= other; }
+ Ns::Name<nbits, behavior>& iadd (ValueType other) { return (*self) +=
other; }
+ Ns::Name<nbits, behavior>& isub (ValueType other) { return (*self) -=
other; }
+ Ns::Name<nbits, behavior>& imul (ValueType other) { return (*self) *=
other; }
+ Ns::Name<nbits, behavior>& idiv (ValueType other) { return (*self) /=
other; }
#endif
#if defined(SWIGPYTHON) || defined(SWIGRUBY)
- bool operator< (const Ns::Name<nbits, behaviour>& other) const { return
(*self) < other; }
- bool operator> (const Ns::Name<nbits, behaviour>& other) const { return
(*self) > other; }
- bool operator<= (const Ns::Name<nbits, behaviour>& other) const {
return (*self) <= other; }
- bool operator>= (const Ns::Name<nbits, behaviour>& other) const {
return (*self) >= other; }
- bool operator== (const Ns::Name<nbits, behaviour>& other) const { return
(*self) == other; }
+ bool operator< (const Ns::Name<nbits, behavior>& other) const { return
(*self) < other; }
+ bool operator> (const Ns::Name<nbits, behavior>& other) const { return
(*self) > other; }
+ bool operator<= (const Ns::Name<nbits, behavior>& other) const { return
(*self) <= other; }
+ bool operator>= (const Ns::Name<nbits, behavior>& other) const { return
(*self) >= other; }
+ bool operator== (const Ns::Name<nbits, behavior>& other) const { return
(*self) == other; }
bool operator< (ValueType other) const { return (*self) < other; }
bool operator> (ValueType other) const { return (*self) > other; }
bool operator<= (ValueType other) const { return (*self) <= other; }
bool operator>= (ValueType other) const { return (*self) >= other; }
bool operator== (ValueType other) const { return (*self) == other; }
#else
- bool lt (const Ns::Name<nbits, behaviour>& other) const { return (*self)
< other; }
- bool gt (const Ns::Name<nbits, behaviour>& other) const { return (*self)
> other; }
- bool le (const Ns::Name<nbits, behaviour>& other) const { return (*self)
<= other; }
- bool ge (const Ns::Name<nbits, behaviour>& other) const { return (*self)
>= other; }
- bool eq (const Ns::Name<nbits, behaviour>& other) const { return (*self)
== other; }
+ bool lt (const Ns::Name<nbits, behavior>& other) const { return (*self)
< other; }
+ bool gt (const Ns::Name<nbits, behavior>& other) const { return (*self)
> other; }
+ bool le (const Ns::Name<nbits, behavior>& other) const { return (*self)
<= other; }
+ bool ge (const Ns::Name<nbits, behavior>& other) const { return (*self)
>= other; }
+ bool eq (const Ns::Name<nbits, behavior>& other) const { return (*self) ==
other; }
bool lt (ValueType other) const { return (*self) < other; }
bool gt (ValueType other) const { return (*self) > other; }
bool le (ValueType other) const { return (*self) <= other; }
@@ -82,16 +82,16 @@
#endif
#if defined(SWIGPYTHON)
- bool operator!= (const Ns::Name<nbits, behaviour>& other) const { return
(*self) != other; }
+ bool operator!= (const Ns::Name<nbits, behavior>& other) const { return
(*self) != other; }
bool operator!= (ValueType other) const { return (*self) != other; }
#elseif !defined(SWIGRUBY)
- bool ne (const Ns::Name<nbits, behaviour>& other) const { return (*self)
!= other; }
+ bool ne (const Ns::Name<nbits, behavior>& other) const { return (*self) !=
other; }
bool ne (ValueType other) const { return (*self) != other; }
#endif
}
- EXTEND_DESCRIBE2(Ns::Name<nbits, behaviour>);
+ EXTEND_DESCRIBE2(Ns::Name<nbits, behavior>);
};
%enddef
@@ -206,7 +206,34 @@
decl_ntg()
-// Compatibility macro, see swilena_ntg_int_u.i
+/*
+ Macro are defined for every type and should be used in all modules
+ Using ntg::int_u32 (the typedef in predecls.hh) directly leads to
+ type matching problems:
+
+ - it is a typedef never used in module swilena_ntg
+ => no type correspondence is created between ntg::int_u32
+ and ntg::int_u<32, ntg::strict>.
+
+ - if another module use ntg::int_u32, operations on it won't be
+ possible since this module won't recognize the type ntg::int_u32.
+
+ - ntg::int_u<32, ntg::strict> or ntg_uint should be used
+ everywhere. ntg_uint is just a convenient macro.
+*/
+
#define ntg_bin ntg::bin
-#define ntg_float_s ntg::float_s
-#define ntg_float_d ntg::float_d
+
+%template(uint) ntg::int_u< 32, ntg::strict >;
+#define ntg_uint ntg::int_u< 32, ntg::strict >
+
+%template(sint) ntg::int_s< 32, ntg::strict >;
+#define ntg_sint ntg::int_s< 32, ntg::strict >
+
+#define ntg_float ntg::float_d
+
+%template(cplx_rect) ntg::cplx< ntg::rect, ntg_float >;
+#define ntg_cplx_rect ntg::cplx< ntg::rect, ntg_float >
+
+%template(cplx_polar) ntg::cplx< ntg::polar, ntg_float >;
+#define ntg_cplx_polar ntg::cplx< ntg::polar, ntg_float >
Index: tools/swilena/meta/swilena_morpho.i
--- tools/swilena/meta/swilena_morpho.i Tue, 06 May 2003 06:56:14 +0200 raph
(oln/s/34_swilena_mo 1.1 640)
+++ tools/swilena/meta/swilena_morpho.i Sat, 27 Sep 2003 19:02:23 +0200 burrus_n
(oln/s/34_swilena_mo 1.2 640)
@@ -1,34 +1,48 @@
// -*- C++ -*-
+%module swilena_morpho
+
+/*
+ Algorithms are supported by a simple two-level mechanism:
+
+ - Declare a my_algorithm template function accepting all type of
+ parameters. This is the goal of the decl_morpho_xxx macros.
+ ex:
+ template <class Ret, class A1, A2>
+ Ret my_algorithm(A1& a1, A2& a2);
+
+ - Instantiate it for every possible type. This is the goal of the
+ generate_morpho_instantiations.py script.
+*/
+
/********** Morpho algorithms taking two arguments ***********/
%define decl_morpho_2(Incl, Func, HAS_FAST)
+
%{
#include Incl
%}
%inline %{
-template<typename R, typename A1, typename A2 >
-static R my_ ## Func( A1& a1, A2& a2)
+template<typename Ret, typename A1, typename A2>
+static Ret my_ ## Func(A1& a1, A2& a2)
{ return oln::morpho::Func(a1, a2); }
%}
+
#if HAS_FAST
%inline %{
-template<typename R, typename A1, typename A2 >
-static R my_fast_ ## Func( A1& a1, A2& a2)
-{ return oln::morpho::fast::Func(a1, a2); }
-%}
-#endif
-%enddef
-%define make_morpho_2(Func, R, A1, A2, HAS_FAST)
-%template(Func) my_ ## Func<R, A1, A2 >;
-#if HAS_FAST
-%template(fast_ ## Func) my_fast_ ## Func<R, A1, A2 >;
+template<typename Ret, typename A1, typename A2 >
+static Ret my_fast_ ## Func(A1& a1, A2& a2)
+{
+ return oln::morpho::fast::Func(a1, a2);
+}
+
+%}
#endif
%enddef
-/************ Morpho algorithms taking three arguments *******************/
+/************ Morpho algorithms taking three arguments ************/
%define decl_morpho_3(Incl, Func, HAS_FAST)
%{
@@ -36,27 +50,21 @@
%}
%inline %{
-template<typename R, typename A1, typename A2, typename A3>
-static R my_ ## Func( A1& a1, A2& a2, A3& a3)
+template<typename Ret, typename A1, typename A2, typename A3>
+static Ret my_ ## Func(A1& a1, A2& a2, A3& a3)
{ return oln::morpho::Func(a1, a2, a3); }
%}
#if HAS_FAST
%inline %{
-template<typename R, typename A1, typename A2, typename A3>
-static R my_fast_ ## Func( A1& a1, A2& a2, A3& a3)
+template<typename Ret, typename A1, typename A2, typename A3>
+static Ret my_fast_ ## Func(A1& a1, A2& a2, A3& a3)
{ return oln::morpho::fast::Func(a1, a2, a3); }
%}
#endif
%enddef
-%define make_morpho_3(Func, R, A1, A2, A3, HAS_FAST)
-%template(Func) my_ ## Func<R, A1, A2, A3 >;
-#if HAS_FAST
-%template(fast_ ## Func) my_fast_ ## Func<R, A1, A2, A3 >;
-#endif
-%enddef
-/************ Morpho algorithms taking four arguments *******************/
+/************ Morpho algorithms taking four arguments ************/
%define decl_morpho_4(Incl, Func, HAS_FAST)
%{
@@ -64,27 +72,22 @@
%}
%inline %{
-template<typename R, typename A1, typename A2, typename A3, typename A4>
-static R my_ ## Func( A1& a1, A2& a2, A3& a3, A4& a4)
+template<typename Ret, typename A1, typename A2, typename A3, typename A4>
+static Ret my_ ## Func( A1& a1, A2& a2, A3& a3, A4& a4)
{ return oln::morpho::Func(a1, a2, a3, a4); }
%}
#if HAS_FAST
%inline %{
-template<typename R, typename A1, typename A2, typename A3, typename A4>
-static R my_fast_ ## Func( A1& a1, A2& a2, A3& a3, A4& a4)
+template<typename Ret, typename A1, typename A2, typename A3, typename A4>
+static Ret my_fast_ ## Func( A1& a1, A2& a2, A3& a3, A4& a4)
{ return oln::morpho::fast::Func(a1, a2, a3, a4); }
%}
#endif
%enddef
-%define make_morpho_4(Func, R, A1, A2, A3, A4, HAS_FAST)
-%template(Func) my_ ## Func<R, A1, A2, A3, A4 >;
-#if HAS_FAST
-%template(fast_ ## Func) my_fast_ ## Func<R, A1, A2, A3, A4 >;
-#endif
-%enddef
-/************ Morpho algorithms taking three arguments and located in three namespaces
****************/
+/************ Morpho algorithms taking three arguments **************/
+/************ and located in sure, sequential and hybrid ************/
%define decl_morpho_3ssh(Incl, Func)
%{
@@ -92,24 +95,20 @@
%}
%inline %{
-template<typename R, typename A1, typename A2, typename A3>
-static R my_sure_ ## Func( A1& a1, A2& a2, A3& a3)
+template<typename Ret, typename A1, typename A2, typename A3>
+static Ret my_sure_ ## Func( A1& a1, A2& a2, A3& a3)
{ return oln::morpho::sure::Func(a1, a2, a3); }
-template<typename R, typename A1, typename A2, typename A3>
-static R my_sequential_ ## Func( A1& a1, A2& a2, A3& a3)
+template<typename Ret, typename A1, typename A2, typename A3>
+static Ret my_sequential_ ## Func( A1& a1, A2& a2, A3& a3)
{ return oln::morpho::sequential::Func(a1, a2, a3); }
-template<typename R, typename A1, typename A2, typename A3>
-static R my_hybrid_ ## Func( A1& a1, A2& a2, A3& a3)
+template<typename Ret, typename A1, typename A2, typename A3>
+static Ret my_hybrid_ ## Func( A1& a1, A2& a2, A3& a3)
{ return oln::morpho::hybrid::Func(a1, a2, a3); }
%}
%enddef
-%define make_morpho_3ssh(Func, R, A1, A2, A3)
-%template(sure_ ## Func) my_sure_ ## Func<R, A1, A2, A3 >;
-%template(sequential_ ## Func) my_sequential_ ## Func<R, A1, A2, A3 >;
-%template(hybrid_ ## Func) my_hybrid_ ## Func<R, A1, A2, A3 >;
-%enddef
-/************ Morpho algorithms taking two arguments and located in three namespaces
****************/
+/************ Morpho algorithms taking two arguments **************/
+/************ and located in sure, sequential and hybrid **********/
%define decl_morpho_2ssh(Incl, Func)
%{
@@ -117,42 +116,34 @@
%}
%inline %{
-template<typename R, typename A1, typename A2>
-static R my_sure_ ## Func( A1& a1, A2& a2)
+template<typename Ret, typename A1, typename A2>
+static Ret my_sure_ ## Func( A1& a1, A2& a2)
{ return oln::morpho::sure::Func(a1, a2); }
-template<typename R, typename A1, typename A2>
-static R my_sequential_ ## Func( A1& a1, A2& a2)
+template<typename Ret, typename A1, typename A2>
+static Ret my_sequential_ ## Func( A1& a1, A2& a2)
{ return oln::morpho::sequential::Func(a1, a2); }
-template<typename R, typename A1, typename A2>
-static R my_hybrid_ ## Func( A1& a1, A2& a2)
+template<typename Ret, typename A1, typename A2>
+static Ret my_hybrid_ ## Func( A1& a1, A2& a2)
{ return oln::morpho::hybrid::Func(a1, a2); }
%}
%enddef
-%define make_morpho_2ssh(Func, R, A1, A2)
-%template(sure_ ## Func) my_sure_ ## Func<R, A1, A2>;
-%template(sequential_ ## Func) my_sequential_ ## Func<R, A1, A2>;
-%template(hybrid_ ## Func) my_hybrid_ ## Func<R, A1, A2>;
-%enddef
-/************ Morpho algorithms taking three arguments and located in two namespaces
****************/
+/************ Morpho algorithms taking three arguments ***********/
+/************ and located in morpho and morpho::sure ***********/
%define decl_morpho_3ss(Incl, Func)
%{
#include Incl
%}
%inline %{
-template<typename R, typename A1, typename A2, typename A3>
-static R my_ ## Func( A1& a1, A2& a2, A3& a3)
+template<typename Ret, typename A1, typename A2, typename A3>
+static Ret my_ ## Func( A1& a1, A2& a2, A3& a3)
{ return oln::morpho::Func(a1, a2, a3); }
-template<typename R, typename A1, typename A2, typename A3>
-static R my_sure_ ## Func( A1& a1, A2& a2, A3& a3)
+template<typename Ret, typename A1, typename A2, typename A3>
+static Ret my_sure_ ## Func( A1& a1, A2& a2, A3& a3)
{ return oln::morpho::sure::Func(a1, a2, a3); }
%}
%enddef
-%define make_morpho_3ss(Func, R, A1, A2, A3)
-%template(Func) my_ ## Func<R, A1, A2, A3 >;
-%template(sure_ ## Func) my_sure_ ## Func<R, A1, A2, A3 >;
-%enddef
/*************** Watershed *****************/
@@ -161,16 +152,36 @@
#include <oln/morpho/watershed.hh>
%}
%inline %{
-template<typename Ret, typename Dt, typename I, typename N>
+template<typename Ret, typename I, typename N>
static Ret my_ ## Func( I& img, N& neigh)
-{ return oln::morpho::Func<Dt >(img, neigh); }
+{ return oln::morpho::Func<oln_value_type(Ret)>(img, neigh); }
%}
%enddef
-%define make_morpho_watershed(Func, R, Dt, Img, Neigh)
-%template(Func ## _ ## Dt) my_ ## Func<R, Dt, Img, Neigh >;
+
+/************ Extrema killers ***********/
+
+%define decl_morpho_extrema_killer(Incl, Func)
+%{
+#include Incl
+%}
+
+%inline %{
+template<typename Img, typename Neighb>
+static Img my_ ## Func(const Img& a1, unsigned area, const Neighb& a3)
+{ return oln::morpho::Func(a1, area, a3); }
+%}
%enddef
/***************** Function families **********************/
+
+/*-----------------.
+| Classical family |
+`-----------------*/
+
+/*
+ Declare generic functions for classical algorithms
+*/
+
%define decl_classical_family()
decl_morpho_2(<oln/morpho/erosion.hh>, erosion, 1)
decl_morpho_2(<oln/morpho/dilation.hh>, dilation, 1)
@@ -222,62 +233,31 @@
decl_morpho_3(<oln/morpho/hit_or_miss.hh>, hit_or_miss_closing_bg, 1)
%enddef
-%define make_classical_family(Img, M, W, N)
- make_morpho_2(erosion, Img, Img, W, 1)
- make_morpho_2(dilation, Img, Img, W, 1)
-
- make_morpho_3(thickening, Img, Img, W, W, 1)
- make_morpho_3(thinning, Img, Img, W, W, 1)
-
- make_morpho_3ss(geodesic_erosion, Img, Img, Img, N)
- make_morpho_3ss(geodesic_dilation, Img, Img, Img, N)
- make_morpho_3ssh(geodesic_reconstruction_dilation, Img, Img, Img, N)
- make_morpho_3ssh(geodesic_reconstruction_erosion, Img, Img, Img, N)
-
- make_morpho_3ssh(minima_imposition, Img, Img, M, N)
- make_morpho_2ssh(regional_minima, M, Img, N)
-
-
- make_morpho_2(beucher_gradient, Img, Img, W, 1)
- make_morpho_2(internal_gradient, Img, Img, W, 1)
- make_morpho_2(external_gradient, Img, Img, W, 1)
-
- // FIXME: this is broken for the moment (why ?)
-/* make_morpho_2(laplacian, Img, Img, W, 1) */
-
- make_morpho_2(white_top_hat, Img, Img, W, 1)
- make_morpho_2(black_top_hat, Img, Img, W, 1)
- make_morpho_2(self_complementary_top_hat, Img, Img, W, 1)
- make_morpho_2(top_hat_contrast_op, Img, Img, W, 1)
-
- make_morpho_3(hit_or_miss, Img, Img, W, W, 1)
- make_morpho_3(hit_or_miss_opening, Img, Img, W, W, 1)
- make_morpho_3(hit_or_miss_opening_bg, Img, Img, W, W, 1)
- make_morpho_3(hit_or_miss_closing, Img, Img, W, W, 1)
- make_morpho_3(hit_or_miss_closing_bg, Img, Img, W, W, 1)
-
-%enddef
+/*----------------------.
+| Extrema killer family |
+`----------------------*/
%define decl_extrema_killer_family()
- decl_morpho_3(<oln/morpho/extrema_killer.hh>, sure_maxima_killer, 0)
- decl_morpho_3(<oln/morpho/extrema_killer.hh>, fast_maxima_killer, 0)
- decl_morpho_3(<oln/morpho/extrema_killer.hh>, sure_minima_killer, 0)
- decl_morpho_3(<oln/morpho/extrema_killer.hh>, fast_minima_killer, 0)
-%enddef
-%define make_extrema_killer_family(Img, N)
- make_morpho_3(sure_maxima_killer, Img, Img, unsigned, N, 0)
- make_morpho_3(fast_maxima_killer, Img, Img, unsigned, N, 0)
- make_morpho_3(sure_minima_killer, Img, Img, unsigned, N, 0)
- make_morpho_3(fast_minima_killer, Img, Img, unsigned, N, 0)
+ decl_morpho_extrema_killer(<oln/morpho/extrema_killer.hh>,
+ sure_maxima_killer)
+ decl_morpho_extrema_killer(<oln/morpho/extrema_killer.hh>,
+ fast_maxima_killer)
+ decl_morpho_extrema_killer(<oln/morpho/extrema_killer.hh>,
+ sure_minima_killer)
+ decl_morpho_extrema_killer(<oln/morpho/extrema_killer.hh>,
+ fast_minima_killer)
%enddef
+/*-----------------.
+| Watershed family |
+`-----------------*/
+
%define decl_watershed_family()
decl_morpho_watershed(watershed_seg)
decl_morpho_watershed(watershed_con)
decl_morpho_3(<oln/morpho/watershed.hh>, watershed_seg_or, 0)
%enddef
-%define make_watershed_family(Dt, Img1, Img2, N)
- make_morpho_watershed(watershed_seg, Img2, Dt, Img1, N)
- make_morpho_watershed(watershed_con, Img2, Dt, Img1, N)
- make_morpho_3(watershed_seg_or, Img2, Img1, Img2, N, 0)
-%enddef
+
+decl_classical_family()
+decl_watershed_family()
+decl_extrema_killer_family()
Index: tools/swilena/meta/swilena_decl.i
--- tools/swilena/meta/swilena_decl.i Tue, 06 May 2003 06:56:14 +0200 raph
(oln/s/39_swilena_de 1.1 640)
+++ tools/swilena/meta/swilena_decl.i Sat, 27 Sep 2003 19:02:23 +0200 burrus_n
(oln/s/39_swilena_de 1.2 640)
@@ -72,5 +72,3 @@
%define swmake5(Name, R, A1, A2, A3, A4, A5)
%template(Name) my_ ## Name<R, A1, A2, A3, A4, A5 >;
%enddef
-
-
Index: tools/swilena/python/tests/simple1.py
--- tools/swilena/python/tests/simple1.py Sun, 21 Sep 2003 23:13:48 +0200 burrus_n
(oln/v/16_simple1.py 1.1 700)
+++ tools/swilena/python/tests/simple1.py Sat, 27 Sep 2003 19:02:23 +0200 burrus_n
(oln/v/16_simple1.py 1.2 700)
@@ -3,16 +3,16 @@
import os
import sys
from swilena_image2d import *
-from swilena_ntg_int_u import *
+from swilena_ntg import *
imgdir = os.environ['IMGDIR']
-lena = image2d_u8()
+lena = image2d_uint()
lena.load(imgdir + "/lena.pgm")
# FIXME: uncomment when ready
#assert(lena.has_impl())
-lena.set(5, 5, int_u8(51))
+lena.set(5, 5, uint(51))
lena.ref(6, 6).value(42)
assert(lena.at(5, 5).value() == 51)
Index: tools/swilena/ruby/tests/simple1.rb
--- tools/swilena/ruby/tests/simple1.rb Sun, 21 Sep 2003 23:13:48 +0200 burrus_n
(oln/v/19_simple1.rb 1.1 700)
+++ tools/swilena/ruby/tests/simple1.rb Sat, 27 Sep 2003 19:02:23 +0200 burrus_n
(oln/v/19_simple1.rb 1.2 700)
@@ -4,19 +4,19 @@
$: << ENV["SWILENA_PATH"] if ENV.has_key? "SWILENA_PATH"
require "swilena_image2d"
-require "swilena_ntg_int_u"
+require "swilena_ntg"
-include Swilena_ntg_int_u
+include Swilena_ntg
include Swilena_image2d
imgdir = ENV["IMGDIR"]
-lena = Image2d_u8.new
+lena = Image2d_uint.new
lena.load(imgdir + "/lena.pgm")
# FIXME: uncomment when ready
#exit 1 unless lena.has_impl()
-lena.set(5, 5, Int_u8.new(51))
+lena.set(5, 5, Uint.new(51))
lena.ref(6, 6).value(42)
exit 1 unless lena.at(5, 5).value() == 51
Index: tools/swilena/doc/examples/ruby/simple.rb
--- tools/swilena/doc/examples/ruby/simple.rb Mon, 22 Sep 2003 00:41:25 +0200 burrus_n
(oln/v/22_simple.rb 1.1 600)
+++ tools/swilena/doc/examples/ruby/simple.rb Sat, 27 Sep 2003 19:02:23 +0200 burrus_n
(oln/v/22_simple.rb 1.2 600)
@@ -4,10 +4,10 @@
$: << ENV["SWILENA_PATH"] if ENV.has_key? "SWILENA_PATH"
require "swilena_image2d"
-require "swilena_ntg_int_u"
+require "swilena_ntg"
require "swilena_display"
-include Swilena_ntg_int_u
+include Swilena_ntg
include Swilena_image2d
display = SwilenaDisplay.new
@@ -15,23 +15,15 @@
display.tmpdir = "/tmp/swilena"
display.display_command = "display %{image_file}"
-ima = Image2d_u8.new(5,5)
+ima = Image2d_uint.new(5,5)
-0.upto(5) do |i|
- 0.upto(5) do |j|
- ima.set(i, j, Int_u8.new(i + j))
+for i in 0..5 do
+ for j in 0..5 do
+ ima.set(i, j, Uint.new(i + j))
end
end
print ima
display.display_image (ima, "image1")
-ima2 = Image2d_u16.new(10, 10)
-0.upto(5) do |i|
- 0.upto(5) do |j|
- ima2.set(i, j, Int_u16.new(1))
- end
-end
-display.display_image (ima2, "image2")
-
display.wait_all_displays()
Index: tools/swilena/doc/examples/python/simple.py
--- tools/swilena/doc/examples/python/simple.py Mon, 22 Sep 2003 00:41:25 +0200 burrus_n
(oln/v/23_simple.py 1.1 600)
+++ tools/swilena/doc/examples/python/simple.py Sat, 27 Sep 2003 19:02:23 +0200 burrus_n
(oln/v/23_simple.py 1.2 600)
@@ -3,24 +3,24 @@
# Add swilena modules path into the PYTHON_PATH variable
from swilena_image2d import *
-from swilena_ntg_int_u import *
+from swilena_ntg import *
import swilena_display
from swilena_display import display_image, wait_all_displays
swilena_display.tmpdir = "/tmp/swilena"
swilena_display.display_command = "xv %{image_file}"
-ima = image2d_u8(5,5)
+ima = image2d_uint(5,5)
print ima.at(5,5).value()
-ima.set(2,2,int_u8(2))
+ima.set(2,2,uint(2))
print ima
p = ima.ref(1,1)
p.value(3)
print ima
-lena = image2d_u8();
+lena = image2d_uint();
lena.load("lena.pgm")
display_image (ima, "lena")
Index: tools/swilena/generate_morpho_instantiations.py
--- tools/swilena/generate_morpho_instantiations.py Mon, 29 Sep 2003 09:56:29 +0200
burrus_n ()
+++ tools/swilena/generate_morpho_instantiations.py Sat, 27 Sep 2003 19:02:23 +0200
burrus_n (oln/v/24_generate_m 1.1 700)
@@ -0,0 +1,149 @@
+#!/usr/bin/env python
+
+files = []
+
+def close_files():
+ for file in files:
+ file.close()
+
+def open_files():
+ for dim in range(1, 4):
+ files.append(open("swilena_morpho%(dim)sd.i" % vars(), 'w'))
+
+def write_headers():
+ for dim in range(1, 4):
+ file = files[dim - 1]
+ file.write("""// Note: this file was generated by generate_morpho.py.
+
+%%module swilena_morpho%(dim)sd
+
+%%include swilena_exception.i
+%%include swilena_morpho.i
+
+%%import swilena_image%(dim)sd.i
+%%import swilena_ntg.i
+
+""" % vars())
+
+def instantiate(dim, algorithm, *args):
+ file = files[dim - 1]
+ swilena_algorithm = "my_" + algorithm
+ params = args[0]
+ for param in args[1:]:
+ params += ", " + param
+ file.write(
+ "%%template(%(algorithm)s) %(swilena_algorithm)s< %(params)s >;\n"
+ % vars())
+
+def write_algorithms():
+ # Algorithms with all types and all dims
+ for dim in range(1, 4):
+ for type in [ "ntg_bin", "ntg_uint", "ntg_sint",
"ntg_float" ]:
+ img_type = "::oln::image%(dim)sd< %(type)s >" % vars()
+ win_type = "::oln::window%(dim)sd" % vars()
+ neighb_type = "::oln::neighborhood%(dim)sd" % vars()
+
+ # FIXME: these algorithms do not work with floats
+ if type != "ntg_float":
+ instantiate(dim, "erosion", img_type, img_type, win_type)
+ instantiate(dim, "fast_erosion", img_type, img_type, win_type)
+
+ instantiate(dim, "dilation", img_type, img_type, win_type)
+ instantiate(dim, "fast_dilation", img_type, img_type, win_type)
+
+ instantiate(dim, "thickening", img_type, img_type, win_type, win_type)
+ instantiate(dim, "fast_thickening", img_type, img_type, win_type, win_type)
+
+ instantiate(dim, "thinning", img_type, img_type, win_type, win_type)
+ instantiate(dim, "fast_thinning", img_type, img_type, win_type, win_type)
+
+ instantiate(dim, "geodesic_erosion", img_type, img_type, img_type,
neighb_type)
+ instantiate(dim, "sure_geodesic_erosion", img_type, img_type, img_type,
neighb_type)
+
+ instantiate(dim, "geodesic_dilation", img_type, img_type, img_type,
neighb_type)
+ instantiate(dim, "sure_geodesic_dilation", img_type, img_type, img_type,
neighb_type)
+
+ instantiate(dim, "sure_geodesic_reconstruction_dilation", img_type, img_type,
img_type, neighb_type)
+ instantiate(dim, "sequential_geodesic_reconstruction_dilation", img_type,
img_type, img_type, neighb_type)
+ instantiate(dim, "hybrid_geodesic_reconstruction_dilation", img_type,
img_type, img_type, neighb_type)
+
+ instantiate(dim, "sure_geodesic_reconstruction_erosion", img_type, img_type,
img_type, neighb_type)
+ instantiate(dim, "sequential_geodesic_reconstruction_erosion", img_type,
img_type, img_type, neighb_type)
+ instantiate(dim, "hybrid_geodesic_reconstruction_erosion", img_type,
img_type, img_type, neighb_type)
+
+ instantiate(dim, "hit_or_miss", img_type, img_type, win_type, win_type)
+ instantiate(dim, "fast_hit_or_miss", img_type, img_type, win_type, win_type)
+
+ instantiate(dim, "hit_or_miss_opening", img_type, img_type, win_type,
win_type)
+ instantiate(dim, "fast_hit_or_miss_opening", img_type, img_type, win_type,
win_type)
+
+ instantiate(dim, "hit_or_miss_opening_bg", img_type, img_type, win_type,
win_type)
+ instantiate(dim, "fast_hit_or_miss_opening_bg", img_type, img_type, win_type,
win_type)
+
+ instantiate(dim, "hit_or_miss_closing", img_type, img_type, win_type,
win_type)
+ instantiate(dim, "fast_hit_or_miss_closing", img_type, img_type, win_type,
win_type)
+
+ instantiate(dim, "hit_or_miss_closing_bg", img_type, img_type, win_type,
win_type)
+ instantiate(dim, "fast_hit_or_miss_closing_bg", img_type, img_type, win_type,
win_type)
+
+ # FIXME: these algorithms do not work with binary types
+ if type != "ntg_bin" and type != "ntg_float":
+ instantiate(dim, "beucher_gradient", img_type, img_type, win_type)
+ instantiate(dim, "fast_beucher_gradient", img_type, img_type, win_type)
+
+ instantiate(dim, "internal_gradient", img_type, img_type, win_type)
+ instantiate(dim, "fast_internal_gradient", img_type, img_type, win_type)
+
+ instantiate(dim, "external_gradient", img_type, img_type, win_type)
+ instantiate(dim, "fast_external_gradient", img_type, img_type, win_type)
+
+ instantiate(dim, "white_top_hat", img_type, img_type, win_type)
+ instantiate(dim, "fast_white_top_hat", img_type, img_type, win_type)
+
+ instantiate(dim, "black_top_hat", img_type, img_type, win_type)
+ instantiate(dim, "fast_black_top_hat", img_type, img_type, win_type)
+
+ instantiate(dim, "self_complementary_top_hat", img_type, img_type, win_type)
+ instantiate(dim, "fast_self_complementary_top_hat", img_type, img_type,
win_type)
+
+ instantiate(dim, "top_hat_contrast_op", img_type, img_type, win_type)
+ instantiate(dim, "fast_top_hat_contrast_op", img_type, img_type, win_type)
+
+ # FIXME: watershed only works with ntg_uint
+ if type == "ntg_uint":
+ # Watershed
+ img_ret_type = "::oln::image%(dim)sd< ntg_uint >" % vars()
+ instantiate(dim, "watershed_seg", img_ret_type, img_type, neighb_type)
+ instantiate(dim, "watershed_con", img_ret_type, img_type, neighb_type)
+ instantiate(dim, "watershed_seg_or", img_type, img_type, img_ret_type,
neighb_type)
+
+ # FIXME: this is broken
+ # instantiate(dim, "laplacian", img_type, img_type, win_type)
+ # instantiate(dim, "fast_laplacian", img_type, img_type, win_type)
+
+ # FIXME: this is broken
+ # bin_img_type = "::oln::image%(dim)sd< ntg_bin >" % vars()
+ # instantiate(dim, "sure_minima_imposition", img_type, img_type,
bin_img_type, neighb_type)
+ # instantiate(dim, "sequential_minima_imposition", img_type, img_type,
bin_img_type, neighb_type)
+ # instantiate(dim, "hybrid_minima_imposition", img_type, img_type,
bin_img_type, neighb_type)
+
+ # FIXME: this is broken
+ # instantiate(dim, "sure_regional_minima", bin_img_type, img_type,
neighb_type)
+ # instantiate(dim, "sequential_regional_minima", bin_img_type, img_type,
neighb_type)
+ # instantiate(dim, "hybrid_regional_minima", bin_img_type, img_type,
neighb_type)
+
+ # Extrema killers
+ # FIXME: extrema killers work only with ntg::int_u8 data type
+ # instantiate(dim, "sure_maxima_killer", img_type, neighb_type)
+ # instantiate(dim, "fast_maxima_killer", img_type, neighb_type)
+ # instantiate(dim, "sure_minima_killer", img_type, neighb_type)
+ # instantiate(dim, "fast_minima_killer", img_type, neighb_type)
+
+def main():
+ open_files()
+ write_headers()
+ write_algorithms()
+ close_files()
+
+if __name__ == "__main__":
+ main()
Index: tools/swilena/meta/swilena_ntg_int_u.i
--- tools/swilena/meta/swilena_ntg_int_u.i Sun, 21 Sep 2003 21:59:21 +0200 burrus_n
(oln/s/30_swilena_nt 1.2 640)
+++ tools/swilena/meta/swilena_ntg_int_u.i Mon, 29 Sep 2003 09:56:29 +0200 burrus_n ()
@@ -1,41 +0,0 @@
-%module swilena_ntg_int_u
-%include swilena_exception.i
-
-%import swilena_ntg.i
-
-%{
-#include <ntg/all.hh>
-%}
-
-%define declare_int_u(Name, nbits, behavior)
-
-%template(Name) ntg::int_u<nbits, behavior>;
-
-/*
- This macro should be used in all modules
- Using ntg::int_u8 directly leads to type matching problems:
-
- - it is a typedef never used in module swilena_ntg_int_u
- => no type correspondence is created between ntg::int_u8
- and ntg::int_u<8, ntg::strict>.
-
- - if another module use ntg::int_u8, operations on it won't be
- possible since this module won't recognize the type ntg::int_u8.
-
- - ntg::int_u<8, ntg::strict> or ntg_int_u8 should be used
- everywhere. ntg_int_u8 is just a convenient macro.
-*/
-
-#define ntg_ ## Name ntg::int_u<nbits, behavior>
-
-%enddef
-
-declare_int_u(int_u8, 8, ntg::strict);
-declare_int_u(int_u8u, 8, ntg::unsafe);
-declare_int_u(int_u8s, 8, ntg::saturate);
-declare_int_u(int_u16, 16, ntg::strict);
-declare_int_u(int_u16u, 16, ntg::unsafe);
-declare_int_u(int_u16s, 16, ntg::saturate);
-declare_int_u(int_u32, 32, ntg::strict);
-declare_int_u(int_u32u, 32, ntg::unsafe);
-declare_int_u(int_u32s, 32, ntg::saturate);
Index: tools/swilena/meta/swilena_ntg_int_s.i
--- tools/swilena/meta/swilena_ntg_int_s.i Sun, 21 Sep 2003 21:59:21 +0200 burrus_n
(oln/s/31_swilena_nt 1.2 640)
+++ tools/swilena/meta/swilena_ntg_int_s.i Mon, 29 Sep 2003 09:56:29 +0200 burrus_n ()
@@ -1,27 +0,0 @@
-%module swilena_ntg_int_s
-%include swilena_exception.i
-
-%import swilena_ntg.i
-
-%{
-#include <ntg/all.hh>
-%}
-
-%define declare_int_s(Name, nbits, behavior)
-
-%template(Name) ntg::int_s<nbits, behavior>;
-
-// See comments in swilena_ntg_int_u.i
-#define ntg_ ## Name ntg::int_s<nbits, behavior>
-
-%enddef
-
-declare_int_s(int_s8, 8, ntg::strict);
-declare_int_s(int_s8u, 8, ntg::unsafe);
-declare_int_s(int_s8s, 8, ntg::saturate);
-declare_int_s(int_s16, 16, ntg::strict);
-declare_int_s(int_s16u, 16, ntg::unsafe);
-declare_int_s(int_s16s, 16, ntg::saturate);
-declare_int_s(int_s32, 32, ntg::strict);
-declare_int_s(int_s32u, 32, ntg::unsafe);
-declare_int_s(int_s32s, 32, ntg::saturate);
Index: tools/swilena/meta/swilena_ntg_cplx.i
--- tools/swilena/meta/swilena_ntg_cplx.i Sun, 21 Sep 2003 21:59:21 +0200 burrus_n
(oln/s/32_swilena_nt 1.3 640)
+++ tools/swilena/meta/swilena_ntg_cplx.i Mon, 29 Sep 2003 09:56:29 +0200 burrus_n ()
@@ -1,23 +0,0 @@
-%module swilena_ntg_cplx
-%include swilena_exception.i
-
-%import swilena_ntg.i
-
-%{
-#include <ntg/all.hh>
-%}
-
-%define declare_cplx(Name, repr, T)
-
-%template(Name) ntg::cplx<repr, T>;
-
-// See comments in swilena_ntg_int_u.i
-#define ntg_ ## Name ntg::cplx<repr, T>
-
-%enddef
-
-
-declare_cplx(cplx_rf, ntg::rect, ntg_float_s);
-declare_cplx(cplx_rd, ntg::rect, ntg_float_d);
-declare_cplx(cplx_pf, ntg::polar, ntg_float_s);
-declare_cplx(cplx_pd, ntg::polar, ntg_float_d);