|
1 | 1 | package net.imglib2.algorithm.convolution; |
2 | 2 |
|
3 | | -import net.imglib2.Dimensions; |
4 | 3 | import net.imglib2.Interval; |
5 | 4 | import net.imglib2.RandomAccessible; |
6 | 5 | import net.imglib2.RandomAccessibleInterval; |
7 | 6 | import net.imglib2.img.Img; |
8 | | -import net.imglib2.img.ImgFactory; |
9 | | -import net.imglib2.img.array.ArrayImgFactory; |
10 | | -import net.imglib2.img.cell.CellImgFactory; |
11 | 7 | import net.imglib2.type.NativeType; |
12 | 8 | import net.imglib2.util.Intervals; |
13 | 9 | import net.imglib2.util.Pair; |
@@ -91,23 +87,10 @@ public void process( RandomAccessible< ? extends T > source, RandomAccessibleInt |
91 | 87 | private static < T extends NativeType< T > > RandomAccessibleInterval< T > createImage( T targetType, Interval targetInterval ) |
92 | 88 | { |
93 | 89 | long[] dimensions = Intervals.dimensionsAsLongArray( targetInterval ); |
94 | | - Img< T > ts = getImgFactory( targetInterval, targetType ).create( dimensions ); |
| 90 | + Img< T > ts = Util.getArrayOrCellImgFactory( targetInterval, targetType ).create( dimensions ); |
95 | 91 | return Views.translate( ts, Intervals.minAsLongArray( targetInterval ) ); |
96 | 92 | } |
97 | 93 |
|
98 | | - private static < T extends NativeType< T > > ImgFactory< T > getImgFactory( final Dimensions targetsize, final T type ) |
99 | | - { |
100 | | - if ( canUseArrayImgFactory( targetsize ) ) |
101 | | - return new ArrayImgFactory<>( type ); |
102 | | - final int cellSize = ( int ) Math.pow( Integer.MAX_VALUE / type.getEntitiesPerPixel().getRatio(), 1.0 / targetsize.numDimensions() ); |
103 | | - return new CellImgFactory<>( type, cellSize ); |
104 | | - } |
105 | | - |
106 | | - private static boolean canUseArrayImgFactory( final Dimensions targetsize ) |
107 | | - { |
108 | | - return Intervals.numElements( targetsize ) <= Integer.MAX_VALUE; |
109 | | - } |
110 | | - |
111 | 94 | private static < T > T uncheckedCast( Object in ) |
112 | 95 | { |
113 | 96 | @SuppressWarnings( "unchecked" ) |
|
0 commit comments