27 #ifndef MLN_TRANSFORM_INFLUENCE_ZONE_GEODESIC_HH
28 # define MLN_TRANSFORM_INFLUENCE_ZONE_GEODESIC_HH
34 # include <mln/extension/adjust.hh>
35 # include <mln/canvas/distance_geodesic.hh>
36 # include <mln/transform/internal/influence_zone_functor.hh>
52 template <
typename I,
typename N>
58 # ifndef MLN_INCLUDE_ONLY
64 template <
typename I,
typename N>
66 influence_zone_geodesic_tests(
const Image<I>& input,
67 const Neighborhood<N>& nbh)
69 mln_precondition(exact(input).is_valid());
70 mln_precondition(exact(nbh).is_valid());
85 template <
typename I,
typename N>
88 const Neighborhood<N>& nbh)
94 mlc_abort(I)::check();
100 template <
typename I,
typename N>
102 influence_zone_geodesic_fastest(const Image<I>& input_,
103 const Neighborhood<N>& nbh_)
105 trace::entering(
"transform::impl::influence_zone_geodesic_fastest");
107 const I& input = exact(input_);
108 const N& nbh = exact(nbh_);
110 internal::influence_zone_geodesic_tests(input, nbh);
112 std::queue<mln_value(I)*> q;
113 mln_concrete(I) output;
115 util::array<
int> dp = offsets_wrt(input, nbh);
116 const
unsigned n_nbhs = dp.nelements();
126 const unsigned nelts = input.nelements();
127 const mln_value(I)* p_i = input.buffer();
128 mln_value(I)* p_o = output.buffer();
129 for (
unsigned i = 0; i < nelts; ++i, ++p_i, ++p_o)
133 for (
unsigned j = 0; j < n_nbhs; ++j)
135 const mln_value(I)* n_i = p_i + dp[j];
154 mln_invariant(*ptr != 0);
155 for (
unsigned j = 0; j < n_nbhs; ++j)
157 mln_value(I)* ntr = ptr + dp[j];
167 trace::exiting(
"transform::impl::influence_zone_geodesic_fastest");
178 template <
typename I,
typename N>
180 influence_zone_geodesic_dispatch(trait::image::value_alignment::any,
181 trait::image::value_storage::any,
182 trait::image::value_access::any,
186 return impl::generic::influence_zone_geodesic(input, nbh);
190 template <
typename I,
typename N>
192 influence_zone_geodesic_dispatch(trait::image::value_alignment::with_grid,
193 trait::image::value_storage::one_block,
194 trait::image::value_access::direct,
198 return impl::influence_zone_geodesic_fastest(input, nbh);
202 template <
typename I,
typename N>
204 influence_zone_geodesic_dispatch(const Image<I>& input,
205 const Neighborhood<N>& nbh)
208 influence_zone_geodesic_dispatch(mln_trait_image_value_alignment(I)(),
209 mln_trait_image_value_storage(I)(),
210 mln_trait_image_value_access(I)(),
211 exact(input), exact(nbh));
217 template <
typename I,
typename N>
221 trace::entering(
"transform::influence_zone_geodesic");
223 internal::influence_zone_geodesic_tests(input, nbh);
226 output = internal::influence_zone_geodesic_dispatch(input, nbh);
228 trace::exiting(
"transform::influence_zone_geodesic");
232 # endif // ! MLN_INCLUDE_ONLY
239 #endif // ! MLN_TRANSFORM_INFLUENCE_ZONE_GEODESIC_HH