|
7 | 7 | import net.imglib2.algorithm.convolution.Convolution; |
8 | 8 | import net.imglib2.img.Img; |
9 | 9 | import net.imglib2.img.array.ArrayImgs; |
| 10 | +import net.imglib2.test.ImgLib2Assert; |
10 | 11 | import net.imglib2.type.numeric.ARGBType; |
11 | 12 | import net.imglib2.type.numeric.NumericType; |
12 | 13 | import net.imglib2.type.numeric.integer.UnsignedByteType; |
|
21 | 22 | import java.util.stream.IntStream; |
22 | 23 | import java.util.stream.Stream; |
23 | 24 |
|
24 | | -import static org.junit.Assert.assertArrayEquals; |
25 | | -import static org.junit.Assert.assertEquals; |
26 | 25 | import static org.junit.Assert.assertTrue; |
27 | 26 |
|
28 | 27 | /** |
@@ -76,7 +75,7 @@ private void testSeparableConvolution( Kernel1D[] kernels1d ) |
76 | 75 | RandomAccessibleInterval< DoubleType > expected = getKernel( kernels1d ); |
77 | 76 | RandomAccessibleInterval< DoubleType > result = createImg( expected ); |
78 | 77 | SeparableKernelConvolution.convolve( kernels1d, dirac, result ); |
79 | | - assertImagesEqual( expected, result, 0.0 ); |
| 78 | + ImgLib2Assert.assertImageEquals( expected, result ); |
80 | 79 | } |
81 | 80 |
|
82 | 81 | private RandomAccessible< DoubleType > getDirac( int n ) |
@@ -119,24 +118,16 @@ private static RandomAccessibleInterval< DoubleType > createImg( Interval interv |
119 | 118 | return Views.translate( image, Intervals.minAsLongArray( interval ) ); |
120 | 119 | } |
121 | 120 |
|
122 | | - private static void assertImagesEqual( RandomAccessibleInterval< DoubleType > expected, RandomAccessibleInterval< DoubleType > actual, double delta ) |
123 | | - { |
124 | | - assertTrue( Intervals.equals( expected, actual ) ); |
125 | | - Views.interval( Views.pair( expected, actual ), expected ).forEach( p -> assertEquals( p.getA().getRealDouble(), p.getB().getRealDouble(), delta ) ); |
126 | | - } |
127 | | - |
128 | 121 | @Test |
129 | 122 | public void testPrecisionOfTemporaryImages() { |
130 | 123 | // NB: This test assures that for convolution on UnsignedByteType, |
131 | 124 | // the pixel type to store intermediate results can store 0.1, hence |
132 | 125 | // is FloatType or DoubleType. |
133 | | - final byte[] inputPixels = { 1 }; |
134 | | - final byte[] outputPixels = new byte[ 1 ]; |
135 | 126 | final Kernel1D[] kernels = { Kernel1D.symmetric( 0.1 ), Kernel1D.symmetric( 10 ) }; |
136 | | - Img< UnsignedByteType > input = ArrayImgs.unsignedBytes( inputPixels, 1, 1 ); |
137 | | - Img< UnsignedByteType > output = ArrayImgs.unsignedBytes( outputPixels, 1, 1 ); |
| 127 | + Img< UnsignedByteType > input = ArrayImgs.unsignedBytes( new byte[] { 1 }, 1, 1 ); |
| 128 | + Img< UnsignedByteType > output = ArrayImgs.unsignedBytes( new byte[] { 0 }, 1, 1 ); |
138 | 129 | SeparableKernelConvolution.convolution( kernels ).process( input, output ); |
139 | | - assertArrayEquals( inputPixels, outputPixels ); |
| 130 | + ImgLib2Assert.assertImageEquals( input, output ); |
140 | 131 | } |
141 | 132 |
|
142 | 133 | @Test |
|
0 commit comments