本文整理汇总了Java中net.imglib2.img.array.ArrayImgs.ints方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayImgs.ints方法的具体用法?Java ArrayImgs.ints怎么用?Java ArrayImgs.ints使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.imglib2.img.array.ArrayImgs
的用法示例。
在下文中一共展示了ArrayImgs.ints方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exhaustiveKendallTauBRankTesting
import net.imglib2.img.array.ArrayImgs; //导入方法依赖的package包/类
@Test
public void exhaustiveKendallTauBRankTesting() {
assumeTrue(exhaustive);
final int n = 5, m = 10;
final int[] values1 = new int[n], values2 = new int[n];
for (int i = 0; i < 100; i++) {
for (int j = 0; j < n; j++) {
values1[j] = Math.abs(pseudoRandom()) % m;
values2[j] = Math.abs(pseudoRandom()) % m;
}
//final PairIterator<DoubleType> iter = pairIterator(values1, values2);
final Iterable<Pair<IntType, IntType>> iter = new IterablePair<>(ArrayImgs.ints(values1, n), ArrayImgs.ints(values2, n));
double kendallValue1 = calculateNaive(iter.iterator());
double kendallValue2 = (Double) ops.run(KendallTauBRank.class, values1, values2);
if (Double.isNaN(kendallValue1)) {
assertTrue("i: " + i + ", value2: " + kendallValue2, Double.isInfinite(kendallValue2) || Double.isNaN(kendallValue2));
} else {
assertEquals("i: " + i, kendallValue1, kendallValue2, 1e-10);
}
}
}
示例2: createIntArray
import net.imglib2.img.array.ArrayImgs; //导入方法依赖的package包/类
private static int[] createIntArray(
final RandomAccessibleInterval<IntType> image)
{
final long[] dims = Intervals.dimensionsAsLongArray(image);
final ArrayImg<IntType, IntArray> dest = ArrayImgs.ints(dims);
copy(image, dest);
return dest.update(null).getCurrentStorageArray();
}
示例3: createLabelRegion
import net.imglib2.img.array.ArrayImgs; //导入方法依赖的package包/类
protected static <T extends RealType<T>> LabelRegion<String> createLabelRegion(
final RandomAccessibleInterval<T> interval, final float min, final float max, long... dims)
{
if (dims == null || dims.length == 0) {
dims = new long[interval.numDimensions()];
interval.dimensions(dims);
}
final ImgLabeling<String, IntType> labeling =
new ImgLabeling<>(ArrayImgs.ints(dims));
final RandomAccess<LabelingType<String>> ra = labeling.randomAccess();
final RandomAccessibleIntervalCursor<T> c = new RandomAccessibleIntervalCursor<>(interval);
final long[] pos = new long[labeling.numDimensions()];
while (c.hasNext()) {
final T item = c.next();
final float value = item.getRealFloat();
if (value >= min && value <= max) {
c.localize(pos);
ra.setPosition(pos);
ra.get().add("1");
}
}
final LabelRegions<String> labelRegions = new LabelRegions<>(labeling);
return labelRegions.getLabelRegion("1");
}
示例4: main
import net.imglib2.img.array.ArrayImgs; //导入方法依赖的package包/类
public static void main( String[] args )
{
final long[] dim = new long[] { 2, 3 };
long[] m = new long[ dim.length ];
long[] M = new long[ dim.length ];
ArrayImg< IntType, IntArray > img = ArrayImgs.ints( dim );
int i = 0;
for ( IntType c : img )
c.set( i++ );
Factory< IntType > factory = ( min1, max1, t1 ) -> {
final long[] dimensions1 = new long[ min1.length ];
for ( int d = 0; d < min1.length; ++d )
dimensions1[ d ] = max1[ d ] - min1[ d ] + 1;
ArrayImg< IntType, IntArray > imgFac = ArrayImgs.ints( dimensions1 );
return Views.translate( imgFac, min1 );
};
Function< long[], long[] > l = ( long[] array ) -> {
long[] result = array.clone();
for ( int k = 0; k < result.length; ++k )
result[ k ] = -result[ k ];
return result;
};
GrowingStoreRandomAccessible< IntType > rra = new GrowingStoreRandomAccessible<>( img, factory );
new ImageJ();
RandomAccess< IntType > ra = rra.randomAccess();
// Bdv bdv = BdvFunctions.show(rra, "1");
IntType f;
ImageJFunctions.show( Views.offsetInterval( rra, rra.getIntervalOfSizeOfStore() ), "1" );
System.out.println( Arrays.toString( dim ) + " " + Arrays.toString( m ) + " " + Arrays.toString( M ) + " " + ra.get().get() + " " + ra + " " + rra.getIntervalOfSizeOfStore() );
ra.setPosition( -2, 0 );
f = ra.get();
f.get();
f.set( ( byte ) 25 );
ImageJFunctions.show( Views.interval( rra, rra.getIntervalOfSizeOfStore() ), "2" );
System.out.println( Arrays.toString( dim ) + " " + Arrays.toString( m ) + " " + Arrays.toString( M ) + " " + ra.get().get() + " " + ra + " " + rra.getIntervalOfSizeOfStore() );
ra.setPosition( dim[ 1 ], 1 );
f = ra.get();
f.get();
f.set( ( byte ) 25 );
ImageJFunctions.show( Views.interval( rra, rra.getIntervalOfSizeOfStore() ), "3" );
System.out.println( Arrays.toString( dim ) + " " + Arrays.toString( m ) + " " + Arrays.toString( M ) + " " + ra.get().get() + " " + ra + " " + rra.getIntervalOfSizeOfStore() );
ra.setPosition( M );
ra.setPosition( 32, 0 );
ra.setPosition( 17, 1 ); // 11 now, was 17 before
long[] pos = new long[ ra.numDimensions() ];
ra.localize( pos );
System.out.println( Arrays.toString( pos ) );
f = ra.get();
f.get();
f.set( ( byte ) 25 );
ImageJFunctions.show( Views.interval( rra, rra.getIntervalOfSizeOfStore() ), "4" );
System.out.println( Arrays.toString( dim ) + " " + Arrays.toString( m ) + " " + Arrays.toString( M ) + " " + ra.get().get() + " " + ra + " " + rra.getIntervalOfSizeOfStore() );
// {
// RandomAccess<FloatType> accessToBeCollected = rra.randomAccess();
// for ( WeakReference< ? > a : rra.randomAccessRefs ) {
// System.out.println( a.get() );
// }
// }
// System.gc();
// System.gc();
// for ( WeakReference< ? > a : rra.randomAccessRefs ) {
// System.out.println( a.get() );
// }
}
示例5: main
import net.imglib2.img.array.ArrayImgs; //导入方法依赖的package包/类
public static void main( String[] args )
{
final long[] dim = new long[] { 2, 3 };
long[] m = new long[ dim.length ];
long[] M = new long[ dim.length ];
ArrayImg< IntType, IntArray > img = ArrayImgs.ints( dim );
int i = 0;
for ( IntType c : img )
c.set( i++ );
// Factory<IntType> factory = (min1, max1, t1) -> {
// final long[] dimensions1 = new long[ min1.length ];
// for (int d = 0; d < min1.length; ++d )
// dimensions1[d] = max1[d] - min1[d] + 1;
// ArrayImg<IntType, IntArray> imgFac = ArrayImgs.ints(dimensions1);
// return Views.translate(imgFac, min1);
// };
SimpleArrayImgFactory< IntType > factory = new SimpleArrayImgFactory< IntType >( new IntType( 0 ) );
Function< long[], long[] > l = ( long[] array ) -> {
long[] result = array.clone();
for ( int k = 0; k < result.length; ++k )
result[ k ] = -result[ k ];
return result;
};
GrowingStoreRandomAccessibleSingletonAccess< IntType > rra = new GrowingStoreRandomAccessibleSingletonAccess<>( img, factory );
new ImageJ();
RandomAccess< IntType > ra = rra.randomAccess();
// Bdv bdv = BdvFunctions.show(rra, "1");
IntType f;
ImageJFunctions.show( Views.offsetInterval( rra, rra.getIntervalOfSizeOfStore() ), "1" );
System.out.println( Arrays.toString( dim ) + " " + Arrays.toString( m ) + " " + Arrays.toString( M ) + " " + ra.get().get() + " " + ra + " " + rra.getIntervalOfSizeOfStore() );
ra.setPosition( -2, 0 );
f = ra.get();
f.get();
f.set( ( byte ) 25 );
ImageJFunctions.show( Views.interval( rra, rra.getIntervalOfSizeOfStore() ), "2" );
System.out.println( Arrays.toString( dim ) + " " + Arrays.toString( m ) + " " + Arrays.toString( M ) + " " + ra.get().get() + " " + ra + " " + rra.getIntervalOfSizeOfStore() );
ra.setPosition( dim[ 1 ], 1 );
f = ra.get();
f.get();
f.set( ( byte ) 25 );
ImageJFunctions.show( Views.interval( rra, rra.getIntervalOfSizeOfStore() ), "3" );
System.out.println( Arrays.toString( dim ) + " " + Arrays.toString( m ) + " " + Arrays.toString( M ) + " " + ra.get().get() + " " + ra + " " + rra.getIntervalOfSizeOfStore() );
ra.setPosition( M );
ra.setPosition( 32, 0 );
ra.setPosition( 17, 1 ); // 11 now, was 17 before
long[] pos = new long[ ra.numDimensions() ];
ra.localize( pos );
System.out.println( Arrays.toString( pos ) );
f = ra.get();
f.get();
f.set( ( byte ) 25 );
ImageJFunctions.show( Views.interval( rra, rra.getIntervalOfSizeOfStore() ), "4" );
System.out.println( Arrays.toString( dim ) + " " + Arrays.toString( m ) + " " + Arrays.toString( M ) + " " + ra.get().get() + " " + ra + " " + rra.getIntervalOfSizeOfStore() );
// {
// RandomAccess<FloatType> accessToBeCollected = rra.randomAccess();
// for ( WeakReference< ? > a : rra.randomAccessRefs ) {
// System.out.println( a.get() );
// }
// }
// System.gc();
// System.gc();
// for ( WeakReference< ? > a : rra.randomAccessRefs ) {
// System.out.println( a.get() );
// }
}
示例6: imgInt
import net.imglib2.img.array.ArrayImgs; //导入方法依赖的package包/类
/**
* Creates an image of type {@link IntType} containing the data of a
* TensorFlow Tensor with the data type {@link DataType#INT32}.
* <p>
* Note that this does _not_ adjust any dimensions. This means that
* the resulting image will have dimensions corresponding to the reversed
* shape of the Tensor. See {@link #imgByteDirect(Tensor)} and
* {@link #imgByte(Tensor, int[])} if you want to handle dimensions
* differently.
* </p>
* @param image The TensorFlow Tensor.
* @return An image containing the data of the Tensor.
* @throws IllegalArgumentException if Tensor data type is not int.
*/
public static Img<IntType> imgInt(final Tensor image) {
final int[] out = new int[image.numElements()];
image.writeTo(IntBuffer.wrap(out));
return ArrayImgs.ints(out, shape(image));
}