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


Java RandomAccessibleInterval.numDimensions方法代码示例

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


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

示例1: reorder

import net.imglib2.RandomAccessibleInterval; //导入方法依赖的package包/类
private static <T extends RealType<T>> RandomAccessibleInterval<T> reorder(
	RandomAccessibleInterval<T> image, int[] dimOrder)
{
	RandomAccessibleInterval<T> output = image;

	// Array which contains for each dimension information on which dimension it is right now
	int[] moved = IntStream.range(0, image.numDimensions()).toArray();

	// Loop over all dimensions and move it to the right spot
	for (int i = 0; i < image.numDimensions(); i++) {
		int from = moved[i];
		int to = dimOrder[i];

		// Move the dimension to the right dimension
		output = Views.permute(output, from, to);

		// Now we have to update which dimension was moved where
		moved[i] = to;
		moved = Arrays.stream(moved).map(v -> v == to ? from : v).toArray();
	}
	return output;
}
 
开发者ID:imagej,项目名称:imagej-tensorflow,代码行数:23,代码来源:Tensors.java

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

示例3: BlendedExtendedMirroredRandomAccesible2

import net.imglib2.RandomAccessibleInterval; //导入方法依赖的package包/类
public BlendedExtendedMirroredRandomAccesible2(RandomAccessibleInterval<T> img, int[] border) {
	this.img = img;
	this.numDimensions = img.numDimensions();
	
	float[] blendingBorder = new float[numDimensions];
	float[] border2 = new float[numDimensions];
	
	this.extDims = new FinalInterval(img);		
	for (int i = 0; i < numDimensions; i++)
	{
		extDims = Intervals.expand(extDims, border[i], i);
		blendingBorder[i] = border[i];
		border2[i] = 0.0f;
	}
	
	this.blending = new BlendingRealRandomAccessible(extDims, border2, blendingBorder);
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:18,代码来源:BlendedExtendedMirroredRandomAccesible2.java

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

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

示例6: reverse

import net.imglib2.RandomAccessibleInterval; //导入方法依赖的package包/类
/** Flips all dimensions {@code d0,d1,...,dn -> dn,...,d1,d0}. */
public static <T extends RealType<T>> RandomAccessibleInterval<T> reverse(
	RandomAccessibleInterval<T> image)
{
	RandomAccessibleInterval<T> reversed = image;
	for (int d = 0; d < image.numDimensions() / 2; d++) {
		reversed = Views.permute(reversed, d, image.numDimensions() - d - 1);
	}
	return reversed;
}
 
开发者ID:imagej,项目名称:imagej-tensorflow,代码行数:11,代码来源:Tensors.java

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

示例8: calculatePCM

import net.imglib2.RandomAccessibleInterval; //导入方法依赖的package包/类
public static <T extends ComplexType<T> & NativeType<T>, S extends ComplexType<S> & NativeType <S>, R extends RealType<R>> RandomAccessibleInterval<R> calculatePCM(
		RandomAccessibleInterval<T> fft1, RandomAccessibleInterval<S> fft2, ImgFactory<R> factory, R type, ExecutorService service){
	
	long[] paddedDimensions = new long[fft1.numDimensions()];
	long[] realSize = new long[fft1.numDimensions()];
	
	FFTMethods.dimensionsComplexToRealFast(fft1, paddedDimensions, realSize);
	RandomAccessibleInterval<R> res = factory.create(realSize, type);
	
	final T typeT = Views.iterable(fft1).firstElement().createVariable();
	final S typeS = Views.iterable(fft2).firstElement().createVariable();
	RandomAccessibleInterval< T > fft1Copy;
	RandomAccessibleInterval< S > fft2Copy;

	try
	{
		fft1Copy = factory.imgFactory( typeT ).create(fft1, typeT );
		fft2Copy = factory.imgFactory( typeS ).create(fft2, typeS );
	}
	catch ( IncompatibleTypeException e )
	{
		throw new RuntimeException( "Cannot instantiate Img for type " + typeS.getClass().getSimpleName() + " or " + typeT.getClass().getSimpleName() );
	}
	
	
	calculatePCM(fft1, fft1Copy, fft2, fft2Copy, res, service);
	
	return res;
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:30,代码来源:PhaseCorrelation2.java

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

示例10: extendImageToSize

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

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

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

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

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

示例15: GrowingStoreRandomAccessible

import net.imglib2.RandomAccessibleInterval; //导入方法依赖的package包/类
public GrowingStoreRandomAccessible( RandomAccessibleInterval< T > initialStore, Factory< T > factory )
{
	this.nDim = initialStore.numDimensions();
	this.min = new long[ this.nDim ];
	this.max = new long[ this.nDim ];
	this.dimensions = new long[ this.nDim ];
	initStore( initialStore );
	this.factory = factory;
	this.t = initialStore.randomAccess().get().createVariable();
	this.randomAccessRefs = new ArrayList<>();
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:12,代码来源:GrowingStoreRandomAccessible.java


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