Skip to content

Commit 41e55dc

Browse files
committed
Gauss3: update javadoc and mark some methods as deprecated.
1 parent 425b057 commit 41e55dc

File tree

1 file changed

+48
-8
lines changed

1 file changed

+48
-8
lines changed

src/main/java/net/imglib2/algorithm/gauss3/Gauss3.java

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@
3434

3535
package net.imglib2.algorithm.gauss3;
3636

37+
import java.util.Arrays;
3738
import java.util.concurrent.ExecutorService;
3839
import java.util.concurrent.Executors;
40+
import java.util.concurrent.ForkJoinPool;
3941

4042
import net.imglib2.RandomAccessible;
4143
import net.imglib2.RandomAccessibleInterval;
@@ -57,7 +59,7 @@
5759
public final class Gauss3
5860
{
5961
/**
60-
* Apply Gaussian convolution to source and write the result to output.
62+
* Apply Gaussian convolution to source and write the result to target.
6163
* In-place operation (source==target) is supported.
6264
*
6365
* <p>
@@ -67,6 +69,11 @@ public final class Gauss3
6769
* in their own precision. The source type S and target type T are either
6870
* both {@link RealType RealTypes} or both the same type.
6971
*
72+
* <p>
73+
* Computation may be multi-threaded, according to the current
74+
* {@link Parallelization} context. (By default, it will use the
75+
* {@link ForkJoinPool#commonPool() common ForkJoinPool})
76+
*
7077
* @param sigma
7178
* standard deviation of isotropic Gaussian.
7279
* @param source
@@ -94,7 +101,7 @@ public static < S extends NumericType< S >, T extends NumericType< T > > void ga
94101
}
95102

96103
/**
97-
* Apply Gaussian convolution to source and write the result to output.
104+
* Apply Gaussian convolution to source and write the result to target.
98105
* In-place operation (source==target) is supported.
99106
*
100107
* <p>
@@ -105,9 +112,10 @@ public static < S extends NumericType< S >, T extends NumericType< T > > void ga
105112
* both {@link RealType RealTypes} or both the same type.
106113
*
107114
* <p>
108-
* Computation is multi-threaded with as many threads as processors
109-
* available.
110-
*
115+
* Computation may be multi-threaded, according to the current
116+
* {@link Parallelization} context. (By default, it will use the
117+
* {@link ForkJoinPool#commonPool() common ForkJoinPool})
118+
*
111119
* @param sigma
112120
* standard deviation in every dimension.
113121
* @param source
@@ -133,6 +141,21 @@ public static < S extends NumericType< S >, T extends NumericType< T > > void ga
133141
}
134142

135143
/**
144+
* @deprecated
145+
* Deprecated. Please use
146+
* {@link Gauss3#gauss(double, RandomAccessible, RandomAccessibleInterval)
147+
* gauss(sigma, source, target)} instead. The number of threads used to
148+
* calculate the Gaussion convolution may by set with the
149+
* {@link Parallelization} context, as show in this example:
150+
* <pre>
151+
* {@code
152+
* Parallelization.runWithNumThreads( numThreads,
153+
* () -> gauss( sigma, source, target )
154+
* );
155+
* }
156+
* </pre>
157+
*
158+
* <p>
136159
* Apply Gaussian convolution to source and write the result to output.
137160
* In-place operation (source==target) is supported.
138161
*
@@ -162,14 +185,30 @@ public static < S extends NumericType< S >, T extends NumericType< T > > void ga
162185
* if source and target type are not compatible (they must be
163186
* either both {@link RealType RealTypes} or the same type).
164187
*/
188+
@Deprecated
165189
public static < S extends NumericType< S >, T extends NumericType< T > > void gauss( final double[] sigma, final RandomAccessible< S > source, final RandomAccessibleInterval< T > target, final int numThreads ) throws IncompatibleTypeException
166190
{
167-
final ExecutorService service = Executors.newFixedThreadPool( numThreads );
168-
gauss( sigma, source, target, service );
169-
service.shutdown();
191+
Parallelization.runWithNumThreads( numThreads,
192+
() -> gauss( sigma, source, target )
193+
);
170194
}
171195

172196
/**
197+
* @deprecated
198+
* Deprecated. Please use
199+
* {@link Gauss3#gauss(double, RandomAccessible, RandomAccessibleInterval)
200+
* gauss(sigma, source, target)} instead. The ExecutorService used to
201+
* calculate the Gaussion convolution may by set with the
202+
* {@link Parallelization} context, as show in this example:
203+
* <pre>
204+
* {@code
205+
* Parallelization.runWithExecutor( executorService,
206+
* () -> gauss( sigma, source, target )
207+
* );
208+
* }
209+
* </pre>
210+
*
211+
* <p>
173212
* Apply Gaussian convolution to source and write the result to output.
174213
* In-place operation (source==target) is supported.
175214
*
@@ -199,6 +238,7 @@ public static < S extends NumericType< S >, T extends NumericType< T > > void ga
199238
* if source and target type are not compatible (they must be
200239
* either both {@link RealType RealTypes} or the same type).
201240
*/
241+
@Deprecated
202242
public static < S extends NumericType< S >, T extends NumericType< T > > void gauss( final double[] sigma, final RandomAccessible< S > source, final RandomAccessibleInterval< T > target, final ExecutorService service ) throws IncompatibleTypeException
203243
{
204244
Parallelization.runWithExecutor( service,

0 commit comments

Comments
 (0)