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


Java NLinearInterpolatorFactory类代码示例

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


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

示例1: act

import net.imglib2.interpolation.randomaccess.NLinearInterpolatorFactory; //导入依赖的package包/类
@Override
public < T extends RealType< T > > void act(
		final int iteration,
		final RandomAccessibleInterval< T > matrix,
		final RandomAccessibleInterval< T > scaledMatrix,
		final double[] lut,
		final int[] permutation,
		final int[] inversePermutation,
		final double[] multipliers,
		final RandomAccessibleInterval< double[] > estimatedFit )
{
	final T dummy = scaledMatrix.randomAccess().get().createVariable();
	dummy.setReal( Double.NaN );
	final String path = fileDir( iteration );
	if ( iteration == 0 )
		createParentDirectory( path );
	final LUTRealTransform tf = new LUTRealTransform( lut, 2, 2 );

	final RealTransformRealRandomAccessible< T, InverseRealTransform > transformed = RealViews.transformReal( Views.interpolate( Views.extendValue( scaledMatrix, dummy ), new NLinearInterpolatorFactory<>() ), tf );
	final double s = 1.0 / ( lut[ lut.length - 1 ] - lut[ 0 ] ) * lut.length;
	final double o = -lut[ 0 ];
	final ScaleAndTranslation scaleAndTranslation = new ScaleAndTranslation( new double[] { s, s }, new double[] { o, o } );
	final IntervalView< T > offset = Views.interval( Views.raster( RealViews.transformReal( transformed, scaleAndTranslation ) ), scaledMatrix );
	final RandomAccessibleInterval< T > strip = MatrixStripConversion.matrixToStrip( offset, range, dummy );
	new FileSaver( ImageJFunctions.wrap( strip, "" ) ).saveAsTiff( path );
}
 
开发者ID:saalfeldlab,项目名称:z-spacing,代码行数:27,代码来源:MatrixVisitor.java

示例2: main

import net.imglib2.interpolation.randomaccess.NLinearInterpolatorFactory; //导入依赖的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

示例3: testScaling

import net.imglib2.interpolation.randomaccess.NLinearInterpolatorFactory; //导入依赖的package包/类
@Test
public void testScaling() {
	Img<ByteType> in = generateByteArrayTestImg(true, new long[] { 10, 10 });
	double[] scaleFactors = new double[] { 2, 2 };
	@SuppressWarnings("unchecked")
	RandomAccessibleInterval<ByteType> out = (RandomAccessibleInterval<ByteType>) ops.run(DefaultScaleView.class, in,
		scaleFactors, new NLinearInterpolatorFactory<ByteType>());

	assertEquals(out.dimension(0), 20);
	assertEquals(out.dimension(1), 20);

	RandomAccess<ByteType> inRA = in.randomAccess();
	RandomAccess<ByteType> outRA = out.randomAccess();
	inRA.setPosition(new long[] { 5, 5 });
	outRA.setPosition(new long[] { 10, 10 });
	assertEquals(inRA.get().get(), outRA.get().get());

}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:19,代码来源:ScaleViewTest.java

示例4: getInterpolatedSource

import net.imglib2.interpolation.randomaccess.NLinearInterpolatorFactory; //导入依赖的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

示例5: mapInterval

import net.imglib2.interpolation.randomaccess.NLinearInterpolatorFactory; //导入依赖的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

示例6: edgelToView

import net.imglib2.interpolation.randomaccess.NLinearInterpolatorFactory; //导入依赖的package包/类
/**
	 * Returns a transformed view of the input source image relative to an edgel.
	 * The {@link Edgel} position will map to the midpoint the output patch.
	 * The +z axis of the output view corresponds to the gradient direction of 
	 * the edgel.
	 * 
	 * @param edgel the edgel
	 * @param src the source image
	 * @param patchSize the patch size
	 * @return the transformed view into the source image
	 */
	public static <T extends RealType<T>> RealTransformRandomAccessible<T, InverseRealTransform> edgelToView(Edgel edgel, RandomAccessibleInterval<T> src, int[] patchSize) 
	{
		logger.debug(" edgel pos : " + edgel);

		int[] midPt = PatchTools.patchSizeToMidpt( patchSize ); 	
		AffineTransform3D xfm = edgelToXfm(edgel, midPt);


		NLinearInterpolatorFactory<T> interpFactory = new NLinearInterpolatorFactory<T>();
//		NearestNeighborInterpolatorFactory<T> interpFactory = new NearestNeighborInterpolatorFactory<T>();

		RealRandomAccessible<T> interpolant = Views.interpolate(
				Views.extendMirrorSingle(src), interpFactory);

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

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

示例7: call

import net.imglib2.interpolation.randomaccess.NLinearInterpolatorFactory; //导入依赖的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

示例8: call

import net.imglib2.interpolation.randomaccess.NLinearInterpolatorFactory; //导入依赖的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

示例9: upsample

import net.imglib2.interpolation.randomaccess.NLinearInterpolatorFactory; //导入依赖的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

示例10: generateTransformed

import net.imglib2.interpolation.randomaccess.NLinearInterpolatorFactory; //导入依赖的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

示例11: main

import net.imglib2.interpolation.randomaccess.NLinearInterpolatorFactory; //导入依赖的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

示例12: createOverlay

import net.imglib2.interpolation.randomaccess.NLinearInterpolatorFactory; //导入依赖的package包/类
protected static < T extends RealType< T > & NativeType< T > > CompositeImage createOverlay( final T targetType, final ImagePlus imp1, final ImagePlus imp2, final InvertibleBoundable finalModel1, final InvertibleBoundable finalModel2, final int dimensionality ) 
{
	final ArrayList< ImagePlus > images = new ArrayList<ImagePlus>();
	images.add( imp1 );
	images.add( imp2 );
	
	final ArrayList< InvertibleBoundable > models = new ArrayList<InvertibleBoundable>();
	models.add( finalModel1 );
	models.add( finalModel2 );
	
	return createOverlay( targetType, images, models, dimensionality, 1, new NLinearInterpolatorFactory<FloatType>() );
}
 
开发者ID:fiji,项目名称:Stitching,代码行数:13,代码来源:OverlayFusion.java

示例13: processReal

import net.imglib2.interpolation.randomaccess.NLinearInterpolatorFactory; //导入依赖的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

示例14: testOutOfBoundsFactoryIsNull

import net.imglib2.interpolation.randomaccess.NLinearInterpolatorFactory; //导入依赖的package包/类
@SuppressWarnings({ "unused", "unchecked" })
@Test
public void testOutOfBoundsFactoryIsNull() {
	Img<ByteType> in = generateByteArrayTestImg(true, new long[] { 10, 10 });
	double[] scaleFactors = new double[] { 2, 2 };
	NLinearInterpolatorFactory<ByteType> nLinearInterpolatorFactory =
		new NLinearInterpolatorFactory<ByteType>();
	RandomAccessibleInterval<ByteType> out = (RandomAccessibleInterval<ByteType>) ops.run(DefaultScaleView.class, in,
		scaleFactors, nLinearInterpolatorFactory, null);
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:11,代码来源:ScaleViewTest.java

示例15: testContingency

import net.imglib2.interpolation.randomaccess.NLinearInterpolatorFactory; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testContingency() {
	Img<ByteType> in = generateByteArrayTestImg(true, new long[] { 10, 10 });
	double[] scaleFactors = new double[] { 2, 2, 2 };
	ops.run(DefaultScaleView.class, in, scaleFactors,
		new NLinearInterpolatorFactory<ByteType>());
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:8,代码来源:ScaleViewTest.java


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