26 #ifndef MLN_CORE_CONCEPT_NEIGHBORHOOD_HH
27 # define MLN_CORE_CONCEPT_NEIGHBORHOOD_HH
33 # include <mln/core/concept/window.hh>
34 # include <mln/trait/windows.hh>
38 # define mln_is_simple_neighborhood(N) mln_is_simple_window(mln_window(N))
48 template <
typename E>
struct Neighborhood;
88 template <
typename L,
typename R>
94 operator<<(std::ostream&ostr, const Neighborhood<N>& nbh);
98 template <
typename I,
typename N>
102 template <
typename I,
typename N>
106 template <
typename I,
typename N>
112 # ifndef MLN_INCLUDE_ONLY
114 template <
typename E>
118 typedef mln_niter(E) niter;
119 typedef mln_fwd_niter(E) fwd_niter;
120 typedef mln_bkd_niter(E) bkd_niter;
122 typedef mln_window(E)
window;
123 bool m = (& E::win) == (& E::win);
125 bool (E::*m2)() const = &E::is_valid;
132 const window& (E::*m1)()
const = & E::win;
138 template <
typename L,
typename R>
140 bool operator==(
const Neighborhood<L>& lhs,
const Neighborhood<R>& rhs)
142 return exact(lhs).win() == exact(rhs).win();
145 template <
typename N>
148 operator<<(std::ostream&ostr, const Neighborhood<N>& nbh)
150 return ostr << exact(nbh).win();
153 template <
typename I,
typename N>
156 offsets_wrt(
const Image<I>& ima_,
const Neighborhood<N>& nbh_)
158 mln_is_simple_neighborhood(N)::check();
160 const I& ima = exact(ima_);
161 const N& nbh = exact(nbh_);
162 mln_precondition(ima.is_valid());
163 mln_precondition(nbh.is_valid());
165 return offsets_wrt(ima, nbh.win());
168 template <
typename I,
typename N>
170 positive_offsets_wrt(
const Image<I>& ima_,
const Neighborhood<N>& nbh_)
172 mln_is_simple_neighborhood(N)::check();
174 const I& ima = exact(ima_);
175 const N& nbh = exact(nbh_);
176 mln_precondition(ima.is_valid());
177 mln_precondition(nbh.is_valid());
179 return positive_offsets_wrt(ima, nbh.win());
182 template <
typename I,
typename N>
184 negative_offsets_wrt(
const Image<I>& ima_,
const Neighborhood<N>& nbh_)
186 mln_is_simple_neighborhood(N)::check();
188 const I& ima = exact(ima_);
189 const N& nbh = exact(nbh_);
190 mln_precondition(ima.is_valid());
191 mln_precondition(nbh.is_valid());
193 return negative_offsets_wrt(ima, nbh.win());
196 # endif // ! MLN_INCLUDE_ONLY
201 #endif // ! MLN_CORE_CONCEPT_NEIGHBORHOOD_HH