Skip to content

Commit afc783f

Browse files
committed
Opify morphology package
1 parent 6bf961e commit afc783f

25 files changed

+2040
-40
lines changed

src/main/java/net/imglib2/algorithm/morphology/BlackTopHat.java

+62-8
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@
3434
package net.imglib2.algorithm.morphology;
3535

3636
import java.util.List;
37+
import java.util.function.BiPredicate;
38+
import java.util.function.Consumer;
3739

38-
import net.imglib2.Interval;
39-
import net.imglib2.IterableInterval;
40-
import net.imglib2.RandomAccessible;
41-
import net.imglib2.RandomAccessibleInterval;
40+
import net.imglib2.*;
4241
import net.imglib2.algorithm.neighborhood.Shape;
4342
import net.imglib2.img.Img;
4443
import net.imglib2.img.ImgFactory;
@@ -77,7 +76,8 @@ public class BlackTopHat
7776
* allow for performance optimization through structuring element
7877
* decomposition. Each shape is processed in order as given in the list. If
7978
* the list is empty, the source image is returned.
80-
*
79+
*
80+
* @implNote op name='blackTopHat', type='org.scijava.function.Function.Arity3'
8181
* @param source
8282
* the source image.
8383
* @param strels
@@ -120,7 +120,8 @@ public static < T extends RealType< T >> Img< T > blackTopHat( final Img< T > so
120120
* image, and the converse for the max value. These normally unseen
121121
* parameters are required to operate on
122122
* {@code T extends Comparable & Type}.
123-
*
123+
*
124+
* @implNote op name='blackTopHat', type='org.scijava.function.Function.Arity5'
124125
* @param source
125126
* the source image.
126127
* @param strels
@@ -159,7 +160,8 @@ public static < T extends Type< T > & Comparable< T > & Sub< T > > Img< T > blac
159160
* limited to flat structuring elements, only having {@code on/off} pixels,
160161
* contrary to grayscale structuring elements. This allows to simply use a
161162
* {@link Shape} as a type for these structuring elements.
162-
*
163+
*
164+
* @implNote op name='blackTopHat', type='org.scijava.function.Function.Arity3'
163165
* @param source
164166
* the source image.
165167
* @param strel
@@ -196,7 +198,8 @@ public static < T extends RealType< T >> Img< T > blackTopHat( final Img< T > so
196198
* (against {@link Comparable}) than any of the value found in the source
197199
* image, and the converse for the max value. These normally unseen
198200
* parameters are required to operate on {@code T extends Comparable & Sub}.
199-
*
201+
*
202+
* @implNote op name='blackTopHat', type='org.scijava.function.Function.Arity5'
200203
* @param source
201204
* the source image.
202205
* @param strel
@@ -268,6 +271,57 @@ public static < T extends RealType< T > > void blackTopHat( final RandomAccessib
268271
MorphologyUtils.subAAB2( target, source, numThreads );
269272
}
270273

274+
/**
275+
* Performs the black top-hat (or bottom-hat) morphological operation on a
276+
* {@link RealType} source {@link RandomAccessible}, using a list of
277+
* {@link Shape}s as a structuring element, and writes the result on a
278+
* specified target which must be an {@link IterableInterval}.
279+
*
280+
* See <a href="http://en.wikipedia.org/wiki/Top-hat_transform"> Top-hat
281+
* transform</a>.
282+
* <p>
283+
* <b>Careful: Target must point to a different structure than source.</b>
284+
* In place operation will not work but will not generate an error.
285+
* <p>
286+
* It is the caller responsibility to ensure that the source is sufficiently
287+
* padded to properly cover the target range plus the shape size. See
288+
* <i>e.g.</i> {@link Views#extendValue(RandomAccessibleInterval, Type)}
289+
* <p>
290+
* It is limited to flat structuring elements, only having
291+
* {@code on/off} pixels, contrary to grayscale structuring elements.
292+
* This allows to simply use a {@link Shape} as a type for these structuring
293+
* elements.
294+
* <p>
295+
* The structuring element is specified through a list of {@link Shape}s, to
296+
* allow for performance optimization through structuring element
297+
* decomposition. Each shape is processed in order as given in the list. If
298+
* the list is empty, the target receives a copy of the source.
299+
* <p>
300+
* This method differs from
301+
* {@link #blackTopHat(RandomAccessible, IterableInterval, List, int)}
302+
* only in that its parameter order is tailored to an Op. The output comes
303+
* last, and the primary input (the input image) comes first.
304+
* </p>
305+
*
306+
* @implNote op name='blackTopHat', type='org.scijava.function.Computers.Arity3'
307+
* @param source
308+
* the {@link RandomAccessible} to operate on.
309+
* @param strels
310+
* the list of {@link Shape}s that serves as a structuring
311+
* element.
312+
* @param numThreads
313+
* the number of threads to use for calculation.
314+
* @param target
315+
* the {@link IterableInterval} to write the results on.
316+
* @param <T>
317+
* the type of the source and the result. Must extends
318+
* {@link RealType}.
319+
*/
320+
public static < T extends RealType< T > > void blackTopHat( final RandomAccessible< T > source, final List< ? extends Shape > strels, final int numThreads , final IterableInterval<T> target)
321+
{
322+
blackTopHat( source, target, strels, numThreads );
323+
}
324+
271325
/**
272326
* Performs the black top-hat (or bottom-hat) morphological operation on a
273327
* source {@link RandomAccessible}, using a list of {@link Shape}s as a

0 commit comments

Comments
 (0)