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


Java RandomAccessibleInterval.dimension方法代码示例

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


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

示例1: Align

import net.imglib2.RandomAccessibleInterval; //导入方法依赖的package包/类
public Align(final RandomAccessibleInterval< T > template, final ImgFactory< FloatType > factory, WarpFunction model)
{
	this.template = template;

	n = template.numDimensions();
	warpFunction = model;
	numParameters = warpFunction.numParameters();
	
	currentTransform = new AffineTransform( n );
	
	final long[] dim = new long[n + 1];
	for ( int d = 0; d < n; ++d )
		dim[d] = template.dimension( d );
	dim[n] = n;
	final Img< FloatType > gradients = factory.create( dim, new FloatType() );
	gradients( Views.extendBorder( template ), gradients );

	dim[n] = numParameters;
	descent = factory.create( dim, new FloatType() );
	computeSteepestDescents( gradients, warpFunction, descent );

	Hinv = computeInverseHessian( descent );

	error = factory.create( template, new FloatType() );
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:26,代码来源:Align.java

示例2: convert

import net.imglib2.RandomAccessibleInterval; //导入方法依赖的package包/类
@Override
public PNGImageNotebookOutput convert(Object object) {

    RandomAccessibleInterval<T> source = (RandomAccessibleInterval<T>) object;

    // NB: Assume <=3 samples in the 3rd dimension means channels. Of course,
    // we have no metadata with a vanilla RAI, but this is a best guess;
    // 3rd dimensions with >3 samples are probably something like Z or time.
    final int cAxis = source.numDimensions() > 2 && source.dimension(2) <= 3 ? 2 : -1;

    String base64Image = (String) ijnb.RAIToPNG(source, 0, 1, cAxis, ValueScaling.AUTO);

    return new PNGImageNotebookOutput(base64Image);
}
 
开发者ID:scijava,项目名称:scijava-jupyter-kernel,代码行数:15,代码来源:RAIToPNGNotebookConverter.java

示例3: display

import net.imglib2.RandomAccessibleInterval; //导入方法依赖的package包/类
/**
 * Converts the given image to a form renderable by scientific notebooks.
 *
 * @param <T>
 * @param source The image to render.
 * @return an object that the notebook knows how to draw onscreen.
 */
default <T extends RealType<T>> Object display(
        final RandomAccessibleInterval<T> source) {
    // NB: Assume <=3 samples in the 3rd dimension means channels. Of course,
    // we have no metadata with a vanilla RAI, but this is a best guess;
    // 3rd dimensions with >3 samples are probably something like Z or time.
    final int cAxis
            = //
            source.numDimensions() > 2 && source.dimension(2) <= 3 ? 2 : -1;

    return RAIToPNG(source, 0, 1, cAxis, ValueScaling.AUTO);
}
 
开发者ID:scijava,项目名称:scijava-jupyter-kernel,代码行数:19,代码来源:ImageJNotebookService.java

示例4: 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

示例5: extendImageByFactor

import net.imglib2.RandomAccessibleInterval; //导入方法依赖的package包/类
public static <T extends RealType<T>> RandomAccessible<T> extendImageByFactor(RandomAccessibleInterval<T> img, int [] extension)
{
	int[] extEachSide = new int[img.numDimensions()];
	for (int i = 0; i <img.numDimensions(); i++){
		extEachSide[i] = (int) (img.dimension(i) < extension[i] ? img.dimension(i) : extension[i]);	
	}
	return new BlendedExtendedMirroredRandomAccesible2<T>(img, extEachSide);
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:9,代码来源:PhaseCorrelation2Util.java

示例6: dummyFuse

import net.imglib2.RandomAccessibleInterval; //导入方法依赖的package包/类
public static <T extends RealType<T>, S extends RealType<S>> RandomAccessibleInterval<FloatType> dummyFuse(RandomAccessibleInterval<T> img1, RandomAccessibleInterval<S> img2, PhaseCorrelationPeak2 shiftPeak, ExecutorService service)
{
	long[] shift = new long[img1.numDimensions()];
	shiftPeak.getShift().localize(shift);
	long[] minImg1 = new long[img1.numDimensions()];
	long[] minImg2 = new long[img1.numDimensions()];
	long[] maxImg1 = new long[img1.numDimensions()];
	long[] maxImg2 = new long[img1.numDimensions()];
	long[] min = new long[img1.numDimensions()];
	long[] max = new long[img1.numDimensions()];
	
	for (int i = 0; i < img1.numDimensions(); i++){
		minImg1[i] = 0;
		maxImg1[i] = img1.dimension(i) -1;
		minImg2[i] = shiftPeak.getShift().getLongPosition(i);
		maxImg2[i] = img2.dimension(i) + minImg2[i] - 1;
		
		min[i] =  Math.min(minImg1[i], minImg2[i]);
		max[i] = Math.max(maxImg1[i], maxImg2[i]);
	}
	
	
	RandomAccessibleInterval<FloatType> res = new ArrayImgFactory<FloatType>().create(new FinalInterval(min, max), new FloatType());
	copyRealImage(Views.iterable(img1), Views.translate(res, min), service);
	copyRealImage(Views.iterable(Views.translate(img2, shift)), Views.translate(res, min), service);
	return res;	
	
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:29,代码来源:PhaseCorrelation2Util.java

示例7: saveFloat

import net.imglib2.RandomAccessibleInterval; //导入方法依赖的package包/类
/**
 * Save a {@link RandomAccessibleInterval} of {@link FloatType} into an HDF5
 * float32 dataset.
 *
 * @param source
 * @param writer
 * @param dataset
 * @param cellDimensions
 */
static public void saveFloat(
		final RandomAccessibleInterval< FloatType > source,
		final IHDF5Writer writer,
		final String dataset,
		final int[] cellDimensions )
{
	final int n = source.numDimensions();
	final long[] dimensions = Intervals.dimensionsAsLongArray( source );
	final IHDF5FloatWriter float32Writer = writer.float32();
	if ( !writer.exists( dataset ) )
		float32Writer.createMDArray(
				dataset,
				reorder( dimensions ),
				reorder( cellDimensions ) );

	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< FloatType > sourceBlock = Views.offsetInterval( source, offset, sourceCellDimensions );
		final MDFloatArray targetCell = new MDFloatArray( reorder( sourceCellDimensions ) );
		int i = 0;
		for ( final FloatType t : Views.flatIterable( sourceBlock ) )
			targetCell.set( t.get(), i++ );

		float32Writer.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,代码行数:48,代码来源:H5Utils.java

示例8: saveDouble

import net.imglib2.RandomAccessibleInterval; //导入方法依赖的package包/类
/**
 * Save a {@link RandomAccessibleInterval} of {@link DoubleType} into an HDF5
 * float64 dataset.
 *
 * @param source
 * @param writer
 * @param dataset
 * @param cellDimensions
 */
static public void saveDouble(
		final RandomAccessibleInterval< DoubleType > source,
		final IHDF5Writer writer,
		final String dataset,
		final int[] cellDimensions )
{
	final int n = source.numDimensions();
	final long[] dimensions = Intervals.dimensionsAsLongArray( source );
	final IHDF5DoubleWriter float64Writer = writer.float64();
	if ( !writer.exists( dataset ) )
		float64Writer.createMDArray(
				dataset,
				reorder( dimensions ),
				reorder( cellDimensions ) );

	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< DoubleType > sourceBlock = Views.offsetInterval( source, offset, sourceCellDimensions );
		final MDDoubleArray targetCell = new MDDoubleArray( reorder( sourceCellDimensions ) );
		int i = 0;
		for ( final DoubleType t : Views.flatIterable( sourceBlock ) )
			targetCell.set( t.get(), i++ );

		float64Writer.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,代码行数:48,代码来源:H5Utils.java

示例9: saveUnsignedShort

import net.imglib2.RandomAccessibleInterval; //导入方法依赖的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

示例10: get

import net.imglib2.RandomAccessibleInterval; //导入方法依赖的package包/类
@Override
public void get( RandomAccessibleInterval< UnsignedByteType > target, int[] offset ) throws MalformedURLException, IOException
{
	int size = Byte.BYTES;
	for ( int d = 0; d < target.numDimensions(); ++d )
		size *= target.dimension( d );
	
	byte[] data = new byte[ size ];
	
	getByteArray( target, data, offset );
	ByteBuffer bb = ByteBuffer.wrap( data );
	for( UnsignedByteType t : Views.flatIterable( target ) )
		t.setInteger( bb.get() );
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:15,代码来源:DatasetBlkUint8.java

示例11: get

import net.imglib2.RandomAccessibleInterval; //导入方法依赖的package包/类
@Override
public void get( RandomAccessibleInterval< UnsignedIntType > target, int[] offset ) throws MalformedURLException, IOException
{
	int size = Integer.BYTES;
	for ( int d = 0; d < target.numDimensions(); ++d )
		size *= target.dimension( d );
	
	byte[] data = new byte[ size ];
	
	getByteArray( target, data, offset );
	ByteBuffer bb = ByteBuffer.wrap( data );
	for( UnsignedIntType t : Views.flatIterable( target ) )
		t.setInteger( bb.getInt() );
	
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:16,代码来源:DatasetBlkRGBA.java

示例12: get

import net.imglib2.RandomAccessibleInterval; //导入方法依赖的package包/类
@Override
public void get( RandomAccessibleInterval< UnsignedLongType > target, int[] offset ) throws MalformedURLException, IOException
{
	int size = Long.BYTES;
	for ( int d = 0; d < target.numDimensions(); ++d )
		size *= target.dimension( d );
	
	byte[] data = new byte[ size ];
	
	getByteArray( target, data, offset );
	ByteBuffer bb = ByteBuffer.wrap( data );
	for( UnsignedLongType t : Views.flatIterable( target ) )
		t.setInteger( bb.getLong() );
	
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:16,代码来源:DatasetBlkLabel.java

示例13: 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


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