|
22 | 22 | public class KernelConvolverFactoryTest |
23 | 23 | { |
24 | 24 |
|
25 | | - @Test |
26 | | - public void testDoubleConvolver() |
27 | | - { |
28 | | - testConvolver( DoubleConvolverRealType.class ); |
29 | | - } |
30 | | - |
31 | | - @Test |
32 | | - public void testFloatConvolver() |
33 | | - { |
34 | | - testConvolver( FloatConvolverRealType.class ); |
35 | | - } |
36 | | - |
37 | | - @Test |
38 | | - public void testNativeConvolver() |
39 | | - { |
40 | | - testConvolver( ConvolverNativeType.class ); |
41 | | - } |
42 | | - |
43 | | - @Test |
44 | | - public void testNumericConvolver() |
45 | | - { |
46 | | - testConvolver( ConvolverNumericType.class ); |
47 | | - } |
48 | | - |
49 | | - public void testConvolver( Class< ? extends Runnable > expectedConvolverClass ) |
50 | | - { |
51 | | - try |
52 | | - { |
53 | | - double[] halfKernel = { 3, 2, 1 }; |
54 | | - double[] in = { 5, 0, 1, 0, 0, 0, 0, 0, 0, 0 }; |
55 | | - double[] expected = { 8, 2, 1, 0, 0, 0 }; |
56 | | - int lineLength = in.length - 2 * ( halfKernel.length - 1 ); |
57 | | - double[] actual = new double[ lineLength ]; |
58 | | - |
59 | | - Img< DoubleType > inImg = ArrayImgs.doubles( in, in.length ); |
60 | | - Img< DoubleType > outImg = ArrayImgs.doubles( actual, actual.length ); |
61 | | - Runnable convolver = expectedConvolverClass |
62 | | - .getConstructor( Kernel1D.class, RandomAccess.class, RandomAccess.class, int.class, long.class ) |
63 | | - .newInstance( Kernel1D.symmetric( halfKernel ), inImg.randomAccess(), outImg.randomAccess(), 0, lineLength ); |
64 | | - convolver.run(); |
65 | | - assertArrayEquals( expected, actual, 0.0001 ); |
66 | | - } |
67 | | - catch ( NoSuchMethodException e ) |
68 | | - { |
69 | | - fail( "The class " + expectedConvolverClass.getSimpleName() + " misses the constructor needed for KernelConvolverFactory." ); |
70 | | - } |
71 | | - catch ( IllegalAccessException | InstantiationException | InvocationTargetException e ) |
72 | | - { |
73 | | - fail( "The constructor of class " + expectedConvolverClass.getSimpleName() + " must be public for class copying." ); |
74 | | - } |
75 | | - } |
76 | | - |
77 | 25 | @Test |
78 | 26 | public void test() |
79 | 27 | { |
80 | 28 | testFactoryTypeMatching( DoubleConvolverRealType.class, ArrayImgs.doubles( 1 ) ); |
81 | 29 | testFactoryTypeMatching( FloatConvolverRealType.class, ArrayImgs.bytes( 1 ) ); |
82 | 30 | testFactoryTypeMatching( ConvolverNativeType.class, ArrayImgs.argbs( 1 ) ); |
83 | | - ListImg< ? extends NumericType< ? > > image = createImageOfNumericType(); |
84 | | - testFactoryTypeMatching( ConvolverNumericType.class, image ); |
| 31 | + testFactoryTypeMatching( ConvolverNumericType.class, createImageOfNumericType() ); |
85 | 32 | } |
86 | 33 |
|
87 | 34 | private ListImg< ? extends NumericType< ? > > createImageOfNumericType() |
|
0 commit comments