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


Java RealRandomAccessible.realRandomAccess方法代码示例

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


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

示例1: render

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

示例2: getAccessor

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

示例3: LabelMultiSetIdPicker

import net.imglib2.RealRandomAccessible; //导入方法依赖的package包/类
public LabelMultiSetIdPicker(
		final ViewerPanel viewer,
		final RealRandomAccessible< LabelMultisetType > labels )
{
	this.viewer = viewer;
	this.labels = labels;
	labelAccess = labels.realRandomAccess();
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:9,代码来源:LabelMultiSetIdPicker.java

示例4: PairLabelMultiSetLongIdPicker

import net.imglib2.RealRandomAccessible; //导入方法依赖的package包/类
public PairLabelMultiSetLongIdPicker(
		final ViewerPanel viewer,
		final RealRandomAccessible< Pair< LabelMultisetType, LongType > > labels )
{
	this.viewer = viewer;
	this.labels = labels;
	labelAccess = labels.realRandomAccess();
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:9,代码来源:PairLabelMultiSetLongIdPicker.java

示例5: copyToImageStack

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

示例6: TransformedInterpolatedRealRandomAccess

import net.imglib2.RealRandomAccessible; //导入方法依赖的package包/类
public TransformedInterpolatedRealRandomAccess(
		final RealRandomAccessible< T > realRandomAccessible,
		final T zero,
		final Interval transformedInterval,
		final AffineTransform3D transform,
		final int[] offset )
{
	super( realRandomAccessible.numDimensions() );

	this.transformedInterval = transformedInterval;
	this.zero = zero;
	this.realRandomAccessible = realRandomAccessible;
	this.transform = transform;
	this.offset = new int[ offset.length ];

	for ( int d = 0; d < n; ++d )
		this.offset[ d ] = offset[ d ];

	this.realRandomAccess = realRandomAccessible.realRandomAccess();

	final double[] imatrix = transform.inverse().getRowPackedCopy();

	this.i00 = imatrix[ 0 ];
	this.i01 = imatrix[ 1 ];
	this.i02 = imatrix[ 2 ];
	this.i03 = imatrix[ 3 ];

	this.i10 = imatrix[ 4 ];
	this.i11 = imatrix[ 5 ];
	this.i12 = imatrix[ 6 ];
	this.i13 = imatrix[ 7 ];

	this.i20 = imatrix[ 8 ];
	this.i21 = imatrix[ 9 ];
	this.i22 = imatrix[ 10 ];
	this.i23 = imatrix[ 11 ];

	this.tmp = new float[ n ];
}
 
开发者ID:fiji,项目名称:SPIM_Registration,代码行数:40,代码来源:TransformedInterpolatedRealRandomAccess.java

示例7: estimateQuadraticFromMatrix

import net.imglib2.RealRandomAccessible; //导入方法依赖的package包/类
public static < T extends RealType< T >, W extends RealType< W > > void estimateQuadraticFromMatrix(
		final RandomAccessibleInterval< T > correlations,
		final double[] scalingFactors,
		final double[] coordinates,
		final RandomAccessibleInterval< double[] > localFits,
		final double regularizerWeight,
		final int comparisonRange,
		final int nIterations,
		final RandomAccessibleInterval< W > pairwiseWeights )
{

	final double inverseRegularizerWeight = 1 - regularizerWeight;

	final RandomAccess< T > corrAccess = correlations.randomAccess();
	final RandomAccess< W > wAccess = pairwiseWeights.randomAccess();

	for ( int iter = 0; iter < nIterations; ++iter )
	{

		final Cursor< double[] > fitCursor = Views.iterable( localFits ).cursor();

		for ( int n = 0; fitCursor.hasNext(); ++n )
		{

			// is this allocation expensive? should this occur one loop
			// further outside?
			final double[] oldScalingFactors = scalingFactors.clone();

			corrAccess.setPosition( n, 0 );
			wAccess.setPosition( n, 0 );

			final double[] lf = fitCursor.next();
			final RealRandomAccessible< DoubleType > interpolatedFit = Views.interpolate( Views.extendValue( ArrayImgs.doubles( lf, lf.length ), new DoubleType( Double.NaN ) ), new NLinearInterpolatorFactory< DoubleType >() );
			final RealRandomAccess< DoubleType > ra = interpolatedFit.realRandomAccess();
			double enumeratorSum = 0.0;
			double denominatorSum = 0.0;
			final int minVal = Math.max( n - comparisonRange, 0 );
			final int maxVal = Math.min( n + comparisonRange, scalingFactors.length );
			for ( int i = minVal; i < maxVal; ++i )
			{
				if ( i == n )
					continue;
				corrAccess.setPosition( i, 1 );
				wAccess.setPosition( i, 1 );
				ra.setPosition( Math.abs( coordinates[ i ] - coordinates[ n ] ), 0 );
				// fits are negative because LUTRealtransform requires
				// increasing function
				final double fitVal = -ra.get().get();
				final double measure = corrAccess.get().getRealDouble();
				if ( Double.isNaN( fitVal ) || Double.isNaN( measure ) || measure <= 0.0 )
					continue;
				final double w = wAccess.get().getRealDouble();
				final double prod = oldScalingFactors[ i ] * measure;
				final double h = w * prod;

				enumeratorSum += h * fitVal;
				denominatorSum += h * prod;
			}
			final double result = enumeratorSum / denominatorSum * inverseRegularizerWeight + regularizerWeight * oldScalingFactors[ n ];
			if ( !Double.isNaN( result ) )
				scalingFactors[ n ] = result;
		}

	}
}
 
开发者ID:saalfeldlab,项目名称:z-spacing,代码行数:66,代码来源:EstimateScalingFactors.java


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