Skip to content

Commit b1ae0d9

Browse files
committed
Add Gauss3 1D kernel helper methods
1 parent f8c3618 commit b1ae0d9

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -248,23 +248,28 @@ public static < S extends NumericType< S >, T extends NumericType< T > > void ga
248248

249249
public static double[][] halfkernels( final double[] sigma )
250250
{
251-
final int n = sigma.length;
252-
final double[][] halfkernels = new double[ n ][];
253-
final int[] size = halfkernelsizes( sigma );
254-
for ( int i = 0; i < n; ++i )
255-
halfkernels[ i ] = halfkernel( sigma[ i ], size[ i ], true );
251+
final double[][] halfkernels = new double[ sigma.length ][];
252+
Arrays.setAll( halfkernels, i -> halfkernel( sigma[ i ] ) );
256253
return halfkernels;
257254
}
258255

259256
public static int[] halfkernelsizes( final double[] sigma )
260257
{
261-
final int n = sigma.length;
262-
final int[] size = new int[ n ];
263-
for ( int i = 0; i < n; ++i )
264-
size[ i ] = Math.max( 2, ( int ) ( 3 * sigma[ i ] + 0.5 ) + 1 );
258+
final int[] size = new int[ sigma.length ];
259+
Arrays.setAll( size, i -> halfkernelsize( sigma[ i ] ) );
265260
return size;
266261
}
267262

263+
public static int halfkernelsize( final double sigma )
264+
{
265+
return Math.max( 2, ( int ) ( 3 * sigma + 0.5 ) + 1 );
266+
}
267+
268+
public static double[] halfkernel( final double sigma )
269+
{
270+
return halfkernel( sigma, halfkernelsize( sigma ), true );
271+
}
272+
268273
/**
269274
* Returns a gaussian half kernel with the given sigma and size.
270275
* <p>

0 commit comments

Comments
 (0)