7
7
import net .imglib2 .RandomAccessible ;
8
8
import net .imglib2 .RandomAccessibleInterval ;
9
9
import net .imglib2 .loops .LoopBuilder ;
10
+ import net .imglib2 .parallel .Parallelization ;
11
+ import net .imglib2 .parallel .TaskExecutor ;
12
+ import net .imglib2 .parallel .TaskExecutors ;
10
13
import net .imglib2 .util .Intervals ;
11
14
import net .imglib2 .util .Localizables ;
12
15
import net .imglib2 .view .Views ;
13
16
17
+ import java .util .concurrent .ExecutorService ;
18
+
14
19
/**
15
20
* This class can be used to implement a separable convolution. It applies a
16
21
* {@link LineConvolverFactory} on the given images.
@@ -23,12 +28,21 @@ public class LineConvolution< T > implements Convolution<T>
23
28
24
29
private final int direction ;
25
30
31
+ private ExecutorService executor ;
32
+
26
33
public LineConvolution ( final LineConvolverFactory < ? super T > factory , final int direction )
27
34
{
28
35
this .factory = factory ;
29
36
this .direction = direction ;
30
37
}
31
38
39
+ @ Deprecated
40
+ @ Override
41
+ public void setExecutor ( ExecutorService executor )
42
+ {
43
+ this .executor = executor ;
44
+ }
45
+
32
46
@ Override
33
47
public Interval requiredSourceInterval ( final Interval targetInterval )
34
48
{
@@ -56,7 +70,8 @@ public void process( RandomAccessible< ? extends T > source, RandomAccessibleInt
56
70
dim [ direction ] = 1 ;
57
71
58
72
RandomAccessibleInterval < Localizable > positions = Localizables .randomAccessibleInterval ( new FinalInterval ( dim ) );
59
- LoopBuilder .setImages ( positions ).multiThreaded ().forEachChunk (
73
+ TaskExecutor taskExecutor = executor == null ? Parallelization .getTaskExecutor () : TaskExecutors .forExecutorService ( executor );
74
+ LoopBuilder .setImages ( positions ).multiThreaded (taskExecutor ).forEachChunk (
60
75
chunk -> {
61
76
62
77
final RandomAccess < ? extends T > in = sourceInterval .randomAccess ();
0 commit comments