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

Java FloatArray类代码示例

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

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



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

示例1: createFloatInstance

import net.imglib2.img.basictypeaccess.array.FloatArray; //导入依赖的package包/类
@SuppressWarnings( "unchecked" )
public static BigWarpImageStackImageLoader< FloatType, FloatArray > createFloatInstance( final ImagePlus imp, int[] ids )
{
	return new BigWarpImageStackImageLoader< FloatType, FloatArray >( new FloatType(), imp, ids )
	{
		@Override
		protected FloatArray wrapPixels( final Object array )
		{
			return new FloatArray( ( float[] ) array );
		}

		@Override
		protected void linkType( final PlanarImg< FloatType, FloatArray > img )
		{
			img.setLinkedType( new FloatType( img ) );
		}
	};
}
 
开发者ID:saalfeldlab,项目名称:bigwarp,代码行数:19,代码来源:BigWarpImageStackImageLoader.java


示例2: main

import net.imglib2.img.basictypeaccess.array.FloatArray; //导入依赖的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: createFloatInstance

import net.imglib2.img.basictypeaccess.array.FloatArray; //导入依赖的package包/类
public static ImageStackImageLoader< FloatType, FloatArray > createFloatInstance( final ImagePlus imp )
{
	return new ImageStackImageLoader< FloatType, FloatArray >( new FloatType(), imp )
	{
		@Override
		protected FloatArray wrapPixels( final Object array )
		{
			return new FloatArray( ( float[] ) array );
		}

		@Override
		protected void linkType( final PlanarImg< FloatType, FloatArray > img )
		{
			img.setLinkedType( new FloatType( img ) );
		}
	};
}
 
开发者ID:bigdataviewer,项目名称:bigdataviewer_fiji,代码行数:18,代码来源:ImageStackImageLoader.java


示例4: convolve1BlockCUDA

import net.imglib2.img.basictypeaccess.array.FloatArray; //导入依赖的package包/类
@SuppressWarnings("unchecked")
final protected static void convolve1BlockCUDA(
		final Block blockStruct, final int deviceId, final Img< FloatType > image,
		final Img< FloatType > result, final Img< FloatType > block, final Img< FloatType > kernel1, final int i )
{
	long time = System.currentTimeMillis();
	blockStruct.copyBlock( Views.extendMirrorSingle( image ), block );
	System.out.println( " block " + i + "(CPU  " + deviceId + "): copy " + (System.currentTimeMillis() - time) );

	// convolve block with kernel1 using CUDA
	time = System.currentTimeMillis();
	final float[] blockF = ((FloatArray)((ArrayImg< net.imglib2.type.numeric.real.FloatType, ? > )block).update( null ) ).getCurrentStorageArray();
	final float[] kernel1F = ((FloatArray)((ArrayImg< net.imglib2.type.numeric.real.FloatType, ? > )kernel1).update( null ) ).getCurrentStorageArray();
	
	MVDeconFFT.cuda.convolution3DfftCUDAInPlace(
			blockF, getCUDACoordinates( CUDAOutput.getImgSizeInt( block ) ),
			kernel1F, getCUDACoordinates( CUDAOutput.getImgSizeInt( kernel1 ) ),
			deviceId );
	System.out.println( " block " + i + "(CUDA " + deviceId + "): compute " + (System.currentTimeMillis() - time) );

	time = System.currentTimeMillis();
	blockStruct.pasteBlock( result, block );
	System.out.println( " block " + i + "(CPU  " + deviceId + "): paste " + (System.currentTimeMillis() - time) );
}
 
开发者ID:fiji,项目名称:SPIM_Registration,代码行数:25,代码来源:MVDeconFFTThreads.java


示例5: convolve2BlockCUDA

import net.imglib2.img.basictypeaccess.array.FloatArray; //导入依赖的package包/类
@SuppressWarnings("unchecked")
final protected static void convolve2BlockCUDA(
		final Block blockStruct, final int deviceId, final Img< FloatType > image,
		final Img< FloatType > result, final Img< FloatType > block, final Img< FloatType > kernel2 )
{
	// ratio outside of the deconvolved space (psi) is 1
	blockStruct.copyBlock( Views.extendValue( image, new FloatType( 1.0f ) ), block );

	// convolve block with kernel2 using CUDA
	final float[] blockF = ((FloatArray)((ArrayImg< net.imglib2.type.numeric.real.FloatType, ? > )block).update( null ) ).getCurrentStorageArray();
	final float[] kernel2F = ((FloatArray)((ArrayImg< net.imglib2.type.numeric.real.FloatType, ? > )kernel2).update( null ) ).getCurrentStorageArray();

	MVDeconFFT.cuda.convolution3DfftCUDAInPlace(
			blockF, getCUDACoordinates( CUDAOutput.getImgSizeInt( block ) ),
			kernel2F, getCUDACoordinates( CUDAOutput.getImgSizeInt( kernel2 ) ),
			deviceId );

	blockStruct.pasteBlock( result, block );
}
 
开发者ID:fiji,项目名称:SPIM_Registration,代码行数:20,代码来源:MVDeconFFTThreads.java


示例6: createFloatArray

import net.imglib2.img.basictypeaccess.array.FloatArray; //导入依赖的package包/类
private static float[] createFloatArray(
	final RandomAccessibleInterval<FloatType> image)
{
	final long[] dims = Intervals.dimensionsAsLongArray(image);
	final ArrayImg<FloatType, FloatArray> dest = ArrayImgs.floats(dims);
	copy(image, dest);
	return dest.update(null).getCurrentStorageArray();
}
 
开发者ID:imagej,项目名称:imagej-tensorflow,代码行数:9,代码来源:Tensors.java


示例7: extractFloatArray

import net.imglib2.img.basictypeaccess.array.FloatArray; //导入依赖的package包/类
private static float[] extractFloatArray(
	final RandomAccessibleInterval<FloatType> image)
{
	if (!(image instanceof ArrayImg)) return null;
	@SuppressWarnings("unchecked")
	final ArrayImg<FloatType, ?> arrayImg = (ArrayImg<FloatType, ?>) image;
	// GOOD NEWS: float[] rasterization order is dimension-wise!
	// BAD NEWS: it always goes d0,d1,d2,.... is that the order we need?
	// MORE BAD NEWS: As soon as you use Views.permute, image is not ArrayImg anymore.
	// SO: This only works if you give a RAI that happens to be laid out directly as TensorFlow desires.
	final Object dataAccess = arrayImg.update(null);
	return dataAccess instanceof FloatArray ? //
		((FloatArray) dataAccess).getCurrentStorageArray() : null;
}
 
开发者ID:imagej,项目名称:imagej-tensorflow,代码行数:15,代码来源:Tensors.java


示例8: main

import net.imglib2.img.basictypeaccess.array.FloatArray; //导入依赖的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: multiply

import net.imglib2.img.basictypeaccess.array.FloatArray; //导入依赖的package包/类
@OpMethod(ops = {
	net.imagej.ops.math.ConstantToArrayImageP.MultiplyFloat.class,
	net.imagej.ops.math.ConstantToArrayImage.MultiplyFloat.class })
public ArrayImg<FloatType, FloatArray> multiply(
	final ArrayImg<FloatType, FloatArray> image, final float value)
{
	@SuppressWarnings("unchecked")
	final ArrayImg<FloatType, FloatArray> result =
		(ArrayImg<FloatType, FloatArray>) ops().run(Ops.Math.Multiply.NAME, image,
			value);
	return result;
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:13,代码来源:MathNamespace.java


示例10: add

import net.imglib2.img.basictypeaccess.array.FloatArray; //导入依赖的package包/类
@OpMethod(op = net.imagej.ops.math.ConstantToPlanarImage.AddFloat.class)
public PlanarImg<FloatType, FloatArray> add(
	final PlanarImg<FloatType, FloatArray> image, final float value)
{
	@SuppressWarnings("unchecked")
	final PlanarImg<FloatType, FloatArray> result =
		(PlanarImg<FloatType, FloatArray>) ops().run(
			net.imagej.ops.Ops.Math.Add.class, image, value);
	return result;
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:11,代码来源:MathNamespace.java


示例11: divide

import net.imglib2.img.basictypeaccess.array.FloatArray; //导入依赖的package包/类
@OpMethod(ops = { net.imagej.ops.math.ConstantToArrayImageP.DivideFloat.class,
	net.imagej.ops.math.ConstantToArrayImage.DivideFloat.class })
public ArrayImg<FloatType, FloatArray> divide(
	final ArrayImg<FloatType, FloatArray> image, final float value)
{
	@SuppressWarnings("unchecked")
	final ArrayImg<FloatType, FloatArray> result =
		(ArrayImg<FloatType, FloatArray>) ops().run(Ops.Math.Divide.NAME, image,
			value);
	return result;
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:12,代码来源:MathNamespace.java


示例12: subtract

import net.imglib2.img.basictypeaccess.array.FloatArray; //导入依赖的package包/类
@OpMethod(ops = {
	net.imagej.ops.math.ConstantToArrayImageP.SubtractFloat.class,
	net.imagej.ops.math.ConstantToArrayImage.SubtractFloat.class })
public ArrayImg<FloatType, FloatArray> subtract(
	final ArrayImg<FloatType, FloatArray> image, final float value)
{
	@SuppressWarnings("unchecked")
	final ArrayImg<FloatType, FloatArray> result =
		(ArrayImg<FloatType, FloatArray>) ops().run(Ops.Math.Subtract.NAME, image,
			value);
	return result;
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:13,代码来源:MathNamespace.java


示例13: generateFloatArrayTestImg

import net.imglib2.img.basictypeaccess.array.FloatArray; //导入依赖的package包/类
public ArrayImg<FloatType, FloatArray> generateFloatArrayTestImg(
	final boolean fill, final long... dims)
{
	final float[] array = new float[(int) Intervals.numElements(
		new FinalInterval(dims))];

	if (fill) {
		seed = 17;
		for (int i = 0; i < array.length; i++) {
			array[i] = (float) pseudoRandom() / (float) Integer.MAX_VALUE;
		}
	}

	return ArrayImgs.floats(array, dims);
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:16,代码来源:AbstractOpTest.java


示例14: copy3dArray

import net.imglib2.img.basictypeaccess.array.FloatArray; //导入依赖的package包/类
private static final void copy3dArray( final int threadIdx, final int numThreads, final RandomAccessible< FloatType > source, final ArrayImg< FloatType, ? > block, final long[] offset )
{
	final int w = (int)block.dimension( 0 );
	final int h = (int)block.dimension( 1 );
	final int d = (int)block.dimension( 2 );

	final long offsetX = offset[ 0 ];
	final long offsetY = offset[ 1 ];
	final long offsetZ = offset[ 2 ];
	final float[] blockArray = ((FloatArray)block.update( null ) ).getCurrentStorageArray();

	// define where we will query the RandomAccess on the source
	final FinalInterval interval = new FinalInterval( new long[] { offsetX, offsetY, offsetZ }, new long[] { offsetX + w - 1, offsetY + h - 1, offsetZ + d - 1 } );
	final RandomAccess< FloatType > randomAccess = source.randomAccess( interval );

	final long[] tmp = new long[]{ offsetX, offsetY, 0 };

	for ( int z = threadIdx; z < d; z += numThreads )
	{
		tmp[ 2 ] = z + offsetZ;
		randomAccess.setPosition( tmp );

		int i = z * h * w;

		for ( int y = 0; y < h; ++y )
		{
			randomAccess.setPosition( offsetX, 0 );

			for ( int x = 0; x < w; ++x )
			{
				blockArray[ i++ ] = randomAccess.get().get();
				randomAccess.fwd( 0 );
			}

			randomAccess.move( -w, 0 );
			randomAccess.fwd( 1 );
		}
	}
}
 
开发者ID:fiji,项目名称:SPIM_Registration,代码行数:40,代码来源:Block.java


示例15: createInstance

import net.imglib2.img.basictypeaccess.array.FloatArray; //导入依赖的package包/类
@Override
public
	SCIFIOCellImg<T, FloatArray>
	createFloatInstance(final long[] dimensions, final Fraction entitiesPerPixel)
{
	return createInstance(new FloatArrayLoader(reader(), subregion),
		dimensions, entitiesPerPixel);
}
 
开发者ID:scifio,项目名称:scifio,代码行数:9,代码来源:SCIFIOCellImgFactory.java


示例16: main

import net.imglib2.img.basictypeaccess.array.FloatArray; //导入依赖的package包/类
public static void main( final String[] args )
{
	new ImageJ();

	final double[] coefficients = new double[]{
			0, 2, 4, 8,
			1, 1, 1, 1,
			1, 10, 5, 1,
			1, 1, 1, 1,

			0, 10, 20, 30,
			40, 50, 60, 70,
			80, 90, 100, 110,
			120, 130, 140, 150
	};

	final LinearIntensityMap< DoubleType > transform = new LinearIntensityMap< DoubleType >( ArrayImgs.doubles( coefficients, 4, 4, 2 ) );

	//final ImagePlus imp = new ImagePlus( "http://upload.wikimedia.org/wikipedia/en/2/24/Lenna.png" );
	final ImagePlus imp1 = new ImagePlus( "http://fly.mpi-cbg.de/~saalfeld/Pictures/norway.jpg");

	final ArrayImg< FloatType, FloatArray > image1 = ArrayImgs.floats( ( float[] )imp1.getProcessor().convertToFloatProcessor().getPixels(), imp1.getWidth(), imp1.getHeight() );
	final ArrayImg< UnsignedByteType, ByteArray > image2 = ArrayImgs.unsignedBytes( ( byte[] )imp1.getProcessor().convertToByteProcessor().getPixels(), imp1.getWidth(), imp1.getHeight() );
	final ArrayImg< UnsignedShortType, ShortArray > image3 = ArrayImgs.unsignedShorts( ( short[] )imp1.getProcessor().convertToShortProcessor().getPixels(), imp1.getWidth(), imp1.getHeight() );
	final ArrayImg< ARGBType, IntArray > image4 = ArrayImgs.argbs( ( int[] )imp1.getProcessor().getPixels(), imp1.getWidth(), imp1.getHeight() );

	ImageJFunctions.show( ArrayImgs.doubles( coefficients, 4, 4, 2 ) );

	transform.run( image1 );
	transform.run( image2 );
	transform.run( image3 );
	transform.run( image4 );

	ImageJFunctions.show( image1 );
	ImageJFunctions.show( image2 );
	ImageJFunctions.show( image3 );
	ImageJFunctions.show( image4 );
}
 
开发者ID:trakem2,项目名称:TrakEM2,代码行数:39,代码来源:LinearIntensityMap.java


示例17: main

import net.imglib2.img.basictypeaccess.array.FloatArray; //导入依赖的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" );
	for ( int y = imp.getHeight() / 2; y < imp.getHeight(); ++y )
	{
		for ( int x = imp.getWidth() / 2; x < imp.getWidth(); ++x )
		{
			imp.getProcessor().setf( x, y, Float.NaN );
		}
	}
	imp.show();
	System.out.println( imp.getHeight() + " " + imp.getWidth() + " " + imp.getStack().getSize() );

	final int xyIndices = 5;
	final ArrayImg< FloatType, FloatArray > img4D = ArrayImgs.floats( xyIndices, xyIndices, imp.getWidth(), imp.getHeight() );

	final ArrayImg< DoubleType, DoubleArray > lut = ArrayImgs.doubles( xyIndices, xyIndices, Math.max( imp.getWidth(), imp.getHeight() ) );
	final ArrayRandomAccess< DoubleType > lutRA = lut.randomAccess();
	final ArrayRandomAccess< FloatType > ra = img4D.randomAccess();
	ra.setPosition( new int[] { 0, 0, 0, 0 } );
	for ( int yPrime = 0; yPrime < xyIndices; ++yPrime )
	{
		ra.setPosition( yPrime, 1 );
		for ( int xPrime = 0; xPrime < xyIndices; ++xPrime )
		{
			ra.setPosition( xPrime, 0 );
			for ( int y = 0; y < imp.getHeight(); ++y )
			{
				ra.setPosition( y, 3 );
				for ( int x = 0; x < imp.getWidth(); ++x )
				{
					ra.setPosition( x, 2 );
					ra.get().set( imp.getProcessor().getf( x, y ) );
					if ( Math.abs( x - y ) > 5 )
					{
						ra.get().set( Float.NaN );
					}
				}
			}
		}
	}

	for ( int xPrime = 0; xPrime < xyIndices; ++xPrime )
	{
		for ( int yPrime = 0; yPrime < xyIndices; ++yPrime )
		{
			for ( int z = 0; z < lut.dimension( 2 ); ++z )
			{
				lutRA.setPosition( new int[] { xPrime, yPrime, z } );
				lutRA.get().set( z );
			}
		}

	}

	final LUTGrid lutGrid = new LUTGrid( 4, 4, lut );

	final RealRandomAccessible< FloatType > source = Views.interpolate( Views.extendValue( img4D, new FloatType( Float.NaN ) ), new NLinearInterpolatorFactory< FloatType >() );
	final RealTransformRealRandomAccessible< FloatType, InverseRealTransform > source2 = RealViews.transformReal( source, lutGrid );
	final RealRandomAccessible< FloatType > source3 = Views.interpolate( Views.extendBorder( img4D ), new NLinearInterpolatorFactory< FloatType >() );
	final RealTransformRealRandomAccessible< FloatType, InverseRealTransform > source4 = RealViews.transformReal( source3, lutGrid );
	final IntervalView< FloatType > v1 = Views.hyperSlice( Views.hyperSlice( img4D, 1, xyIndices / 2 ), 0, xyIndices / 2 );
	final IntervalView< FloatType > v2 = Views.interval( Views.hyperSlice( Views.hyperSlice( Views.raster( source2 ), 1, 0 ), 0, xyIndices - 5 ), new FinalInterval( v1 ) );
	final IntervalView< FloatType > v3 = Views.interval( Views.hyperSlice( Views.hyperSlice( Views.raster( source4 ), 1, 0 ), 0, xyIndices - 5 ), new FinalInterval( v1 ) );

	ImageJFunctions.show( v1, "hyperSlice" );
	ImageJFunctions.show( v2, "extendNaN" );
	ImageJFunctions.show( v3, "extendBorder" );

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


示例18: FloatImage

import net.imglib2.img.basictypeaccess.array.FloatArray; //导入依赖的package包/类
public FloatImage(final long[] dim, final float[] pixels) {
	super(new FloatArray(pixels), dim, new Fraction());
	setLinkedType(new FloatType(this));
}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:5,代码来源:FloatImage.java


示例19: benchmark

import net.imglib2.img.basictypeaccess.array.FloatArray; //导入依赖的package包/类
public static final void benchmark( final String[] args )
{
	final int ntrials = 10;

	final Shape strel = new DiamondShape( 3 );

	final ArrayImg< FloatType, FloatArray > img = ArrayImgs.floats( new long[] { 200, 200 } );
	for ( final FloatType pixel : img )
	{
		pixel.set( 1f );
	}
	final ArrayRandomAccess< FloatType > ra = img.randomAccess();

	final ArrayImg< BitType, LongArray > bitsImg = ArrayImgs.bits( new long[] { img.dimension( 0 ), img.dimension( 1 ) } );
	for ( final BitType pixelB : bitsImg )
	{
		pixelB.set( true );
	}
	final ArrayRandomAccess< BitType > raBits = bitsImg.randomAccess(); // LOL

	final Random ran = new Random( 1l );
	for ( int i = 0; i < 1000; i++ )
	{
		final int x = ran.nextInt( ( int ) img.dimension( 0 ) );
		final int y = ran.nextInt( ( int ) img.dimension( 1 ) );

		ra.setPosition( new int[] { x, y } );
		ra.get().set( 0f );

		raBits.setPosition( ra );
		raBits.get().set( false );
	}

	// Dilate to new image
	Img< BitType > imgBits3 = Opening.open( bitsImg, strel, 1 );
	long start = System.currentTimeMillis();
	for ( int i = 0; i < ntrials; i++ )
	{
		imgBits3 = Opening.open( bitsImg, strel, 1 );
	}
	long end = System.currentTimeMillis();
	System.out.println( "BitType time: " + ( ( end - start ) / ntrials ) + " ms." );

	Img< FloatType > img3 = Opening.open( img, strel, 1 );
	start = System.currentTimeMillis();
	for ( int i = 0; i < ntrials; i++ )
	{
		img3 = Opening.open( img, strel, 1 );
	}
	end = System.currentTimeMillis();
	System.out.println( "FloatType time: " + ( ( end - start ) / ntrials ) + " ms." );

	ImageJ.main( args );
	ImageJFunctions.show( img3, "Float" );
	ImageJFunctions.show( imgBits3, "Bit" );
}
 
开发者ID:imglib,项目名称:imglib2-tests,代码行数:57,代码来源:OpeningTests.java


示例20: benchmark

import net.imglib2.img.basictypeaccess.array.FloatArray; //导入依赖的package包/类
public static final void benchmark( final String[] args )
{
	final int ntrials = 10;

	final Shape strel = new DiamondShape( 3 );

	final ArrayImg< FloatType, FloatArray > img = ArrayImgs.floats( new long[] { 200, 200 } );
	for ( final FloatType pixel : img )
	{
		pixel.set( 1f );
	}
	final ArrayRandomAccess< FloatType > ra = img.randomAccess();

	final ArrayImg< BitType, LongArray > bitsImg = ArrayImgs.bits( new long[] { img.dimension( 0 ), img.dimension( 1 ) } );
	for ( final BitType pixelB : bitsImg )
	{
		pixelB.set( true );
	}
	final ArrayRandomAccess< BitType > raBits = bitsImg.randomAccess(); // LOL

	final Random ran = new Random( 1l );
	for ( int i = 0; i < 1000; i++ )
	{
		final int x = ran.nextInt( ( int ) img.dimension( 0 ) );
		final int y = ran.nextInt( ( int ) img.dimension( 1 ) );

		ra.setPosition( new int[] { x, y } );
		ra.get().set( 0f );

		raBits.setPosition( ra );
		raBits.get().set( false );
	}

	// Dilate to new image
	Img< BitType > imgBits3 = Erosion.erode( bitsImg, strel, 1 );
	long start = System.currentTimeMillis();
	for ( int i = 0; i < ntrials; i++ )
	{
		imgBits3 = Erosion.erode( bitsImg, strel, 1 );
	}
	long end = System.currentTimeMillis();
	System.out.println( "BitType time: " + ( ( end - start ) / ntrials ) + " ms." );

	Img< FloatType > img3 = Erosion.erode( img, strel, 1 );
	start = System.currentTimeMillis();
	for ( int i = 0; i < ntrials; i++ )
	{
		img3 = Erosion.erode( img, strel, 1 );
	}
	end = System.currentTimeMillis();
	System.out.println( "FloatType time: " + ( ( end - start ) / ntrials ) + " ms." );

	ImageJ.main( args );
	ImageJFunctions.show( img3, "Float" );
	ImageJFunctions.show( imgBits3, "Bit" );
}
 
开发者ID:imglib,项目名称:imglib2-tests,代码行数:57,代码来源:ErosionTests.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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