当前位置: 首页>>代码示例>>Java>>正文


Java MDShortArray类代码示例

本文整理汇总了Java中ch.systemsx.cisd.base.mdarray.MDShortArray的典型用法代码示例。如果您正苦于以下问题:Java MDShortArray类的具体用法?Java MDShortArray怎么用?Java MDShortArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MDShortArray类属于ch.systemsx.cisd.base.mdarray包,在下文中一共展示了MDShortArray类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadArray

import ch.systemsx.cisd.base.mdarray.MDShortArray; //导入依赖的package包/类
@Override
public VolatileShortArray loadArray(
		final int timepoint,
		final int setup,
		final int level,
		final int[] dimensions,
		final long[] min ) throws InterruptedException
{
	short[] data = null;
	final MDShortArray slice = reader.readMDArrayBlockWithOffset(
			dataset,
			new int[]{ dimensions[ 2 ], dimensions[ 1 ], dimensions[ 0 ] },
			new long[]{ min[ 2 ], min[ 1 ], min[ 0 ] } );

	data = slice.getAsFlatArray();

	if ( data == null )
	{
		System.out.println(
				"H5 short array loader failed loading min = " +
				Arrays.toString( min ) +
				", dimensions = " +
				Arrays.toString( dimensions ) );

		data = new short[ dimensions[ 0 ] * dimensions[ 1 ] * dimensions[ 2 ] ];
	}

	return new VolatileShortArray( data, true );
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:30,代码来源:H5ShortArrayLoader.java

示例2: loadUnsignedShort

import ch.systemsx.cisd.base.mdarray.MDShortArray; //导入依赖的package包/类
/**
 * Load an HDF5 uint16 dataset into a {@link CellImg} of {@link UnsignedShortType}.
 *
 * @param reader
 * @param dataset
 * @param cellDimensions
 */
static public CellImg< UnsignedShortType, ? > loadUnsignedShort(
		final IHDF5Reader reader,
		final String dataset,
		final int[] cellDimensions )
{
	final IHDF5ShortReader uint16Reader = reader.uint16();

	final long[] dimensions = reorder( reader.object().getDimensions( dataset ) );
	final int n = dimensions.length;

	final CellImg< UnsignedShortType, ? > target = new CellImgFactory< UnsignedShortType >( cellDimensions ).create( dimensions, new UnsignedShortType() );

	final long[] offset = new long[ n ];
	final long[] targetCellDimensions = new long[ n ];
	for ( int d = 0; d < n; )
	{
		cropCellDimensions( target, offset, cellDimensions, targetCellDimensions );
		final RandomAccessibleInterval< UnsignedShortType > targetBlock = Views.offsetInterval( target, offset, targetCellDimensions );
		final MDShortArray targetCell = uint16Reader.readMDArrayBlockWithOffset(
				dataset,
				Util.long2int( reorder( targetCellDimensions ) ),
				reorder( offset ) );

		int i = 0;
		for ( final UnsignedShortType t : Views.flatIterable( targetBlock ) )
			t.set( targetCell.get( i++ ) );

		for ( d = 0; d < n; ++d )
		{
			offset[ d ] += cellDimensions[ d ];
			if ( offset[ d ] < dimensions[ d ] )
				break;
			else
				offset[ d ] = 0;
		}
	}

	return target;
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:47,代码来源:H5Utils.java

示例3: saveUnsignedShort

import ch.systemsx.cisd.base.mdarray.MDShortArray; //导入依赖的package包/类
/**
 * Save a {@link RandomAccessibleInterval} of {@link ShortType} into an HDF5
 * uint16 dataset.
 *
 * @param source
 * @param writer
 * @param dataset
 * @param cellDimensions
 */
static public void saveUnsignedShort(
		final RandomAccessibleInterval< ShortType > source,
		final IHDF5Writer writer,
		final String dataset,
		final int[] cellDimensions )
{
	final int n = source.numDimensions();
	final long[] dimensions = Intervals.dimensionsAsLongArray( source );
	final IHDF5ShortWriter uint16Writer = writer.uint16();
	if ( !writer.exists( dataset ) )
		uint16Writer.createMDArray(
				dataset,
				reorder( dimensions ),
				reorder( cellDimensions ),
				HDF5IntStorageFeatures.INT_AUTO_SCALING_DEFLATE );

	final long[] offset = new long[ n ];
	final long[] sourceCellDimensions = new long[ n ];
	for ( int d = 0; d < n; )
	{
		cropCellDimensions( source, offset, cellDimensions, sourceCellDimensions );
		final RandomAccessibleInterval< ShortType > sourceBlock = Views.offsetInterval( source, offset, sourceCellDimensions );
		final MDShortArray targetCell = new MDShortArray( reorder( sourceCellDimensions ) );
		int i = 0;
		for ( final ShortType t : Views.flatIterable( sourceBlock ) )
			targetCell.set( t.get(), i++ );

		uint16Writer.writeMDArrayBlockWithOffset( dataset, targetCell, reorder( offset ) );

		for ( d = 0; d < n; ++d )
		{
			offset[ d ] += cellDimensions[ d ];
			if ( offset[ d ] < source.dimension( d ) )
				break;
			else
				offset[ d ] = 0;
		}
	}
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:49,代码来源:H5Utils.java

示例4: loadArrayLevel0

import ch.systemsx.cisd.base.mdarray.MDShortArray; //导入依赖的package包/类
@Override
	public VolatileLabelMultisetArray loadArrayLevel0(
			final int[] dimensions,
			final long[] min ) throws InterruptedException
	{
		short[] data = null;

		final MDShortArray block = reader.readMDArrayBlockWithOffset(
				dataset,
				new int[]{ dimensions[ 2 ], dimensions[ 1 ], dimensions[ 0 ] },
				new long[]{ min[ 2 ], min[ 1 ], min[ 0 ] } );

		data = block.getAsFlatArray();

		if ( data == null )
		{
			System.out.println(
					"H5 short label multiset array loader failed loading min = " +
					Arrays.toString( min ) +
					", dimensions = " +
					Arrays.toString( dimensions ) );

			data = new short[ dimensions[ 0 ] * dimensions[ 1 ] * dimensions[ 2 ] ];
		}

		final int[] offsets = new int[ dimensions[ 2 ] * dimensions[ 1 ] * dimensions[ 0 ] ];
		final LongMappedAccessData listData = LongMappedAccessData.factory.createStorage( 32 );
		final LabelMultisetEntryList list = new LabelMultisetEntryList( listData, 0 );
		final LabelMultisetEntry entry = new LabelMultisetEntry( 0, 1 );
		int nextListOffset = 0;
		final TLongIntHashMap idOffsetHash = new TLongIntHashMap(
				Constants.DEFAULT_CAPACITY,
				Constants.DEFAULT_LOAD_FACTOR,
				-1,
				-1);
A:		for ( int i = 0; i < data.length; ++i )
		{
			final long id = data[ i ] & 0xffffL;

//			does the list [id x 1] already exist?
			final int offset = idOffsetHash.get( id );
			if ( offset == idOffsetHash.getNoEntryValue() )
			{
				list.createListAt( listData, nextListOffset );
				entry.setId( id );
				list.add( entry );
				offsets[ i ] = nextListOffset;
				idOffsetHash.put( id, nextListOffset );
				nextListOffset += list.getSizeInBytes();
			}
			else
			{
				offsets[ i ] = offset;
				continue A;
			}
		}
//		System.out.println( listData.size() );

		return new VolatileLabelMultisetArray( offsets, listData, true );
	}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:61,代码来源:H5ShortLabelMultisetArrayLoader.java


注:本文中的ch.systemsx.cisd.base.mdarray.MDShortArray类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。