
J'ai effectué les changements ci-dessous pour que les gradients puissent marcher sur des images avec voisinage. Ces modifications comprennent : - l'ajout de ch_value_type dans les propriétés de image_from_pwf ; - la modification de force_value_type_to (cf. infra). ChangeLog | 22 ++++++++++++++++++++++ oln/convert/force.hh | 5 +++-- oln/core/pw/image.hh | 7 +++++++ oln/funobj/accum.hh | 2 +- oln/level/extrema_components.hh | 5 +++-- oln/level/level_components.hh | 2 +- oln/morpho/gradient.hh | 6 +++--- oln/morpho/temp.hh | 14 ++++++++------ oln/morpho/thick_gradient.hh | 7 ++++--- 9 files changed, 52 insertions(+), 18 deletions(-) Index: olena/ChangeLog from Roland Levillain <roland@lrde.epita.fr> Catch up with changes in morphological gradients. * oln/morpho/temp.hh (force_value_type_to): Take the whole output image type as first parameter, not just its value type (which is deduced from the former). Use ntg::cast::force<> to perform the conversion. * oln/core/pw/image.hh (set_props <category::image, image_from_pwf<F> >::ch_value_type): New. * oln/morpho/gradient.hh, oln/morpho/thick_gradient.hh: Adjust. * oln/funobj/accum.hh (accum_with_init::fun_) (accum_with_init::value_): Switch the order of these declarations to match the order of their initializations in ctors. * oln/convert/force.hh, oln/level/level_components.hh: Aesthetic changes. * oln/level/extrema_components.hh: Likewise. (extrema_components): Use ntg_cumul_type(DestValue) to store the components labels. Index: olena/oln/morpho/temp.hh --- olena/oln/morpho/temp.hh (révision 226) +++ olena/oln/morpho/temp.hh (copie de travail) @@ -31,6 +31,7 @@ # include <oln/basics.hh> # include <oln/utils/record.hh> # include <oln/core/ch_value_type.hh> +# include <ntg/utils/cast.hh> namespace oln { @@ -39,19 +40,20 @@ // FIXME: this is definitely temporay - template <typename T, typename I> - typename ch_value_type<I,T>::ret + template <typename O, typename I> + O force_value_type_to(const abstract::image<I>& input) { entering("force_value_type_to"); registering(input, "input"); - typedef typename ch_value_type<I,T>::ret output_type; - output_type output(input.size(), "output"); + typedef oln_type_of(O, value) output_value_type; - oln_type_of(I, fwd_piter) p(input.size()); + O output(input.size(), "output"); + + oln_type_of(I, piter) p(input.size()); for_all_p (p) - output[p] = T(input[p]); + output[p] = ntg::cast::force<output_value_type> (input[p].value()); exiting("force_value_type_to"); return output; Index: olena/oln/core/pw/image.hh --- olena/oln/core/pw/image.hh (révision 226) +++ olena/oln/core/pw/image.hh (copie de travail) @@ -69,6 +69,13 @@ typedef fwd_piter2d fwd_piter_type; typedef bkd_piter2d bkd_piter_type; typedef image2d<value_type> concrete_type; + + // FIXME: Is this ``cast'' right? + template <typename U> + struct ch_value_type + { + typedef concrete_type<U> ret; + }; }; Index: olena/oln/morpho/gradient.hh --- olena/oln/morpho/gradient.hh (révision 226) +++ olena/oln/morpho/gradient.hh (copie de travail) @@ -53,7 +53,7 @@ dil = elementary_dilation(input); ero = elementary_erosion(input); - output = force_value_type_to<oln_type_of(I, value)>( dil - ero ); + output = force_value_type_to<oln_type_of(I, concrete)>( dil - ero ); exiting("morpho::gradient_beucher"); return output; @@ -72,7 +72,7 @@ oln_type_of(I, concrete) ero("ero"), output("output"); ero = elementary_erosion(input); - output = force_value_type_to<oln_type_of(I, value)>( input - ero ); + output = force_value_type_to<oln_type_of(I, concrete)>( input - ero ); exiting("morpho::gradient_internal"); return output; @@ -91,7 +91,7 @@ oln_type_of(I, concrete) dil("dil"), output("output"); dil = elementary_dilation(input); - output = force_value_type_to<oln_type_of(I, value)>( dil - input ); + output = force_value_type_to<oln_type_of(I, concrete)>( dil - input ); exiting("morpho::gradient_external"); return output; Index: olena/oln/morpho/thick_gradient.hh --- olena/oln/morpho/thick_gradient.hh (révision 226) +++ olena/oln/morpho/thick_gradient.hh (copie de travail) @@ -31,6 +31,7 @@ # include <oln/morpho/dilation.hh> # include <oln/morpho/erosion.hh> # include <oln/morpho/temp.hh> +# include <oln/ops/arith.hh> namespace oln { @@ -52,7 +53,7 @@ dil = dilation(input, win); ero = erosion(input, win); - output = force_value_type_to<oln_type_of(I, value)>( dil - ero ); + output = force_value_type_to<oln_type_of(I, concrete)>( dil - ero ); exiting("morpho::thick_gradient_beucher"); return output; @@ -72,7 +73,7 @@ oln_type_of(I, concrete) ero("ero"), output("output"); ero = erosion(input, win); - output = force_value_type_to<oln_type_of(I, value)>( input - ero ); + output = force_value_type_to<oln_type_of(I, concrete)>( input - ero ); exiting("morpho::thick_gradient_internal"); return output; @@ -92,7 +93,7 @@ oln_type_of(I, concrete) dil("dil"), output("output"); dil = dilation(input, win); - output = force_value_type_to<oln_type_of(I, value)>( dil - input ); + output = force_value_type_to<oln_type_of(I, concrete)>( dil - input ); exiting("morpho::thick_gradient_external"); return output; Index: olena/oln/funobj/accum.hh --- olena/oln/funobj/accum.hh (révision 226) +++ olena/oln/funobj/accum.hh (copie de travail) @@ -64,8 +64,8 @@ private: - T value_; F fun_; + T value_; }; Index: olena/oln/convert/force.hh --- olena/oln/convert/force.hh (révision 226) +++ olena/oln/convert/force.hh (copie de travail) @@ -51,8 +51,9 @@ name() { // FIXME: Exact is not an integre type ! - return std::string("force<") - + ntg_name(Output) + ">"; + // return std::string("force<") + ntg_name(Output) + ", " + + // Exact::name() + ">"; + return std::string("force<") + ntg_name(Output) + ">"; } }; Index: olena/oln/level/level_components.hh --- olena/oln/level/level_components.hh (révision 226) +++ olena/oln/level/level_components.hh (copie de travail) @@ -67,7 +67,7 @@ q.pop(); oln_type_of(I, niter) n(input); for_all_n_of_p (n, s) - if (input.hold(n) && !processed[n] && input[n] == input[s]) + if (input.hold(n) and !processed[n] and input[n] == input[s]) { labels[n] = cur_label; processed[n] = true; Index: olena/oln/level/extrema_components.hh --- olena/oln/level/extrema_components.hh (révision 226) +++ olena/oln/level/extrema_components.hh (copie de travail) @@ -50,7 +50,8 @@ Cmp cmp; // Compute level components. - typedef unsigned comp_type; + typedef ntg_cumul_type(DestValue) cumul_type; + typedef cumul_type comp_type; typename ch_value_type<I, comp_type>::ret comps = level_components<comp_type>(input); std::set<comp_type> extrema; @@ -68,7 +69,7 @@ oln_type_of(I, niter) n(input); for_all_n_of_p (n, p) - if (input.hold(n) && cmp(input[n], input[p])) + if (input.hold(n) and cmp(input[n], input[p])) { extrema.erase(comp); non_extrema.insert(comp);