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


Java Views.interpolate方法代码示例

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


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

示例1: main

import net.imglib2.view.Views; //导入方法依赖的package包/类
final static public void main( final String[] args )
	{
		new ImageJ();
		final ImagePlus imp = new ImagePlus( "http://media.npr.org/images/picture-show-flickr-promo.jpg" );
		imp.show();

		final float[] pixels = ( float[] ) imp.getProcessor().convertToFloat().getPixels();
		final ArrayImg< FloatType, FloatArray > img = ArrayImgs.floats( pixels, imp.getWidth(), imp.getHeight() );

		final double[] lut = new double[ Math.max( imp.getWidth(), imp.getHeight() ) ];
		for ( int i = 0; i < lut.length; ++i )
			lut[ i ] = i + Math.pow( i, 1.5 );

		final SingleDimensionLUTRealTransform transform = new SingleDimensionLUTRealTransform( lut, 2, 2, 1 );
		final RealRandomAccessible< FloatType > source = Views.interpolate( Views.extendBorder( img ), new NLinearInterpolatorFactory< FloatType >() );
		final RandomAccessible< FloatType > target = new RealTransformRandomAccessible< FloatType, RealTransform >( source, transform );
		final RandomAccessible< FloatType > target2 = RealViews.transform( source, transform );

//		RealViews.transformReal(source, transform);

		ImageJFunctions.show( Views.interval( target, new FinalInterval( imp.getWidth(), imp.getHeight() ) ) );
		ImageJFunctions.show( Views.interval( target2, new FinalInterval( imp.getWidth(), imp.getHeight() ) ) );
	}
 
开发者ID:saalfeldlab,项目名称:z-spacing,代码行数:24,代码来源:SingleDimensionLUTRealTransform.java

示例2: render

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

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

示例4: defaultRasterTest

import net.imglib2.view.Views; //导入方法依赖的package包/类
@Test
public void defaultRasterTest() {
	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());
	}
	RealRandomAccessible<DoubleType> realImg = Views.interpolate(img, new FloorInterpolatorFactory<DoubleType>());
	
	RandomAccessibleOnRealRandomAccessible<DoubleType> il2 = Views.raster(realImg);
	RandomAccessibleOnRealRandomAccessible<DoubleType> opr = ops.transform().rasterView(realImg);
	
	Cursor<DoubleType> il2C = Views.interval(il2, img).localizingCursor();
	RandomAccess<DoubleType> oprRA = Views.interval(opr, img).randomAccess();
	
	while (il2C.hasNext()) {
		il2C.next();
		oprRA.setPosition(il2C);
		assertEquals(il2C.get().get(), oprRA.get().get(), 1e-10);
	}
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:22,代码来源:RasterViewTest.java

示例5: getInterpolatedSource

import net.imglib2.view.Views; //导入方法依赖的package包/类
@Override
public RealRandomAccessible< T > getInterpolatedSource( final int t, final int level, final Interpolation method )
{
	InterpolatorFactory< T, RandomAccessible< T >> factory;
	switch ( method )
	{
	default:
	case NEARESTNEIGHBOR:
		factory = new NearestNeighborInterpolatorFactory< T >();
		break;
	case NLINEAR:
		factory = new NLinearInterpolatorFactory< T >();
		break;
	}
	final T zero = img.firstElement().createVariable();
	zero.setZero();
	return Views.interpolate( Views.extendValue( getSource( t, level ), zero ), factory );
}
 
开发者ID:fiji,项目名称:MaMuT,代码行数:19,代码来源:ImgPlusSource.java

示例6: getInterpolatedSource

import net.imglib2.view.Views; //导入方法依赖的package包/类
@Override
public RealRandomAccessible< VolatileARGBType > getInterpolatedSource( final int t, final int level, final Interpolation method )
{
	final ExtendedRandomAccessibleInterval< VolatileARGBType, RandomAccessibleInterval< VolatileARGBType > > extendedSource =
			Views.extendValue( getSource( t,  level ), new VolatileARGBType( 0 ) );
	switch ( method )
	{
	case NLINEAR :
		return Views.interpolate( extendedSource, interpolatorFactories[ 1 ] );
	default :
		return Views.interpolate( extendedSource, interpolatorFactories[ 0 ] );
	}
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:14,代码来源:AbstractARGBConvertedLabelsSource.java

示例7: generateTransformed

import net.imglib2.view.Views; //导入方法依赖的package包/类
public static < T extends RealType< T > > RealRandomAccessible< T > generateTransformed(
		final RandomAccessibleInterval< T > input,
		final Transform permutation,
		final InvertibleRealTransform lut,
		final T dummy )
{
	dummy.setReal( Double.NaN );
	final IntervalView< T > permuted = Views.interval( new TransformView< T >( input, permutation ), input );
	final RealRandomAccessible< T > interpolated = Views.interpolate( Views.extendValue( permuted, dummy ), new NLinearInterpolatorFactory< T >() );
	return RealViews.transformReal( interpolated, lut );
}
 
开发者ID:saalfeldlab,项目名称:z-spacing,代码行数:12,代码来源:ZPositionCorrection.java

示例8: main

import net.imglib2.view.Views; //导入方法依赖的package包/类
final static public void main( final String[] args )
	{

		new ImageJ();
		final ImagePlus imp = new ImagePlus( "http://media.npr.org/images/picture-show-flickr-promo.jpg" );
		imp.show();

		final float[] pixels = ( float[] ) imp.getProcessor().convertToFloat().getPixels();
		final ArrayImg< FloatType, FloatArray > img = ArrayImgs.floats( pixels, imp.getWidth(), imp.getHeight() );

		final double[] lut = new double[ Math.max( imp.getWidth(), imp.getHeight() ) ];
		for ( int i = 0; i < lut.length; ++i )
			lut[ i ] = i + Math.pow( i, 1.5 );

		final LUTRealTransform transform = new LUTRealTransform( lut, 2, 2 );
		final RealRandomAccessible< FloatType > source = Views.interpolate( Views.extendBorder( img ), new NLinearInterpolatorFactory< FloatType >() );
		final RandomAccessible< FloatType > target = new RealTransformRandomAccessible< FloatType, RealTransform >( source, transform );
		final RandomAccessible< FloatType > target2 = RealViews.transform( source, transform );

//		RealViews.transformReal(source, transform);

		final ArrayImg< FloatType, FloatArray > targetImg = ArrayImgs.floats( imp.getWidth(), imp.getHeight() );
		render( source, targetImg, transform, 0.05 );

		ImageJFunctions.show( Views.interval( target, new FinalInterval( imp.getWidth(), imp.getHeight() ) ) );
		ImageJFunctions.show( Views.interval( target2, new FinalInterval( imp.getWidth(), imp.getHeight() ) ) );
		ImageJFunctions.show( targetImg );
	}
 
开发者ID:saalfeldlab,项目名称:z-spacing,代码行数:29,代码来源:LUTRealTransform.java

示例9: ImageInterpolation

import net.imglib2.view.Views; //导入方法依赖的package包/类
public ImageInterpolation( final Img< T > image, final InterpolatorFactory< T, RandomAccessible< T > > interpolatorFactory, final boolean mirror )
{
	this.image = image;
	this.interpolatorFactory = interpolatorFactory;
	if ( mirror )
		this.interpolated = Views.interpolate( Views.extendMirrorSingle( image ), interpolatorFactory );
	else
		this.interpolated = Views.interpolate( Views.extendZero( image ), interpolatorFactory );
}
 
开发者ID:fiji,项目名称:Stitching,代码行数:10,代码来源:ImageInterpolation.java

示例10: xfmToView

import net.imglib2.view.Views; //导入方法依赖的package包/类
public static <T extends RealType<T>> RealTransformRandomAccessible<T, InverseRealTransform> xfmToView(
		InvertibleRealTransform xfm, 
		RandomAccessible<T> src, 
		InterpolatorFactory<T, RandomAccessible<T>> interpFactory) 
{
	RealRandomAccessible<T> interpolant = Views.interpolate(
			src, interpFactory);

	RealTransformRandomAccessible<T, InverseRealTransform> rv = 
		RealViews.transform( interpolant, xfm.inverse() );

	return rv;
}
 
开发者ID:bogovicj,项目名称:hhmi-exp,代码行数:14,代码来源:TransformTools.java

示例11: getCurrentCorrelation

import net.imglib2.view.Views; //导入方法依赖的package包/类
public double getCurrentCorrelation(final RandomAccessibleInterval< T > image)
{
	final RealRandomAccessible< T > interpolated = Views.interpolate( Views.extendBorder( image ), new NLinearInterpolatorFactory< T >() );
	final RandomAccessible< T > warped = RealViews.affine( interpolated, currentTransform );
	return PhaseCorrelation2Util.getCorrelation( Views.interval( warped, template ), template );
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:7,代码来源:Align.java

示例12: computeDifference

import net.imglib2.view.Views; //导入方法依赖的package包/类
/**
 * Compute the pixel-wise difference between an affine-transformed source
 * image and a target image.
 *
 * @param source
 *            The source image.
 * @param transform
 *            A coordinate transformation to apply to the source image.
 * @param target
 *            The target image.
 * @param difference
 *            Output image. The pixel-wise difference between the
 *            transformed source image and the target image is stored here.
 *            
 * @param <T> pixel type source
 * @param <S> pixel type target
 */
public static < T extends RealType< T >,  S extends RealType< S > > void computeDifference(
		final RandomAccessible< T > source,
		final AffineTransform transform,
		final RandomAccessible< T > target,
		final RandomAccessibleInterval< S > difference,
		final ExecutorService service,
		final int nTasks)
{
	final RealRandomAccessible< T > interpolated = Views.interpolate( source, new NLinearInterpolatorFactory< T >() );
	final RandomAccessible< T > warped = RealViews.affine( interpolated, transform );

	final long stepSize = Views.iterable( difference ).size() / nTasks;

	final List<Callable< Void >> tasks = new ArrayList<>();
	final AtomicInteger ai = new AtomicInteger( 0 );
	for (int iO = 0; iO<nTasks; iO++)
	{
		tasks.add( new Callable< Void >()
		{
			@Override
			public Void call() throws Exception
			{
				final int i = ai.getAndIncrement();
				final Cursor< T > cw = Views.flatIterable( Views.interval( warped, difference ) ).cursor();
				final Cursor< T > ct = Views.flatIterable( Views.interval( target, difference ) ).cursor();
				final Cursor< S > cd = Views.flatIterable( difference ).cursor();

				cw.jumpFwd( stepSize * i );
				ct.jumpFwd( stepSize * i );
				cd.jumpFwd( stepSize * i );

				final long end = i == nTasks - 1 ? Views.iterable( difference ).size() - stepSize * i : stepSize;
				int count = 0;
				while (count++ < end)
				{
					cd.next().setReal( ( cw.next().getRealDouble() - ct.next().getRealDouble() ));
				}
				return null;
			}
		} );
	}

	try
	{
		List< Future< Void > > futures = service.invokeAll( tasks );
		for (Future< Void > f: futures)
			f.get();
	}
	catch ( InterruptedException | ExecutionException e )
	{
		e.printStackTrace();
	}
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:71,代码来源:Align.java

示例13: calculateCrossCorr

import net.imglib2.view.Views; //导入方法依赖的package包/类
public <T extends RealType<T>, S extends RealType<S>> void calculateCrossCorr(RandomAccessibleInterval<T> img1, RandomAccessibleInterval<S> img2, 
		long minOverlapPx, boolean interpolateSubpixel)
{
	Pair<Interval, Interval> intervals = PhaseCorrelation2Util.getOverlapIntervals(img1, img2, shift);
	
	// no overlap found
	if (intervals == null) {
		crossCorr = Double.NEGATIVE_INFINITY;
		nPixel = 0;
		return;
	}
	
	nPixel = 1;
	for (int i = 0; i< intervals.getA().numDimensions(); i++){
		nPixel *= intervals.getA().dimension(i);
	}
	
	if (nPixel < minOverlapPx){
		crossCorr = Double.NEGATIVE_INFINITY;
		nPixel = 0;
		return;
	}

	// for subpixel move the underlying Img2 by the subpixel offset
	if ( subpixelShift != null && interpolateSubpixel )
	{
		RealRandomAccessible< S > rra = Views.interpolate( Views.extendMirrorSingle( img2 ), new NLinearInterpolatorFactory< S >() );

		InvertibleRealTransform transform = null;

		// e.g. subpixel = (-0.4, 0.1, -0.145)
		final double tx = subpixelShift.getDoublePosition( 0 ) - shift.getDoublePosition( 0 );
		final double ty = subpixelShift.getDoublePosition( 1 ) - shift.getDoublePosition( 1 );

		if ( rra.numDimensions() == 2 )
			transform = new Translation2D( -tx, -ty ); // -relative subpixel shift only
		else if ( rra.numDimensions() == 3 )
			transform = new Translation3D( -tx, -ty, shift.getDoublePosition( 2 ) - subpixelShift.getDoublePosition( 2 ) ); // -relative subpixel shift only

		img2 = Views.interval( Views.raster( RealViews.transform( rra, transform ) ), img2 );
	}

	crossCorr = PhaseCorrelation2Util.getCorrelation(Views.zeroMin(Views.interval(img1, intervals.getA())), Views.zeroMin(Views.interval(img2, intervals.getB())));
	
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:46,代码来源:PhaseCorrelationPeak2.java

示例14: estimate

import net.imglib2.view.Views; //导入方法依赖的package包/类
@Override
protected RandomAccessibleInterval< double[] > estimate( final int size )
{

	{
		final ArrayRandomAccess< DoubleType > ra = summedMeasurements.randomAccess();
		for ( int n = 0; n < nSamples.length; ++n )
		{
			ra.setPosition( n, 0 );
			final double[] ns = nSamples[ n ];
			for ( int r = 0; r < ns.length; ++r )
			{
				ra.setPosition( r, 1 );
				ra.get().mul( 1.0 / ns[ r ] );
			}
		}
	}


	final CompositeIntervalView< DoubleType, RealComposite< DoubleType > > collapsed =
			Views.collapseReal( summedMeasurements );

	final RealRandomAccessible< RealComposite< DoubleType > > interpolated =
			Views.interpolate( Views.extendBorder( collapsed ), new NLinearInterpolatorFactory<>() );

	final FinalInterval fi = new FinalInterval( size );
	final IntervalView< RealComposite< DoubleType > > transformed =
			Views.interval( Views.raster( RealViews.transformReal( interpolated, scaleAndTranslation ) ), fi );

	final Cursor< RealComposite< DoubleType > > t = transformed.cursor();
	final ArrayList< double[] > list = new ArrayList<>();
	for ( int n = 0; n < size; ++n )
	{
		final RealComposite< DoubleType > c = t.next();
		final double[] target = new double[ nSamples[ 0 ].length ];
		target[ 0 ] = -1;
		for ( int i = 1; i < target.length; ++i )
			target[ i ] = -c.get( i ).get();
		list.add( target );
	}

	return new ListImg<>( list, list.size() );
}
 
开发者ID:saalfeldlab,项目名称:z-spacing,代码行数:44,代码来源:LocalCorrelationFitAverage.java

示例15: estimateFromMatrix

import net.imglib2.view.Views; //导入方法依赖的package包/类
public < T extends RealType< T >, W extends RealType< W > > RandomAccessibleInterval< double[] > estimateFromMatrix(
		final RandomAccessibleInterval< T > correlations,
		final double[] coordinates,
		final AbstractLUTRealTransform transform,
		final RandomAccessibleInterval< W > estimateWeightMatrix,
		final Options options )
{
	final int range = options.comparisonRange;
	final boolean forceMonotonicity = options.forceMonotonicity;

	final T correlationsNaNExtension = correlations.randomAccess().get().copy();
	correlationsNaNExtension.setReal( Double.NaN );
	final RealRandomAccessible< T > extendedInterpolatedCorrelations = Views.interpolate( Views.extendValue( correlations, correlationsNaNExtension ), new NLinearInterpolatorFactory<>() );

	final RealTransformRealRandomAccessible< T, InverseRealTransform > transformedCorrelations = RealViews.transformReal( extendedInterpolatedCorrelations, transform );

	// TODO extend border or value (nan)?
	final RealRandomAccessible< W > extendedInterpolatedWeights = Views.interpolate( Views.extendBorder( estimateWeightMatrix ), new NLinearInterpolatorFactory<>() );

	final RealTransformRealRandomAccessible< W, InverseRealTransform > transformedWeights = RealViews.transformReal( extendedInterpolatedWeights, transform );

	final RealRandomAccess< T > access1 = transformedCorrelations.realRandomAccess();
	final RealRandomAccess< T > access2 = transformedCorrelations.realRandomAccess();

	final RealRandomAccess< W > wAccess1 = transformedWeights.realRandomAccess();
	final RealRandomAccess< W > wAccess2 = transformedWeights.realRandomAccess();

	init( range );

	for ( int z = 0; z < coordinates.length; ++z )
	{
		access1.setPosition( z, 1 );
		access1.setPosition( z, 0 );
		transform.apply( access1, access1 );
		access2.setPosition( access1 );

		wAccess1.setPosition( access1 );
		wAccess2.setPosition( access1 );

		double currentMin1 = Double.MAX_VALUE;
		double currentMin2 = Double.MAX_VALUE;
		// should w go in pairwise?
		for ( int k = 0; k <= range; ++k, access1.fwd( 0 ), access2.bck( 0 ), wAccess1.fwd( 0 ), wAccess2.bck( 0 ) )
		{
			final double a1 = access1.get().getRealDouble();
			final double a2 = access2.get().getRealDouble();
			if ( !Double.isNaN( a1 ) && a1 > 0.0 && ( !forceMonotonicity || a1 < currentMin1 ) )
			{
				currentMin1 = a1;
				add( z, k, a1, wAccess1.get().getRealDouble() );
			}
			if ( !Double.isNaN( a2 ) && a2 > 0.0 && ( !forceMonotonicity || a2 < currentMin2 ) )
			{
				currentMin2 = a2;
				add( z, k, a2, wAccess2.get().getRealDouble() );
			}
		}
	}

	return estimate( coordinates.length );
}
 
开发者ID:saalfeldlab,项目名称:z-spacing,代码行数:62,代码来源:AbstractCorrelationFit.java


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