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


Java RandomAccessibleInterval.dimensions方法代码示例

本文整理汇总了Java中net.imglib2.RandomAccessibleInterval.dimensions方法的典型用法代码示例。如果您正苦于以下问题:Java RandomAccessibleInterval.dimensions方法的具体用法?Java RandomAccessibleInterval.dimensions怎么用?Java RandomAccessibleInterval.dimensions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.imglib2.RandomAccessibleInterval的用法示例。


在下文中一共展示了RandomAccessibleInterval.dimensions方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: computeInverseHessian

import net.imglib2.RandomAccessibleInterval; //导入方法依赖的package包/类
/**
 * Compute the inverse Hessian matrix from the the steepest descent images.
 * @param descent descent image
 * @param <T> pixel type
 * @return Hessian
 */
public static <T extends RealType< T >> double[][] computeInverseHessian(
		final RandomAccessibleInterval< T > descent)
{
	final int n = descent.numDimensions() - 1;
	final int numParameters = (int) descent.dimension( n );
	final long[] dim = new long[n + 1];
	descent.dimensions( dim );
	dim[n] = 1;
	final LocalizingIntervalIterator pos = new LocalizingIntervalIterator( dim );
	final RandomAccess< T > r = descent.randomAccess();
	final double[] deriv = new double[numParameters];
	final double[][] H = new double[numParameters][numParameters];
	while ( pos.hasNext() )
	{
		pos.fwd();
		r.setPosition( pos );
		for ( int p = 0; p < numParameters; ++p )
		{
			deriv[p] = r.get().getRealDouble();
			r.fwd( n );
		}
		for ( int i = 0; i < numParameters; ++i )
			for ( int j = 0; j < numParameters; ++j )
				H[i][j] += deriv[i] * deriv[j];
	}
	return new Matrix( H ).inverse().getArray();
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:34,代码来源:Align.java

示例2: initStore

import net.imglib2.RandomAccessibleInterval; //导入方法依赖的package包/类
private synchronized void initStore( RandomAccessibleInterval< T > newStore )
{
	newStore.dimensions( this.dimensions );
	newStore.min( this.min );
	newStore.max( this.max );
	this.store = newStore;
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:8,代码来源:GrowingStoreRandomAccessible.java

示例3: initStore

import net.imglib2.RandomAccessibleInterval; //导入方法依赖的package包/类
private void initStore( RandomAccessibleInterval< T > newStore )
{
	newStore.dimensions( this.dimensions );
	newStore.min( this.min );
	newStore.max( this.max );
	this.store = newStore;
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:8,代码来源:GrowingStoreRandomAccessibleSingletonAccess.java

示例4: BlockedInterval

import net.imglib2.RandomAccessibleInterval; //导入方法依赖的package包/类
/**
 * @param source
 *            Source to be wrapped.
 * @param stepSize
 *            Strides for each dimension.
 * @param factory
 *            Factory for extending source.
 */
public BlockedInterval(
		RandomAccessibleInterval< T > source,
		long[] stepSize,
		OutOfBoundsFactory< T, RandomAccessibleInterval< T > > factory )
{
	super();
	this.stepSize = stepSize;
	this.extendedSource = new ExtendedRandomAccessibleInterval< T, RandomAccessibleInterval< T > >( source, factory );
	this.nDim = source.numDimensions();

	this.max = new long[ nDim ];
	this.min = new long[ nDim ];
	this.dimensions = new long[ nDim ];

	source.min( this.min );
	source.max( this.max );
	source.dimensions( dimensions );

	for ( int d = 0; d < this.nDim; ++d )
	{
		long val = this.max[ d ] - this.min[ d ];
		this.max[ d ] = val / stepSize[ d ] + this.min[ d ];

		long dim = this.dimensions[ d ] - this.min[ d ];
		this.dimensions[ d ] = dim / stepSize[ d ] + this.min[ d ];
	}

}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:37,代码来源:BlockedInterval.java

示例5: getPARegions

import net.imglib2.RandomAccessibleInterval; //导入方法依赖的package包/类
/**
 *  Build an image compatible with particle analyzer (8-connected binary region )
 * @param input is a label image
 * @return is a binary image
 */
public static <T extends RealType<T> & NativeType<T>> Img<IntType> getPARegions(RandomAccessibleInterval<T> input)
{
	int nDim = input.numDimensions();
	long[] dims = new long[nDim];
	input.dimensions(dims);
	ImgFactory<IntType> imgFactory = Util.getArrayOrCellImgFactory( input ,  new IntType(0) );
	Img<IntType> output = imgFactory.create(  input, new IntType()  );
			
	
	Connectivity connectivity = Connectivity.FULL; 
	RandomAccess<T> raIn = Views.extendMirrorSingle(input).randomAccess();
	
	// random accessible on the ouput
	RandomAccess<IntType> raOut = output.randomAccess();
	
	// define the connectivity
	long[][] neigh = ImageConnectivity.getConnectivityPos(nDim, connectivity.getConn() );
	int[] n_offset = ImageConnectivity.getIdxOffsetToCenterPix(neigh, dims);
	long[][] dPosList = ImageConnectivity.getSuccessiveMove(neigh);
	int nNeigh = n_offset.length;
	
	long nElements = Intervals.numElements( input );
	
	// browse through the image
	for(long idx=0; idx<nElements; idx++){
		
		final long[] pos = new long[nDim];
		getPosFromIdx( idx, pos, dims);
		raIn.setPosition(pos);
		float pVal = raIn.get().getRealFloat();
		
		if( pVal > 0 ){
			
			// loop on neighbors
			raOut.setPosition(pos);
			raOut.get().setInteger(255);
		
			for( int i =0; i<nNeigh; i++){
				
				raIn.move(dPosList[i]);
				float nVal = raIn.get().getRealFloat();
				
				// if p is strictly inferior to n then p it is a border between two label, its value is set to 0
				if ( pVal < nVal ) {
					raOut.get().setInteger( 0 );
					break;
				}
			}
			
		}
	}
	return output;
}
 
开发者ID:mpicbg-scicomp,项目名称:Interactive-H-Watershed,代码行数:59,代码来源:Utils.java

示例6: writeImage

import net.imglib2.RandomAccessibleInterval; //导入方法依赖的package包/类
/**
 * @param image
 *            Image to be stored in dvid server.
 * @param iterationAxis
 *            Along which axis to iterate.
 * @param steps
 *            Step sizes along each axis.
 * @param offset
 *            Offset target position by offset.
 * @param borderExtension
 *            Extend border with this value.
 * 
 *            Write image into data set. The image will be divided into
 *            blocks as defined by steps. The target coordinates will be the
 *            image coordinates shifted by offset.
 */
public void writeImage(
		RandomAccessibleInterval< UnsignedLongType > image,
		final int iterationAxis,
		final int[] steps,
		final int[] offset,
		UnsignedLongType borderExtension )
{
	// realX ensures that realX[i] is integer multiple of blockSize
	long[] realDim = new long[ image.numDimensions() ];
	image.dimensions( realDim );
	adaptToBlockSize( realDim, this.blockSize );
	int[] realSteps = adaptToBlockSize( steps.clone(), this.blockSize );
	int[] realOffset = adaptToBlockSize( offset.clone(), this.blockSize );

	// For now, assume always that data is in [0,1,2] == "xyz" format.
	// Do we need flexibility to allow for different orderings?
	int[] dims = new int[ image.numDimensions() ];
	for ( int d = 0; d < image.numDimensions(); ++d )
		dims[ d ] = d;

	// stepSize as long[], needed for BlockedInterval
	long[] stepSize = new long[ image.numDimensions() ];
	for ( int i = 0; i < stepSize.length; i++ )
		stepSize[ i ] = realSteps[ i ];

	// Create BlockedInterval that allows for flat iteration and intuitive
	// hyperslicing.
	// Go along iterationAxis and hyperslice, then iterate over each
	// hyperslice.
	BlockedInterval< UnsignedLongType > blockedImage = BlockedInterval.createZeroExtended( image, stepSize );
	for ( int a = 0, aUnitIncrement = 0; a < image.dimension( iterationAxis ); ++aUnitIncrement, a += realSteps[ iterationAxis ] )
	{
		IntervalView< RandomAccessibleInterval< UnsignedLongType >> hs = 
				Views.hyperSlice( blockedImage, iterationAxis, aUnitIncrement );
		Cursor< RandomAccessibleInterval< UnsignedLongType >> cursor = Views.flatIterable( hs ).cursor();
		while ( cursor.hasNext() )
		{
			RandomAccessibleInterval< UnsignedLongType > block = cursor.next();
			int[] localOffset = realOffset.clone();
			localOffset[ iterationAxis ] = a;
			for ( int i = 0, k = 0; i < localOffset.length; i++ )
			{
				if ( i == iterationAxis )
					continue;
				localOffset[ i ] += cursor.getIntPosition( k++ ) * stepSize[ i ];
			}
			try
			{
				this.writeBlock( block, dims, localOffset );
			}
			catch ( IOException e )
			{
				System.err.println( "Failed to write block: " + dataset.getRequestString( DatasetBlkLabel.getIntervalRequestString( image, realSteps ) ) );
				e.printStackTrace();
			}
		}
	}

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

示例7: writeLevelToHdf5File

import net.imglib2.RandomAccessibleInterval; //导入方法依赖的package包/类
public static void writeLevelToHdf5File(
		final ArrayList< RandomAccessibleInterval< LabelMultisetType > > imgs,
		final ExportMipmapInfo mipmapInfo,
		final int level,
		final BlockWriter writer,
		final LevelInfoWriter levelInfoWriter )
{
	final int n = imgs.get( 0 ).numDimensions();
	final int[][] resolutions = mipmapInfo.getExportResolutions();

	// Are downsampling factors a multiple of a level that we have
	// already written?
	int[] factorsToPreviousLevel = null;
	int previousLevel = -1;
	A: for ( int l = level - 1; l >= 0; --l )
	{
		final int[] f = new int[ n ];
		for ( int d = 0; d < n; ++d )
		{
			f[ d ] = resolutions[ level ][ d ] / resolutions[ l ][ d ];
			if ( f[ d ] * resolutions[ l ][ d ] != resolutions[ level ][ d ] )
				continue A;
		}
		factorsToPreviousLevel = f;
		previousLevel = l;
		break;
	}

	final RandomAccessibleInterval< LabelMultisetType > sourceImg = imgs.get( previousLevel );
	final long[] factors = Util.int2long( factorsToPreviousLevel );

	final long[] dimensions = new long[ n ];
	sourceImg.dimensions( dimensions );
	for ( int d = 0; d < n; ++d )
		dimensions[ d ] = Math.max( dimensions[ d ] / factors[ d ], 1 );

	levelInfoWriter.writeLevelInfo( dimensions, Util.int2long( resolutions[ level ] ), Util.int2long( mipmapInfo.getSubdivisions()[ level ] ) );

	final long[] minRequiredInput = new long[ n ];
	final long[] maxRequiredInput = new long[ n ];
	sourceImg.min( minRequiredInput );
	for ( int d = 0; d < n; ++d )
		maxRequiredInput[ d ] = minRequiredInput[ d ] + dimensions[ d ] * factors[ d ] - 1;
	final RandomAccessibleInterval< LabelMultisetType > extendedImg = Views.interval( Views.extendBorder( sourceImg ), new FinalInterval( minRequiredInput, maxRequiredInput ) );

	final int[] cellDimensions = mipmapInfo.getSubdivisions()[ level ];
	final long[] numCells = new long[ n ];
	final int[] borderSize = new int[ n ];
	final long[] minCell = new long[ n ];
	final long[] maxCell = new long[ n ];
	for ( int d = 0; d < n; ++d )
	{
		numCells[ d ] = ( dimensions[ d ] - 1 ) / cellDimensions[ d ] + 1;
		maxCell[ d ] = numCells[ d ] - 1;
		borderSize[ d ] = ( int ) ( dimensions[ d ] - ( numCells[ d ] - 1 ) * cellDimensions[ d ] );
	}

	final LocalizingIntervalIterator i = new LocalizingIntervalIterator( minCell, maxCell );
	final long[] currentCellMin = new long[ n ];
	final long[] currentCellDim = new long[ n ];
	final long[] currentCellPos = new long[ n ];
	while ( i.hasNext() )
	{
		i.fwd();
		i.localize( currentCellPos );
		for ( int d = 0; d < n; ++d )
		{
			currentCellMin[ d ] = currentCellPos[ d ] * cellDimensions[ d ];
			final boolean isBorderCellInThisDim = ( currentCellPos[ d ] + 1 == numCells[ d ] );
			currentCellDim[ d ] = isBorderCellInThisDim ? borderSize[ d ] : cellDimensions[ d ];
		}
		final VolatileLabelMultisetArray downscaled = Downscale.downscale( extendedImg, factors, currentCellDim, currentCellMin );
		writer.writeBlock( downscaled, currentCellMin, currentCellDim );
	}
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:76,代码来源:DownscaleToHdf5.java


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