Skip to content

Commit

Permalink
Opify morphology package
Browse files Browse the repository at this point in the history
  • Loading branch information
gselzer committed Mar 4, 2022
1 parent 6bf961e commit afc783f
Show file tree
Hide file tree
Showing 25 changed files with 2,040 additions and 40 deletions.
70 changes: 62 additions & 8 deletions src/main/java/net/imglib2/algorithm/morphology/BlackTopHat.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@
package net.imglib2.algorithm.morphology;

import java.util.List;
import java.util.function.BiPredicate;
import java.util.function.Consumer;

import net.imglib2.Interval;
import net.imglib2.IterableInterval;
import net.imglib2.RandomAccessible;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.*;
import net.imglib2.algorithm.neighborhood.Shape;
import net.imglib2.img.Img;
import net.imglib2.img.ImgFactory;
Expand Down Expand Up @@ -77,7 +76,8 @@ public class BlackTopHat
* allow for performance optimization through structuring element
* decomposition. Each shape is processed in order as given in the list. If
* the list is empty, the source image is returned.
*
*
* @implNote op name='blackTopHat', type='org.scijava.function.Function.Arity3'
* @param source
* the source image.
* @param strels
Expand Down Expand Up @@ -120,7 +120,8 @@ public static < T extends RealType< T >> Img< T > blackTopHat( final Img< T > so
* image, and the converse for the max value. These normally unseen
* parameters are required to operate on
* {@code T extends Comparable & Type}.
*
*
* @implNote op name='blackTopHat', type='org.scijava.function.Function.Arity5'
* @param source
* the source image.
* @param strels
Expand Down Expand Up @@ -159,7 +160,8 @@ public static < T extends Type< T > & Comparable< T > & Sub< T > > Img< T > blac
* limited to flat structuring elements, only having {@code on/off} pixels,
* contrary to grayscale structuring elements. This allows to simply use a
* {@link Shape} as a type for these structuring elements.
*
*
* @implNote op name='blackTopHat', type='org.scijava.function.Function.Arity3'
* @param source
* the source image.
* @param strel
Expand Down Expand Up @@ -196,7 +198,8 @@ public static < T extends RealType< T >> Img< T > blackTopHat( final Img< T > so
* (against {@link Comparable}) than any of the value found in the source
* image, and the converse for the max value. These normally unseen
* parameters are required to operate on {@code T extends Comparable & Sub}.
*
*
* @implNote op name='blackTopHat', type='org.scijava.function.Function.Arity5'
* @param source
* the source image.
* @param strel
Expand Down Expand Up @@ -268,6 +271,57 @@ public static < T extends RealType< T > > void blackTopHat( final RandomAccessib
MorphologyUtils.subAAB2( target, source, numThreads );
}

/**
* Performs the black top-hat (or bottom-hat) morphological operation on a
* {@link RealType} source {@link RandomAccessible}, using a list of
* {@link Shape}s as a structuring element, and writes the result on a
* specified target which must be an {@link IterableInterval}.
*
* See <a href="http://en.wikipedia.org/wiki/Top-hat_transform"> Top-hat
* transform</a>.
* <p>
* <b>Careful: Target must point to a different structure than source.</b>
* In place operation will not work but will not generate an error.
* <p>
* It is the caller responsibility to ensure that the source is sufficiently
* padded to properly cover the target range plus the shape size. See
* <i>e.g.</i> {@link Views#extendValue(RandomAccessibleInterval, Type)}
* <p>
* It is limited to flat structuring elements, only having
* {@code on/off} pixels, contrary to grayscale structuring elements.
* This allows to simply use a {@link Shape} as a type for these structuring
* elements.
* <p>
* The structuring element is specified through a list of {@link Shape}s, to
* allow for performance optimization through structuring element
* decomposition. Each shape is processed in order as given in the list. If
* the list is empty, the target receives a copy of the source.
* <p>
* This method differs from
* {@link #blackTopHat(RandomAccessible, IterableInterval, List, int)}
* only in that its parameter order is tailored to an Op. The output comes
* last, and the primary input (the input image) comes first.
* </p>
*
* @implNote op name='blackTopHat', type='org.scijava.function.Computers.Arity3'
* @param source
* the {@link RandomAccessible} to operate on.
* @param strels
* the list of {@link Shape}s that serves as a structuring
* element.
* @param numThreads
* the number of threads to use for calculation.
* @param target
* the {@link IterableInterval} to write the results on.
* @param <T>
* the type of the source and the result. Must extends
* {@link RealType}.
*/
public static < T extends RealType< T > > void blackTopHat( final RandomAccessible< T > source, final List< ? extends Shape > strels, final int numThreads , final IterableInterval<T> target)
{
blackTopHat( source, target, strels, numThreads );
}

/**
* Performs the black top-hat (or bottom-hat) morphological operation on a
* source {@link RandomAccessible}, using a list of {@link Shape}s as a
Expand Down
Loading

0 comments on commit afc783f

Please sign in to comment.