Package net.imglib2.loops
Class IterableLoopBuilder<T>
- java.lang.Object
-
- net.imglib2.loops.IterableLoopBuilder<T>
-
public class IterableLoopBuilder<T> extends java.lang.ObjectSimilar toLoopBuilder, but expects the first image to be anIterableIntervaland the other images to beRandomAccessible.Please note: It is usually preferable to use LoopBuilder as it often has a better performance, and using
RandomAccessibleIntervalfor all images is simpler.Here is an usage example, that calculates the sum of two images:
IterableInterval<DoubleType> sum = ... RandomAccessible<DoubleType> imageA = ... RandomAccessible<DoubleType> imageB = ... IterableLoopBuilder.setImages(sum, imageA, imageB).forEachPixel( (s, a, b) -> { s.setReal(a.getRealDouble() + b.getRealDouble()); } );- See Also:
LoopBuilder
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classIterableLoopBuilder.Chunk<T>
-
Field Summary
Fields Modifier and Type Field Description private IterableInterval<?>firstImageprivate java.util.List<RandomAccessible<?>>otherImagesprivate TaskExecutortaskExecutor
-
Constructor Summary
Constructors Modifier Constructor Description privateIterableLoopBuilder(IterableInterval<?> firstImage, RandomAccessible<?>... otherImages)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <R> java.util.List<R>forEachChunk(java.util.function.Function<LoopBuilder.Chunk<T>,R> chunkAction)voidforEachPixel(T action)Executes the given action pixel wise for the given images.IterableLoopBuilder<T>multithreaded()This will cause the loop to be executed in a multi threaded fashion.IterableLoopBuilder<T>multithreaded(TaskExecutor taskExecutor)This will cause the loop to be executed in a multi threaded fashion.static <A> IterableLoopBuilder<java.util.function.Consumer<A>>setImages(IterableInterval<A> a)Set the image to loop over.static <A,B>
IterableLoopBuilder<java.util.function.BiConsumer<A,B>>setImages(IterableInterval<A> a, RandomAccessible<B> b)Sets the images to loop over.static <A,B,C>
IterableLoopBuilder<LoopBuilder.TriConsumer<A,B,C>>setImages(IterableInterval<A> a, RandomAccessible<B> b, RandomAccessible<C> c)Sets the images to loop over.
-
-
-
Field Detail
-
taskExecutor
private TaskExecutor taskExecutor
-
firstImage
private final IterableInterval<?> firstImage
-
otherImages
private final java.util.List<RandomAccessible<?>> otherImages
-
-
Constructor Detail
-
IterableLoopBuilder
private IterableLoopBuilder(IterableInterval<?> firstImage, RandomAccessible<?>... otherImages)
-
-
Method Detail
-
setImages
public static <A> IterableLoopBuilder<java.util.function.Consumer<A>> setImages(IterableInterval<A> a)
Set the image to loop over.
-
setImages
public static <A,B> IterableLoopBuilder<java.util.function.BiConsumer<A,B>> setImages(IterableInterval<A> a, RandomAccessible<B> b)
Sets the images to loop over.
-
setImages
public static <A,B,C> IterableLoopBuilder<LoopBuilder.TriConsumer<A,B,C>> setImages(IterableInterval<A> a, RandomAccessible<B> b, RandomAccessible<C> c)
Sets the images to loop over.
-
forEachPixel
public void forEachPixel(T action)
Executes the given action pixel wise for the given images.
-
forEachChunk
public <R> java.util.List<R> forEachChunk(java.util.function.Function<LoopBuilder.Chunk<T>,R> chunkAction)
-
multithreaded
public IterableLoopBuilder<T> multithreaded()
This will cause the loop to be executed in a multi threaded fashion. Details can be set using theParallelizationframework.
-
multithreaded
public IterableLoopBuilder<T> multithreaded(TaskExecutor taskExecutor)
This will cause the loop to be executed in a multi threaded fashion. The giveTaskExecutorwill be used for multi threading.
-
-