@@ -117,6 +117,7 @@ public static < T > ToLongBiFunction< Localizable, T > idFromIntervalIndexer( fi
117117 * generalization for higher dimenions over a binary mask. {@code mask} and
118118 * {@code labeling} are expected to have equal min and max.
119119 *
120+ * @implNote op name='connectedComponents', type='org.scijava.function.Computers.Arity1'
120121 * @param mask
121122 * Boolean mask to distinguish foreground ({@code true}) from
122123 * background ({@code false}).
@@ -170,6 +171,44 @@ public static < B extends BooleanType< B >, L extends IntegerType< L > > void co
170171 new StartAtOneIdForNextSet () );
171172 }
172173
174+ /**
175+ *
176+ * Implementation of connected component analysis that uses
177+ * {@link IntArrayRankedUnionFind} to find sets of pixels that are connected
178+ * with respect to a neighborhood ({@code shape}) over a binary mask.
179+ * {@code mask}
180+ * and {@code labeling} are expected to have equal min and max.
181+ * <p>
182+ * This method differs from
183+ * {@link #connectedComponents(RandomAccessibleInterval, RandomAccessibleInterval, Shape)}
184+ * only in that its parameter order is tailored to an Op. The output comes
185+ * last, and the primary input (the input image) comes first.
186+ * </p>
187+ *
188+ * @implNote op name='connectedComponents', type='org.scijava.function.Computers.Arity2'
189+ * @param mask
190+ * Boolean mask to distinguish foreground ({@code true}) from
191+ * background ({@code false}).
192+ * @param shape
193+ * Connectivity of connected components, e.g. 4-neighborhood
194+ * ({@link DiamondShape}), 8-neighborhood
195+ * ({@link RectangleNeighborhood}) and their generalisations for
196+ * higher dimensions.
197+ * @param labeling
198+ * Output parameter to store labeling: background pixels are
199+ * labeled zero, foreground pixels are greater than zero: 1, 2,
200+ * ..., N. Note that initially all pixels are expected to be zero
201+ * as background values will not be written.
202+ */
203+ public static < B extends BooleanType < B >, L extends IntegerType < L > > void connectedComponents (
204+ final RandomAccessibleInterval < B > mask ,
205+ final Shape shape ,
206+ final RandomAccessibleInterval < L > labeling )
207+ {
208+ connectedComponents (mask , labeling , shape );
209+ }
210+
211+
173212 /**
174213 *
175214 * Implementation of connected component analysis that uses
@@ -216,6 +255,55 @@ public static < B extends BooleanType< B >, L extends IntegerType< L > > void co
216255 UnionFind .relabel ( mask , labeling , uf , idForPixel , idForSet );
217256 }
218257
258+ /**
259+ *
260+ * Implementation of connected component analysis that uses
261+ * {@link UnionFind} to find sets of pixels that are connected with respect
262+ * to a neighborhood ({@code shape}) over a binary mask. {@code mask} and
263+ * {@code labeling} are expected to have equal min and max.
264+ * <p>
265+ * This method differs from
266+ * {@link #connectedComponents(RandomAccessibleInterval, RandomAccessibleInterval, Shape, LongFunction, ToLongBiFunction, LongUnaryOperator)}
267+ * only in that its parameter order is tailored to an Op. The output comes
268+ * last, and the primary input (the input image) comes first.
269+ * </p>
270+ *
271+ * @implNote op name='connectedComponents', type='org.scijava.function.Computers.Arity5'
272+ * @param mask
273+ * Boolean mask to distinguish foreground ({@code true}) from
274+ * background ({@code false}).
275+ * @param shape
276+ * Connectivity of connected components, e.g. 4-neighborhood
277+ * ({@link DiamondShape}), 8-neighborhood
278+ * ({@link RectangleNeighborhood}) and their generalisations for
279+ * higher dimensions.
280+ * @param unionFindFactory
281+ * Creates appropriate {@link UnionFind} data structure for size
282+ * of {@code labeling}, e.g. {@link IntArrayRankedUnionFind} of
283+ * appropriate size.
284+ * @param idForPixel
285+ * Create id from pixel location and value. Multiple calls with
286+ * the same argument should always return the same result.
287+ * @param idForSet
288+ * Create id for a set from the root id of a set. Multiple calls
289+ * with the same argument should always return the same result.
290+ * @param labeling
291+ * Output parameter to store labeling: background pixels are
292+ * labeled zero, foreground pixels are greater than zero: 1, 2,
293+ * ..., N. Note that this is expected to be zero as background
294+ * values will not be written.
295+ */
296+ public static < B extends BooleanType < B >, L extends IntegerType < L > > void connectedComponents (
297+ final RandomAccessibleInterval < B > mask ,
298+ final Shape shape ,
299+ final LongFunction < UnionFind > unionFindFactory ,
300+ final ToLongBiFunction < Localizable , L > idForPixel ,
301+ final LongUnaryOperator idForSet ,
302+ final RandomAccessibleInterval < L > labeling )
303+ {
304+ connectedComponents ( mask , labeling , shape , unionFindFactory , idForPixel , idForSet );
305+ }
306+
219307 private static < B extends BooleanType < B >, L extends IntegerType < L > > UnionFind makeUnion (
220308 final RandomAccessibleInterval < B > mask ,
221309 final RandomAccessibleInterval < L > labeling ,
0 commit comments