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


Java RandomAccessibleInterval类代码示例

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


RandomAccessibleInterval类属于net.imglib2包,在下文中一共展示了RandomAccessibleInterval类的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: subspaceConnectivity

import net.imglib2.RandomAccessibleInterval; //导入依赖的package包/类
/** Process connectivity for one 3D subspace */
private void subspaceConnectivity(final String label,
	final RandomAccessibleInterval<BitType> subspace)
{
    statusService.showStatus("Connectivity: calculating connectivity");
	final double eulerCharacteristic = eulerCharacteristicOp.calculate(subspace)
		.get();
       statusService.showStatus("Connectivity: calculating euler correction");
	final double edgeCorrection = eulerCorrectionOp.calculate(subspace).get();
	final double correctedEuler = eulerCharacteristic - edgeCorrection;
	final double connectivity = 1 - correctedEuler;
	final double connectivityDensity = calculateConnectivityDensity(subspace,
		connectivity);

	addResults(label, eulerCharacteristic, correctedEuler, connectivity,
		connectivityDensity);
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:18,代码来源:ConnectivityWrapper.java

示例3: applySplit

import net.imglib2.RandomAccessibleInterval; //导入依赖的package包/类
/**
 * Splits a subspace along the given coordinates
 * <p>
 * For example, if you have a 5D {X, Y, Z, C, T} hyperstack, and give the
 * coordinates {{3, 0}, {4, 1}} you'll get a 3D {X, Y, Z} subspace of the
 * first channel, and second time frame
 * </p>
 * 
 * @param hyperstack an n-dimensional image
 * @param splitCoordinates (dimension, position) pairs describing the
 *          hyperstack split
 * @return The subspace interval
 */
private static <T extends RealType<T> & NativeType<T>>
	RandomAccessibleInterval<T> applySplit(final ImgPlus<T> hyperstack,
		final List<ValuePair<IntType, LongType>> splitCoordinates)
{
	final List<ValuePair<IntType, LongType>> workingSplit = createWorkingCopy(
		splitCoordinates);
	RandomAccessibleInterval<T> slice = hyperstack;
	for (int i = 0; i < workingSplit.size(); i++) {
		final int dimension = workingSplit.get(i).a.get();
		final long position = workingSplit.get(i).b.get();
		slice = Views.hyperSlice(slice, dimension, position);
		decrementIndices(workingSplit, dimension);
	}
	return slice;
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:29,代码来源:HyperstackUtils.java

示例4: subSpaceFraction

import net.imglib2.RandomAccessibleInterval; //导入依赖的package包/类
/** Process surface fraction for one 3D subspace in the n-dimensional image */
@SuppressWarnings("unchecked")
private double[] subSpaceFraction(
	RandomAccessibleInterval<BitType> subSpace)
{
       statusService.showStatus("Surface fraction: creating surface");
	// Create masks for marching cubes
	final RandomAccessibleInterval totalMask = raiCopy.calculate(subSpace);
	// Because we want to create a surface from the whole image, set everything
	// in the mask to foreground
	((Img<BitType>) totalMask).forEach(BitType::setOne);

	// Create surface meshes and calculate their volume. If the input interval
	// wasn't binary, we'd have to threshold it before these calls.
	final Mesh thresholdMesh = marchingCubes.calculate(subSpace);
       statusService.showStatus("Surface fraction: calculating volume");
	final double rawThresholdVolume = meshVolume.calculate(thresholdMesh).get();
	final Mesh totalMesh = marchingCubes.calculate(totalMask);
	final double rawTotalVolume = meshVolume.calculate(totalMesh).get();

	final double thresholdVolume = rawThresholdVolume * elementSize;
	final double totalVolume = rawTotalVolume * elementSize;
	final double ratio = thresholdVolume / totalVolume;

	return new double[] { thresholdVolume, totalVolume, ratio };
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:27,代码来源:SurfaceFractionWrapper.java

示例5: runRotationsInParallel

import net.imglib2.RandomAccessibleInterval; //导入依赖的package包/类
private List<Vector3d> runRotationsInParallel(
	final RandomAccessibleInterval<BitType> interval) throws ExecutionException,
	InterruptedException
{
	final ExecutorService executor = Executors.newFixedThreadPool(5);
	final Callable<List<Vector3d>> milTask = () -> milOp.calculate(interval);
	final List<Future<List<Vector3d>>> futures = Stream.generate(() -> milTask)
		.limit(rotations).map(executor::submit).collect(toList());
	final List<Vector3d> pointCloud = Collections.synchronizedList(
		new ArrayList<>(rotations * 3));
	final int futuresSize = futures.size();
	for (int j = 0; j < futuresSize; j++) {
		statusService.showProgress(j, futuresSize);
		final List<Vector3d> points = futures.get(j).get();
		pointCloud.addAll(points);

	}
	executor.shutdown();
	return pointCloud;
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:21,代码来源:AnisotropyWrapper.java

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

示例7: align

import net.imglib2.RandomAccessibleInterval; //导入依赖的package包/类
public AffineTransform align(final RandomAccessibleInterval< T > image, final int maxIterations,
		final double minParameterChange)
{
	lastAlignConverged = false;
	ExecutorService service = Executors.newFixedThreadPool( Runtime.getRuntime().availableProcessors() * 2);

	currentTransform.set( new AffineTransform( n ) );
	int i = 0;
	while ( i < maxIterations )
	{
		++i;
		if ( alignStep( image, service ) < minParameterChange )
		{
			lastAlignConverged = true;
			break;
		}
	}
	System.out.println( "computed " + i + " iterations." );
	return currentTransform;
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:21,代码来源:Align.java

示例8: gradient

import net.imglib2.RandomAccessibleInterval; //导入依赖的package包/类
/**
 * Compute the partial derivative of source in a particular dimension.
 *
 * @param source
 *            source image, has to provide valid data in the interval of the
 *            gradient image plus a one pixel border in dimension.
 * @param target
 *            output image, the partial derivative of source in the
 *            specified dimension.
 * @param dimension
 *            along which dimension the partial derivatives are computed
 * @param <T> pixel type source
 * @param <S> pixel type target
 */
public static < T extends RealType< T >, S extends RealType< S > > void gradient(
		final RandomAccessible< T > source,
		final RandomAccessibleInterval< S > target,
		final int dimension )
{
	final Cursor< T > front = Views.flatIterable(
			Views.interval( source,
					Intervals.translate( target, 1, dimension ) ) ).cursor();
	final Cursor< T > back = Views.flatIterable(
			Views.interval( source,
					Intervals.translate( target, -1, dimension ) ) ).cursor();
	for( final S t : Views.flatIterable( target ) )
	{
		t.setReal( front.next().getRealDouble() - back.next().getRealDouble());
		t.mul( 0.5 );
	}
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:32,代码来源:Align.java

示例9: pickSpecific

import net.imglib2.RandomAccessibleInterval; //导入依赖的package包/类
public <T extends RealType<T>> RandomAccessibleInterval< T > pickSpecific(List<BasicViewDescription< ? >> vds,
		   List<RandomAccessibleInterval< T >> rais)
{
	for (int i = 0; i< vds.size(); i++)
	{
		if (entityClass == TimePoint.class)
		{
			if (vds.get( i ).getTimePoint() == instance)
				if (vds.get( i ).isPresent())
					return rais.get( i );
			
			continue;
		}
		
		if (vds.get( i ).getViewSetup().getAttribute( entityClass ).equals( instance ))
			if (vds.get( i ).isPresent())
				return rais.get( i );
	}
	
	// this should only be reached if the requested view is not present
	return null;
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:23,代码来源:GroupedViewAggregator.java

示例10: aggregate

import net.imglib2.RandomAccessibleInterval; //导入依赖的package包/类
public <T extends RealType<T>> RandomAccessibleInterval< T > aggregate(
		List<RandomAccessibleInterval< T >> rais,
		List<? extends ViewId> vids,
		AbstractSequenceDescription< ?, ? extends BasicViewDescription< ? >, ? > sd
		)
{
	Map<BasicViewDescription< ? >, RandomAccessibleInterval<T>> map = new HashMap<>();
	
	for (int i = 0; i < vids.size(); i++)
	{
		ViewId vid = vids.get( i );
		BasicViewDescription< ? > vd = sd.getViewDescriptions().get( vid );
		map.put( vd, rais.get( i ) );
	}
	
	for (Action< ? > action : actions)
	{
		map = action.aggregate( map );
	}
	
	// return the first RAI still present
	// ideally, there should be only one left
	return map.values().iterator().next();
	
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:26,代码来源:GroupedViewAggregator.java

示例11: getFloatImage

import net.imglib2.RandomAccessibleInterval; //导入依赖的package包/类
@Override
public RandomAccessibleInterval< FloatType > getFloatImage(
		int timepointId, boolean normalize, ImgLoaderHint... hints )
{
	final Random rnd = new Random( setupId );

	final Img< FloatType > img = ArrayImgs.floats( 512, 512, 86 );

	final float scale;
	
	if ( normalize )
		scale = 1;
	else
		scale = 20000;
	
	for ( final FloatType t : img )
		t.set( rnd.nextFloat() * scale);

	return img;
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:21,代码来源:MinimalTest.java

示例12: main

import net.imglib2.RandomAccessibleInterval; //导入依赖的package包/类
public static void main( String[] args )
{
	SpimData spimData = grid3x2();
	SequenceDescription sd = spimData.getSequenceDescription();
	ImgLoader i = sd.getImgLoader();

	TimePoint firstTp = sd.getTimePoints().getTimePointsOrdered().get( 0 );
	int tpId = firstTp.getId();

	for ( final ViewSetup vs: spimData.getSequenceDescription().getViewSetups().values() )
	{
		SetupImgLoader< ? > sil = i.getSetupImgLoader( vs.getId() );
		ViewDescription vd = sd.getViewDescription( tpId, vs.getId() );
		
		Tile t = vd.getViewSetup().getTile();

		if ( t.hasLocation() )
			System.out.println( "Loading: " + t.getName() + " " + Util.printCoordinates( t.getLocation() ) + " " + vd.getViewSetup().getChannel().getName() );
		else
			System.out.println( "Loading: " + t.getName() + " (unknown location) " + vd.getViewSetup().getChannel().getName() );
		
		ImageJFunctions.show( (RandomAccessibleInterval< UnsignedShortType >)sil.getImage( tpId, ImgLoaderHints.LOAD_COMPLETELY ) ).resetDisplayRange();
	}
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:25,代码来源:GenerateSpimData.java

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

示例14: calculatePCM

import net.imglib2.RandomAccessibleInterval; //导入依赖的package包/类
public static <T extends RealType<T>, S extends RealType<S>, R extends RealType<R>, C extends ComplexType<C>> RandomAccessibleInterval<R> calculatePCM(
		RandomAccessibleInterval<T> img1, RandomAccessibleInterval<S> img2, int[] extension,
		ImgFactory<R> factory, R type, ImgFactory<C> fftFactory, C fftType, ExecutorService service){

	
	// TODO: Extension absolute per dimension in pixels, i.e. int[] extension
	// TODO: not bigger than the image dimension because the second mirroring is identical to the image
	
	Dimensions extSize = PhaseCorrelation2Util.getExtendedSize(img1, img2, extension);
	long[] paddedDimensions = new long[extSize.numDimensions()];
	long[] fftSize = new long[extSize.numDimensions()];
	FFTMethods.dimensionsRealToComplexFast(extSize, paddedDimensions, fftSize);
	
	RandomAccessibleInterval<C> fft1 = fftFactory.create(fftSize, fftType);
	RandomAccessibleInterval<C> fft2 = fftFactory.create(fftSize, fftType);
	
	FFT.realToComplex(Views.interval(PhaseCorrelation2Util.extendImageByFactor(img1, extension), 
			FFTMethods.paddingIntervalCentered(img1, new FinalInterval(paddedDimensions))), fft1, service);
	FFT.realToComplex(Views.interval(PhaseCorrelation2Util.extendImageByFactor(img2, extension), 
			FFTMethods.paddingIntervalCentered(img2, new FinalInterval(paddedDimensions))), fft2, service);
	
	RandomAccessibleInterval<R> pcm = calculatePCMInPlace(fft1, fft2, factory, type, service);
	return pcm;
	
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:26,代码来源:PhaseCorrelation2.java

示例15: getShift

import net.imglib2.RandomAccessibleInterval; //导入依赖的package包/类
/**
 * calculate the shift between two images from the phase correlation matrix
 * @param pcm the phase correlation matrix of img1 and img2
 * @param img1 source image 1
 * @param img2 source image 2
 * @param nHighestPeaks the number of peaks in pcm to check via cross. corr.
 * @param minOverlap minimal overlap (in pixels)
 * @param subpixelAccuracy whether to do subpixel shift peak localization or not
 * @param interpolateSubpixel whether to interpolate the subpixel shift in cross. corr.
 * @param service thread pool
 * @return best (highest c.c.) shift peak
 */
public static <T extends RealType<T>, S extends RealType<S>, R extends RealType<R>> PhaseCorrelationPeak2 getShift(
		RandomAccessibleInterval<R> pcm, RandomAccessibleInterval<T> img1, RandomAccessibleInterval<S> img2, int nHighestPeaks,
		long minOverlap, boolean subpixelAccuracy, boolean interpolateSubpixel, ExecutorService service)
{
	System.out.println( "PCM" );
	List<PhaseCorrelationPeak2> peaks = PhaseCorrelation2Util.getPCMMaxima(pcm, service, nHighestPeaks, subpixelAccuracy);
	//peaks = PhaseCorrelation2Util.getHighestPCMMaxima(peaks, nHighestPeaks);
	System.out.println( "expand" );
	PhaseCorrelation2Util.expandPeakListToPossibleShifts(peaks, pcm, img1, img2);
	System.out.print( "cross " );
	long t = System.currentTimeMillis();
	PhaseCorrelation2Util.calculateCrossCorrParallel(peaks, img1, img2, minOverlap, service, interpolateSubpixel);
	System.out.println( (System.currentTimeMillis() - t) );
	System.out.println( "sort" );
	Collections.sort(peaks, Collections.reverseOrder(new PhaseCorrelationPeak2.ComparatorByCrossCorrelation()));
	System.out.println( "done" );

	if (peaks.size() > 0)
		return peaks.get(0);
	else
		return null;
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:35,代码来源:PhaseCorrelation2.java


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