27 #ifndef MLN_TOPO_SKELETON_IS_SIMPLE_POINT_HH
28 # define MLN_TOPO_SKELETON_IS_SIMPLE_POINT_HH
38 # include <mln/core/concept/image.hh>
39 # include <mln/core/alias/point2d.hh>
40 # include <mln/core/alias/neighb2d.hh>
74 bool check(
const I& ima,
const mln_psite(I)&
p)
const;
76 bool check__(
const I& ima,
unsigned p)
const;
82 template <
typename I,
typename N2>
84 const mln_psite(I)& p,
bool object)
const;
85 template <
typename I,
typename N2>
87 unsigned p,
bool object)
const;
91 # ifndef MLN_INCLUDE_ONLY
96 static const unsigned char nb_connexity_c8[256] =
98 0, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1,
99 1, 2, 1, 1, 1, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1,
100 1, 2, 2, 2, 2, 3, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1,
101 2, 3, 2, 2, 2, 3, 2, 2, 2, 2, 1, 1, 2, 2, 1, 1,
103 1, 2, 2, 2, 2, 3, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1,
104 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
105 1, 2, 2, 2, 2, 3, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1,
106 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
108 1, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 3, 3, 2, 2,
109 1, 2, 1, 1, 1, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1,
110 2, 3, 3, 3, 3, 4, 3, 3, 2, 2, 2, 2, 3, 3, 2, 2,
111 2, 3, 2, 2, 2, 3, 2, 2, 2, 2, 1, 1, 2, 2, 1, 1,
113 1, 2, 2, 2, 2, 3, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1,
114 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
115 1, 2, 2, 2, 2, 3, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1,
116 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
119 static const unsigned char nb_connexity_c4[256] =
121 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1,
122 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 3, 2, 2, 2, 2, 1,
123 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1,
124 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 3, 2, 2, 2, 2, 1,
126 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 3, 2, 2, 2, 3, 2,
127 2, 2, 3, 3, 2, 2, 2, 2, 3, 3, 4, 3, 3, 3, 3, 2,
128 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 1, 1, 1, 2, 1,
129 2, 2, 3, 3, 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 1,
131 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1,
132 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 3, 2, 2, 2, 2, 1,
133 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1,
134 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 3, 2, 2, 2, 2, 1,
136 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 3, 2, 2, 2, 3, 2,
137 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 3, 2, 2, 2, 2, 1,
138 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 1, 1, 1, 2, 1,
139 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1
144 template <
typename N>
148 mln_precondition(
nbh_.is_valid());
152 template <
typename N>
153 template <
typename I,
typename N2>
157 const mln_psite(I)& p,
163 mln_bkd_niter(N2) n(
c8(), p);
167 if (ima.domain().has(n) && ima(n) == object)
174 return internal::nb_connexity_c4[res];
176 return internal::nb_connexity_c8[res];
184 template <
typename N>
185 template <
typename I,
typename N2>
194 static util::array<int>
195 noffset = mln::offsets_wrt(ima,
c8());
197 for (
int i = noffset.nelements() - 1; i >= 0; --i)
200 if (ima.element(p + noffset[i]) == object)
207 return internal::nb_connexity_c4[res];
209 return internal::nb_connexity_c8[res];
217 template <
typename N>
218 template <
typename I>
222 const mln_psite(I)& p)
const
224 mln_precondition(ima.is_valid());
225 return (nb_connexity2d(ima, nbh_.foreground(),
p,
true) == 1)
226 && (nb_connexity2d(ima, nbh_.background(),
p,
false) == 1);
232 template <
typename N>
233 template <
typename I>
239 mln_precondition(ima.is_valid());
240 return (nb_connexity2d__(ima, nbh_.foreground(),
p,
true) == 1)
241 && (nb_connexity2d__(ima, nbh_.background(),
p,
false) == 1);
245 # endif // MLN_TOPO_SKELETON_INCLUDE_ONLY
253 #endif // ! MLN_TOPO_SKELETON_IS_SIMPLE_POINT_HH