• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RealRandomAccess类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: debug

import net.imglib2.RealRandomAccess; //导入依赖的package包/类
public void debug( double[] pt )
{
	RealRandomAccess<T> rra = warpMagImg.realRandomAccess();
	
	rra.setPosition( pt );
	
	System.out.println("at ( 0 0 0 ): ");
	System.out.println( "get val: " + rra.get());
	double[] baseRes = warpMagImg.ra.base.apply( pt );
	
	double[] warpRes = new double[ warpMagImg.ra.warp.numTargetDimensions() ]; 
	warpMagImg.ra.warp.apply( pt, warpRes );

	System.out.println( "base res: " + baseRes[0] + " " + baseRes[1]);
	System.out.println( "warp res: " + warpRes[0] + " " + warpRes[1]);
	
}
 
开发者ID:saalfeldlab,项目名称:bigwarp,代码行数:18,代码来源:WarpMagnitudeSource.java


示例2: render

import net.imglib2.RealRandomAccess; //导入依赖的package包/类
public static < T extends Type< T > > void render( final RealRandomAccessible< T > source, final RandomAccessibleInterval< T > target, final RealTransform transform, final double dx )
{
	final RealRandomAccessible< T > interpolant = Views.interpolate( Views.extendBorder( target ), new NearestNeighborInterpolatorFactory< T >() );
	final RealRandomAccess< T > a = source.realRandomAccess();
	final RealRandomAccess< T > b = interpolant.realRandomAccess();

	for ( double y = 0; y < target.dimension( 1 ); y += dx )
	{
		a.setPosition( y, 1 );

		for ( double x = 0; x < target.dimension( 0 ); x += dx )
		{
			a.setPosition( x, 0 );
			transform.apply( a, b );
			b.get().set( a.get() );
		}
	}
}
 
开发者ID:saalfeldlab,项目名称:z-spacing,代码行数:19,代码来源:LUTRealTransform.java


示例3: TileProcessor

import net.imglib2.RealRandomAccess; //导入依赖的package包/类
public TileProcessor(int threadNumber,
	List<ArrayList<RealRandomAccess<? extends RealType<?>>>> interpolators,
	ArrayList<? extends ImageInterpolation<? extends RealType<?>>> input,
	Vector<Chunk> threadChunks, int numImages, Img<T> output,
	PixelFusion fusion, ClassifiedRegion[] currentTile,
	ArrayList<InvertibleBoundable> transform, ImagePlus[] fusionImp,
	int[] count, double positionsPerThread, double[] offset, int[] loopDim)
{
	this.threadNumber = threadNumber;
	this.threadChunks = threadChunks;
	this.currentTile = currentTile;
	this.transform = transform;
	this.fusionImp = fusionImp;
	this.count = count;
	this.positionsPerThread = positionsPerThread;
	this.offset = offset;
	this.loopDim = loopDim;

	in = getThreadInterpolators(interpolators, threadNumber, input, numImages);
	inPos = new double[numImages][output.numDimensions()];
	myFusion = fusion.copy();
	out = output.randomAccess();
}
 
开发者ID:fiji,项目名称:Stitching,代码行数:24,代码来源:Fusion.java


示例4:

import net.imglib2.RealRandomAccess; //导入依赖的package包/类
/**
* Helper method to lazily initialize the input image interpolators,
* creating one list per thread.
*/
private
	ArrayList<RealRandomAccess<? extends RealType<?>>>
	getThreadInterpolators(
		List<ArrayList<RealRandomAccess<? extends RealType<?>>>> interpolators,
		int threadNumber,
		ArrayList<? extends ImageInterpolation<? extends RealType<?>>> input,
		int numImages)
{
	ArrayList<RealRandomAccess<? extends RealType<?>>> in = null;
	if (threadNumber >= interpolators.size()) {
		in = new ArrayList<RealRandomAccess<? extends RealType<?>>>();
		for (int i = 0; i < numImages; ++i) {
			in.add(input.get(i).createInterpolator());
		}
		interpolators.add(in);
	}
	else {
		in = interpolators.get(threadNumber);
	}
	return in;
}
 
开发者ID:fiji,项目名称:Stitching,代码行数:26,代码来源:Fusion.java


示例5: copyInterpolatedGeneric

import net.imglib2.RealRandomAccess; //导入依赖的package包/类
public static <T extends NumericType< T > > void copyInterpolatedGeneric( RandomAccessible< T > from, IterableInterval< T > to, double[] offset, double scale, InterpolatorFactory< T, RandomAccessible< T > > interpolatorFactory )
{
	final int n = to.numDimensions();
	final double[] fromPosition = new double[ n ];
	Cursor< T > cursor = to.localizingCursor();
	RealRandomAccess< T > interpolator =  interpolatorFactory.create( from );
	while ( cursor.hasNext() )
	{
		final T t = cursor.next();
		for ( int d = 0; d < n; ++d )
		{
			fromPosition[ d ] = scale * cursor.getDoublePosition( d ) + offset[ d ];
		}
		interpolator.setPosition( fromPosition );
		t.set( interpolator.get() );
	}
}
 
开发者ID:imglib,项目名称:imglib2-tests,代码行数:18,代码来源:OpenAndDisplayInterpolated.java


示例6: getAccessor

import net.imglib2.RealRandomAccess; //导入依赖的package包/类
/**
 * Logic stolen from
 * <a href='https://github.com/trakem2/TrakEM2/blob/master/TrakEM2_/src/main/java/org/janelia/intensity/LinearIntensityMap.java'>
 *   TrakEM2 LinearIntensityMap
 * </a>.
 *
 * @return an accessor for deriving warped pixel intensities.
 */
public RealRandomAccess<RealComposite<DoubleType>> getAccessor() {

    final ArrayImg<DoubleType, DoubleArray> warpField =
            ArrayImgs.doubles(values, columnCount, rowCount, VALUES_PER_AFFINE);

    final CompositeIntervalView<DoubleType, RealComposite<DoubleType>>
            collapsedSource = Views.collapseReal(warpField);

    final RandomAccessible<RealComposite<DoubleType>> extendedCollapsedSource = Views.extendBorder(collapsedSource);
    final RealRandomAccessible<RealComposite<DoubleType>> coefficients =
            Views.interpolate(extendedCollapsedSource, interpolatorFactory);

    final double xScale = getXScale();
    final double yScale = getYScale();
    final double[] scale = { xScale, yScale };
    final double[] shift = { 0.5 * xScale , 0.5 * yScale };

    final ScaleAndTranslation scaleAndTranslation = new ScaleAndTranslation(scale, shift);

    final RealRandomAccessible<RealComposite<DoubleType>> stretchedCoefficients =
            RealViews.transform(coefficients, scaleAndTranslation);

    return stretchedCoefficients.realRandomAccess();
}
 
开发者ID:saalfeldlab,项目名称:render,代码行数:33,代码来源:AffineWarpField.java


示例7: defaultInterpolateTest

import net.imglib2.RealRandomAccess; //导入依赖的package包/类
@Test
public void defaultInterpolateTest() {
	
	Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[]{10, 10}, new DoubleType());
	Random r = new Random();
	for (DoubleType d : img) {
		d.set(r.nextDouble());
	}
	
	RealRandomAccess<DoubleType> il2 = Views.interpolate(img, new FloorInterpolatorFactory<DoubleType>()).realRandomAccess();
	RealRandomAccess<DoubleType> opr = ops.transform().interpolateView(img, new FloorInterpolatorFactory<DoubleType>()).realRandomAccess();
	
	il2.setPosition(new double[]{1.75, 5.34});
	opr.setPosition(new double[]{1.75, 5.34});
	assertEquals(il2.get().get(), opr.get().get(), 1e-10);
	
	il2.setPosition(new double[]{3, 7});
	opr.setPosition(new double[]{3, 7});
	assertEquals(il2.get().get(), opr.get().get(), 1e-10);
	
	il2.setPosition(new double[]{8.37, 3.97});
	opr.setPosition(new double[]{8.37, 3.97});
	assertEquals(il2.get().get(), opr.get().get(), 1e-10);
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:25,代码来源:InterpolateViewTest.java


示例8: mapInterval

import net.imglib2.RealRandomAccess; //导入依赖的package包/类
public final static <T extends NumericType<T>> void mapInterval(
		final KernelTransformFloatSeparable xfm,
		final Img<T> src, final Img<T> tgt )
{
	NLinearInterpolatorFactory<T> interp = new NLinearInterpolatorFactory<T>();
	RealRandomAccess<T> sara = Views.interpolate( Views.extendZero(src), interp ).realRandomAccess();
	
	Cursor<T> tc = tgt.cursor();
	float[] pos = new float[src.numDimensions()]; 
	while( tc.hasNext() ){
		tc.fwd();
		tc.localize(pos);
		float[] srcPt  = xfm.transformPoint( pos );
		sara.setPosition( srcPt );
		tc.get().set( sara.get() );
		
	}
}
 
开发者ID:bogovicj,项目名称:hhmi-exp,代码行数:19,代码来源:SimCrack.java


示例9: call

import net.imglib2.RealRandomAccess; //导入依赖的package包/类
@Override
public String call() throws Exception 
{
	final NLinearInterpolatorFactory< FloatType > f = new NLinearInterpolatorFactory< FloatType >();
	
	// make the interpolators and get the transformations
	final RealRandomAccess< FloatType > ir = Views.interpolate( Views.extendMirrorSingle( img ), f ).realRandomAccess();
	final RealRandomAccess< FloatType > wr = blending.realRandomAccess();

	final Cursor< FloatType > cursor = Views.iterable( transformedImg ).localizingCursor();
	final Cursor< FloatType > cursorW = Views.iterable( weightImg ).cursor();

	final float[] s = new float[ 3 ];
	final float[] t = new float[ 3 ];

	cursor.jumpFwd( portion.getStartPosition() );
	cursorW.jumpFwd( portion.getStartPosition() );

	for ( int j = 0; j < portion.getLoopSize(); ++j )
		loop( cursor, cursorW, ir, wr, transform, s, t, offsetX, offsetY, offsetZ, imgSizeX, imgSizeY, imgSizeZ );

	return portion + " finished successfully (transform input & precompute weights).";
}
 
开发者ID:fiji,项目名称:SPIM_Registration,代码行数:24,代码来源:TransformInputAndWeights.java


示例10: call

import net.imglib2.RealRandomAccess; //导入依赖的package包/类
@Override
public String call() throws Exception 
{
	final NLinearInterpolatorFactory< FloatType > f = new NLinearInterpolatorFactory< FloatType >();
	
	// make the interpolators and get the transformations
	final RealRandomAccess< FloatType > ir = Views.interpolate( Views.extendMirrorSingle( img ), f ).realRandomAccess();
	final Cursor< FloatType > cursor = Views.iterable( transformedImg ).localizingCursor();

	final float[] s = new float[ 3 ];
	final float[] t = new float[ 3 ];
	
	cursor.jumpFwd( portion.getStartPosition() );
	
	for ( int j = 0; j < portion.getLoopSize(); ++j )
		loop( cursor, ir, transform, s, t, offsetX, offsetY, offsetZ, imgSizeX, imgSizeY, imgSizeZ );
	
	return portion + " finished successfully (transform input & no weights).";
}
 
开发者ID:fiji,项目名称:SPIM_Registration,代码行数:20,代码来源:TransformInput.java


示例11: upsample

import net.imglib2.RealRandomAccess; //导入依赖的package包/类
public static <T extends RealType<T> & NativeType<T>> Img<T> upsample(Img<T> input, long[] out_size, Interpolator interpType){
	int nDim = input.numDimensions();
	if(nDim != out_size.length){
		return input;
	}
	long[] in_size = new long[nDim]; 
	input.dimensions(in_size);
	float[] upfactor = new float[nDim];
	for(int i=0; i<nDim; i++){
		upfactor[i] = (float)out_size[i]/in_size[i];
	}
	RealRandomAccess< T > interpolant;
	switch(interpType){
		case Linear:
			NLinearInterpolatorFactory<T> NLinterp_factory = new NLinearInterpolatorFactory<T>();
			interpolant = Views.interpolate( Views.extendBorder( input ), NLinterp_factory ).realRandomAccess();
			break;
		case Lanczos:
			LanczosInterpolatorFactory<T> LanczosInterp_factory = new LanczosInterpolatorFactory<T>();
			interpolant = Views.interpolate( Views.extendBorder( input ), LanczosInterp_factory ).realRandomAccess();
			break;
		default: // NearestNeighbor:
			NearestNeighborInterpolatorFactory<T> NNInterp_factory = new NearestNeighborInterpolatorFactory<T>();
			interpolant = Views.interpolate( Views.extendBorder( input ), NNInterp_factory ).realRandomAccess();
			break;
	}
	final ImgFactory< T > imgFactory = new ArrayImgFactory< T >();
	final Img< T > output = imgFactory.create( out_size , input.firstElement().createVariable() );
	Cursor< T > out_cursor = output.localizingCursor();
	float[] tmp = new float[2];
	while(out_cursor.hasNext()){
		out_cursor.fwd();
		for ( int d = 0; d < nDim; ++d )
			tmp[ d ] = out_cursor.getFloatPosition(d) /upfactor[d];
		interpolant.setPosition(tmp);
		out_cursor.get().setReal( Math.round( interpolant.get().getRealFloat() ) );
	}
	return output;
}
 
开发者ID:mpicbg-scicomp,项目名称:Interactive-H-Watershed,代码行数:40,代码来源:Utils.java


示例12: copyRealRandomAccess

import net.imglib2.RealRandomAccess; //导入依赖的package包/类
@Override
public RealRandomAccess<FloatType> copyRealRandomAccess()
{
	final BlendingRealRandomAccess r = new BlendingRealRandomAccess( interval, border, blending );
	r.setPosition( this );
	return r;
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:8,代码来源:BlendingRealRandomAccess.java


示例13: copyToImageStack

import net.imglib2.RealRandomAccess; //导入依赖的package包/类
public static < T extends NumericType< T > & NativeType< T > > ImagePlus copyToImageStack( final RealRandomAccessible< T > rai, final Interval itvl )
{
	final long[] dimensions = new long[ itvl.numDimensions() ];
	itvl.dimensions( dimensions );

	// create the image plus image
	final T t = rai.realRandomAccess().get();
	final ImagePlusImgFactory< T > factory = new ImagePlusImgFactory< T >();
	final ImagePlusImg< T, ? > target = factory.create( itvl, t );

	double k = 0;
	final long N = dimensions[ 0 ] * dimensions[ 1 ] * dimensions[ 2 ];

	final net.imglib2.Cursor< T > c = target.cursor();
	final RealRandomAccess< T > ra = rai.realRandomAccess();
	while ( c.hasNext() )
	{
		c.fwd();
		ra.setPosition( c );
		c.get().set( ra.get() );

		if ( k % 10000 == 0 )
		{
			IJ.showProgress( k / N );
		}
		k++;
	}

	IJ.showProgress( 1.1 );
	try
	{
		return target.getImagePlus();
	}
	catch ( final ImgLibException e )
	{
		e.printStackTrace();
	}

	return null;
}
 
开发者ID:saalfeldlab,项目名称:bigwarp,代码行数:41,代码来源:BigWarpRealExporter.java


示例14: processTile

import net.imglib2.RealRandomAccess; //导入依赖的package包/类
/**
	 * Intermediate helper method to delegate to
	 * {@link #processTile(ClassifiedRegion, int[], int, PixelFusion, ArrayList, ArrayList, LocalizableByDimCursor, float[], int[], int, int[], long[], ImagePlus)}
	 */
private void processTile(ClassifiedRegion r, int depth,
	PixelFusion myFusion, ArrayList<InvertibleBoundable> transform,
	ArrayList<RealRandomAccess<? extends RealType<?>>> in,
	RandomAccess<T> out, double[][] inPos,
	int threadNumber, int[] count, long[] lastDraw, ImagePlus fusionImp)
	throws NoninvertibleModelException
{
	processTile(r, r.classArray(), depth, myFusion, transform, in, out,
		inPos, threadNumber, count, lastDraw, fusionImp);
}
 
开发者ID:fiji,项目名称:Stitching,代码行数:15,代码来源:Fusion.java


示例15: processReal

import net.imglib2.RealRandomAccess; //导入依赖的package包/类
static private final <T extends RealType<T>> Img<T> processReal(final Img<T> img, final long[] dim, final Mode mode) throws Exception {

		final Img<T> res = img.factory().create(dim, img.firstElement().createVariable());

		InterpolatorFactory<T,RandomAccessible<T>> ifac;
		switch (mode) {
		case LINEAR:
			ifac = new NLinearInterpolatorFactory<T>();
			break;
		case NEAREST_NEIGHBOR:
			ifac = new NearestNeighborInterpolatorFactory<T>();
			break;
		default:
			throw new Exception("Resample: unknown mode!");
		}

		final RealRandomAccess<T> inter = ifac.create(Views.extend(img, new OutOfBoundsMirrorFactory<T,Img<T>>(OutOfBoundsMirrorFactory.Boundary.SINGLE)));
		final Cursor<T> c2 = res.localizingCursor();
		final float[] s = new float[dim.length];
		for (int i=0; i<s.length; i++) s[i] = (float)img.dimension(i) / dim[i];
		final long[] d = new long[dim.length];
		final float[] p = new float[dim.length];
		while (c2.hasNext()) {
			c2.fwd();
			c2.localize(d); // TODO "localize" seems to indicate the opposite of what it does
			for (int i=0; i<d.length; i++) p[i] = d[i] * s[i];
			inter.move(p);
			c2.get().set(inter.get());			
		}
		return res;
	}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:32,代码来源:Resample.java


示例16: call

import net.imglib2.RealRandomAccess; //导入依赖的package包/类
@Override
public String call() throws Exception 
{
	// make the blending and get the transformations
	final RealRandomAccess< FloatType > wr = blending.realRandomAccess();

	final Cursor< FloatType > cursorO = Views.iterable( overlapImg ).localizingCursor();
	final Cursor< FloatType > cursorB = Views.iterable( blendingImg ).cursor();

	final float[] s = new float[ 3 ];
	final float[] t = new float[ 3 ];

	cursorO.jumpFwd( portion.getStartPosition() );
	cursorB.jumpFwd( portion.getStartPosition() );

	for ( int j = 0; j < portion.getLoopSize(); ++j )
	{
		// move img cursor forward any get the value (saves one access)
		final FloatType o = cursorO.next();
		cursorO.localize( s );
		
		// move weight cursor forward and get the value 
		final FloatType b = cursorB.next();

		s[ 0 ] += offsetX;
		s[ 1 ] += offsetY;
		s[ 2 ] += offsetZ;

		transform.applyInverse( t, s );

		// compute weights in any part of the image (the border can be negative!)
		wr.setPosition( t );

		o.set( o.get() + 1 );
		b.set( wr.get() );
	}

	return portion + " finished successfully (visualize weights).";
}
 
开发者ID:fiji,项目名称:SPIM_Registration,代码行数:40,代码来源:TransformWeights.java


示例17: loop

import net.imglib2.RealRandomAccess; //导入依赖的package包/类
private static final void loop(
		final Cursor< FloatType > cursor,
		final Cursor< FloatType > cursorW,
		final RealRandomAccess< FloatType > ir,
		final RealRandomAccess< FloatType > wr,
		final AffineTransform3D transform,
		final float[] s, final float[] t,
		final int offsetX, final int offsetY, final int offsetZ,
		final int imgSizeX, final int imgSizeY, final int imgSizeZ )
{
	// move img cursor forward any get the value (saves one access)
	final FloatType v = cursor.next();
	cursor.localize( s );

	// move weight cursor forward and get the value 
	final FloatType w = cursorW.next();

	s[ 0 ] += offsetX;
	s[ 1 ] += offsetY;
	s[ 2 ] += offsetZ;
	
	transform.applyInverse( t, s );
	
	if ( FusionHelper.intersects( t[ 0 ], t[ 1 ], t[ 2 ], imgSizeX, imgSizeY, imgSizeZ ) )
	{
		ir.setPosition( t );

		// do not accept 0 values in the data where image data is present, 0 means no image data is available
		// (used in MVDeconvolution.computeQuotient)
		v.set( Math.max( MVDeconvolution.minValue, ir.get().get() ) );
	}

	// compute weights in any case (the border can be negative!)
	wr.setPosition( t );
	w.set( wr.get() );
}
 
开发者ID:fiji,项目名称:SPIM_Registration,代码行数:37,代码来源:TransformInputAndWeights.java


示例18: loop

import net.imglib2.RealRandomAccess; //导入依赖的package包/类
private static final void loop(
		final Cursor< FloatType > cursor,
		final RealRandomAccess< FloatType > ir,
		final AffineTransform3D transform,
		final float[] s, final float[] t,
		final int offsetX, final int offsetY, final int offsetZ,
		final int imgSizeX, final int imgSizeY, final int imgSizeZ )
{
	// move img cursor forward any get the value (saves one access)
	final FloatType v = cursor.next();
	cursor.localize( s );

	s[ 0 ] += offsetX;
	s[ 1 ] += offsetY;
	s[ 2 ] += offsetZ;

	transform.applyInverse( t, s );

	if ( FusionHelper.intersects( t[ 0 ], t[ 1 ], t[ 2 ], imgSizeX, imgSizeY, imgSizeZ ) )
	{
		ir.setPosition( t );

		// do not accept 0 values in the data where image data is present, 0 means no image data is available
		// (used in MVDeconvolution.computeQuotient)
		v.set( Math.max( MVDeconvolution.minValue, ir.get().get() ) );
	}
}
 
开发者ID:fiji,项目名称:SPIM_Registration,代码行数:28,代码来源:TransformInput.java


示例19: realRandomAccess

import net.imglib2.RealRandomAccess; //导入依赖的package包/类
@Override
public RealRandomAccess<FloatType> realRandomAccess()
{ 
	return Views.interpolate(
		Views.extendZero( this.contentBasedImg ),
		new NLinearInterpolatorFactory< FloatType >()
		).realRandomAccess();
}
 
开发者ID:fiji,项目名称:SPIM_Registration,代码行数:9,代码来源:ContentBased.java


示例20: realRandomAccess

import net.imglib2.RealRandomAccess; //导入依赖的package包/类
@Override
public RealRandomAccess<FloatType> realRandomAccess()
{
	return new BlendingRealRandomAccess( interval, border, blending );
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:6,代码来源:Blending.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PlaceholderAPI类代码示例发布时间:2022-05-21
下一篇:
Java StreamSupport类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap