30 #ifndef MLN_WORLD_K2_BORDER_FILL_NON_PRIMARY_FROM_PRIMARY_2_FACES_HH
31 # define MLN_WORLD_K2_BORDER_FILL_NON_PRIMARY_FROM_PRIMARY_2_FACES_HH
33 # include <mln/core/concept/image.hh>
34 # include <mln/core/concept/function.hh>
35 # include <mln/world/kn/safe_cast.hh>
36 # include <mln/world/k2/is_non_primary_2_face_horizontal.hh>
37 # include <mln/world/k2/is_non_primary_2_face_vertical.hh>
38 # include <mln/geom/min_row.hh>
39 # include <mln/geom/min_col.hh>
40 # include <mln/geom/max_row.hh>
41 # include <mln/geom/max_col.hh>
65 template <
typename I,
typename F>
66 void fill_non_primary_from_primary_2_faces(
const Image<I>& inout,
67 const Function_vv2v<F>& f);
71 # ifndef MLN_INCLUDE_ONLY
74 template <
typename I,
typename F>
75 void fill_non_primary_from_primary_2_faces(
const Image<I>& inout_,
76 const Function_vv2v<F>& f_)
78 trace::entering(
"mln::world::k2::fill_non_primary_from_primary_2_faces");
80 mln_precondition(exact(inout_).is_valid());
81 mln_precondition(exact(inout_).border() >= 1);
82 mln_precondition(exact(inout_).domain() == exact(aux_).domain());
83 I& inout =
const_cast<I&
>(exact(inout_));
84 const F& f = exact(f_);
86 typedef mln_argument(F) V;
89 min_row_1 = geom::min_row(inout) - 1,
90 max_row_1 = geom::max_row(inout) + 1,
91 min_col_1 = geom::min_col(inout) - 1,
92 max_col_1 = geom::max_col(inout) + 1;
95 for (def::coord col = min_col_1; col <= max_col_1; ++col)
96 if (is_non_primary_2_face_vertical(min_row_1, col))
99 inout.at_(min_row_1, col) = f(inout.at_(min_row_1, col - 2),
100 inout.at_(min_row_1, col + 2));
102 inout.at_(max_row_1, col) = f(inout.at_(max_row_1, col - 2),
103 inout.at_(max_row_1, col + 2));
107 for (
def::coord row = min_row_1; row <= max_row_1; ++row)
108 if (is_non_primary_2_face_horizontal(row, min_col_1))
111 inout.at_(row, min_col_1) = f(inout.at_(row - 2, min_col_1),
112 inout.at_(row + 2, min_col_1));
114 inout.at_(row, max_col_1) = f(inout.at_(row - 2, max_col_1),
115 inout.at_(row + 2, max_col_1));
118 trace::exiting(
"mln::world::k2::fill_non_primary_from_primary_2_faces");
122 # endif // ! MLN_INCLUDE_ONLY
132 #endif // ! MLN_WORLD_K2_BORDER_FILL_NON_PRIMARY_FROM_PRIMARY_2_FACES_HH