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

Java NumericType类代码示例

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

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



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

示例1: transferN

import net.imglib2.type.numeric.NumericType; //导入依赖的package包/类
/** Copy img into iimg, offset by 1 in every dimension. */
static private final <R extends NumericType<R>, T extends NumericType<T>> void transferN(
		final Img<R> img,
		final Img<T> iimg,
		final Converter<R, T> converter)
{
	// Copy img to iimg, with an offset of 1 in every dimension
	final long[] min = new long[img.numDimensions()];
	final long[] max = new long[min.length];
	for (int i=0; i<min.length; ++i) {
		min[i] = 1;
		max[i] = img.dimension(i);
	}
	final Cursor<R> c1 = img.cursor();
	final RandomAccess<T> r = Views.zeroMin(Views.interval(iimg, min, max)).randomAccess();
	while (c1.hasNext()) {
		c1.fwd();
		r.setPosition(c1);
		converter.convert(c1.get(), r.get());
	}
}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:22,代码来源:FastIntegralImg.java


示例2: integrateN

import net.imglib2.type.numeric.NumericType; //导入依赖的package包/类
/** In place; assumes iimg already contains the information of the image to integrate. */
static private final <T extends NumericType<T>> void integrateN(
		final Img<T> iimg,
		final T sum)
{
	final RandomAccess<T> r2 = iimg.randomAccess();
	final int numDimensions = iimg.numDimensions();
	// Integrate iimg by summing over all possible kinds of rows
	final int[] rowDims = new int[numDimensions -1];
	for (int rowDimension = 0; rowDimension < numDimensions; ++rowDimension) {
		// Reset position
		for (int i=0; i<numDimensions; ++i) {
			r2.setPosition(1L, i);
		}
		
		// Prepare the set of dimensions to iterate over
		for (int i=0, k=0; i<rowDims.length; ++i, ++k) {
			if (i == rowDimension) ++k;
			rowDims[i] = k;
		}

		// Iterate over all dimensions other than rowDimension
		integrateRows(rowDimension, iimg, r2, sum, rowDims);
	}
}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:26,代码来源:FastIntegralImg.java


示例3: process

import net.imglib2.type.numeric.NumericType; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
static private final <N extends NumericType<N>>
					Img<N> process(final Img<N> img, final float[] matrix,
					final Mode mode, final OutOfBoundsFactory<N,Img<N>> oobf) throws Exception {
	if (matrix.length < 12) {
		throw new IllegalArgumentException("Affine transform in 2D requires a matrix array of 12 elements.");
	}
	final Type<?> type = img.firstElement().createVariable();
	if (ARGBType.class.isAssignableFrom(type.getClass())) { // type instanceof RGBALegacyType fails to compile
		return (Img)processRGBA((Img)img, matrix, mode, (OutOfBoundsFactory)oobf);
	} else if (type instanceof RealType<?>) {
		return processReal((Img)img, matrix, mode, (OutOfBoundsFactory)oobf);
	} else {
		throw new Exception("Affine transform: cannot handle type " + type.getClass());
	}
}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:17,代码来源:AbstractAffine3D.java


示例4: process

import net.imglib2.type.numeric.NumericType; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
static private final <N extends NumericType<N>> Img<N> process(final Img<N> img, long[] dim, final Mode mode) throws Exception {
	// Pad dim array with missing dimensions
	if (dim.length != img.numDimensions()) {
		long[] d = new long[img.numDimensions()];
		int i = 0;
		for (; i<dim.length; i++) d[i] = dim[i];
		for (; i<img.numDimensions(); i++) d[i] = img.dimension(i);
		dim = d;
	}
	final Type<?> type = img.firstElement().createVariable();
	if (ARGBType.class.isAssignableFrom(type.getClass())) { // type instanceof RGBALegacyType fails to compile
		return (Img)processRGBA((Img)img, dim, mode);
	} else if (type instanceof RealType<?>) {
		return processReal((Img)img, dim, mode);
	} else {
		throw new Exception("Affine transform: cannot handle type " + type.getClass());
	}
}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:20,代码来源:Resample.java


示例5: copyInterpolatedGeneric

import net.imglib2.type.numeric.NumericType; //导入依赖的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: mapInterval

import net.imglib2.type.numeric.NumericType; //导入依赖的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


示例7: createZeroExtended

import net.imglib2.type.numeric.NumericType; //导入依赖的package包/类
/**
 * @param source
 *            Source to be wrapped.
 * @param stepSize
 *            Strides for each dimension
 * @return BlockedInterval wrapped around zero extended source.
 */
public static < U extends NumericType< U > > BlockedInterval< U > createZeroExtended(
		RandomAccessibleInterval< U > source,
		long[] stepSize )
{
	U value = source.randomAccess().get().copy();
	value.setZero();
	return createValueExtended( source, stepSize, value );
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:16,代码来源:BlockedInterval.java


示例8: copyToImageStack

import net.imglib2.type.numeric.NumericType; //导入依赖的package包/类
public static < T extends NumericType<T> > RandomAccessibleInterval<T> copyToImageStack( 
		final RandomAccessible< T > raible,
		final Interval itvl,
		final ImgFactory<T> factory,
		final int nThreads )
{
	// create the image plus image
	final T t = raible.randomAccess().get().copy();
	Img< T > target = factory.create( itvl, t );
	return copyToImageStack( raible, itvl, target, nThreads );
}
 
开发者ID:saalfeldlab,项目名称:bigwarp,代码行数:12,代码来源:BigWarpExporter.java


示例9: copyToImageStack

import net.imglib2.type.numeric.NumericType; //导入依赖的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


示例10: process

import net.imglib2.type.numeric.NumericType; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
private static final <R extends NumericType<R>> Img<R> process(final IterableInterval<R> img) {
	if (img instanceof Img) {
		return ((Img<R>)img).copy();
	}

	if (img.firstElement() instanceof NativeType<?>) {
		return copyAsArrayImg((IterableInterval)img);
	}
	
	throw new IllegalArgumentException("Could not duplicate image of class " + img.getClass() + " with type " + img.firstElement().getClass());
}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:13,代码来源:Duplicate.java


示例11: computeSmallestType

import net.imglib2.type.numeric.NumericType; //导入依赖的package包/类
/**
 * Determine the smallest type that will correctly store the sums.
 * For {@link Img} whose type has integer precision, the largest type is {@link LongType}.
 * For {@link Img} whose type has floating-point precision, the largest type is {@link DoubleType}.
 * 
 * @param img The input {@link Img}.
 * @return
 */
static public final <R extends RealType<R>, T extends NativeType<T> & NumericType<T>> T computeSmallestType(final Img<R> img) {
	final R type = img.firstElement();
	final long maxSum = (long) (img.size() * (Math.pow(2, type.getBitsPerPixel()) -1));
	T smallest = chooseSmallestType(type, maxSum);
	if (null != smallest) return smallest;
	// Else, slow way: sum all values and determine the smallest type
	final RealSum sum = new RealSum();
	for (final R r : img) sum.add(r.getRealDouble());
	smallest = chooseSmallestType(type, sum.getSum());
	if (null != smallest) return smallest;
	throw new UnsupportedOperationException("Target image is too large!");
}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:21,代码来源:FastIntegralImg.java


示例12: chooseSmallestType

import net.imglib2.type.numeric.NumericType; //导入依赖的package包/类
@SuppressWarnings("unchecked")
static private final <R extends RealType<R>, T extends NativeType<T> & NumericType<T>> T chooseSmallestType(final R srcType, final double maxSum) {
	if (IntegerType.class.isAssignableFrom(srcType.getClass())) {
		if (maxSum < Math.pow(2, 8)) return (T)(Object) new UnsignedByteType();
		if (maxSum < Math.pow(2, 16)) return (T)(Object) new UnsignedShortType();
		if (maxSum < Math.pow(2, 32)) return (T)(Object) new UnsignedIntType();
		if (maxSum < Math.pow(2, 64)) return (T)(Object) new LongType();
	} else {
		if (maxSum <= Float.MAX_VALUE) return (T)(Object) new FloatType();
		if (maxSum <= Double.MAX_VALUE) return (T)(Object) new DoubleType();
	}
	return null;
}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:14,代码来源:FastIntegralImg.java


示例13: populate1

import net.imglib2.type.numeric.NumericType; //导入依赖的package包/类
static private final <R extends NumericType<R>, T extends NumericType<T>> void populate1(final Img<R> img, final Img<T> iimg, final Converter<R, T> converter, final T sum) {
	final RandomAccess<R> r1 = img.randomAccess();
	final RandomAccess<T> r2 = iimg.randomAccess();
	sum.setZero();
	r2.move(1L, 0);
	for (long pos = 0; pos < img.dimension(0); ++pos) {
		converter.convert(r1.get(), r2.get());
		sum.add(r2.get());
		r2.get().set(sum);
		r1.move(1L, 0);
		r2.move(1L, 0);
	}
}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:14,代码来源:FastIntegralImg.java


示例14: populate2

import net.imglib2.type.numeric.NumericType; //导入依赖的package包/类
/** The offsets of 1,1 are due to the integral image being +1 larger in every dimension.
 * 
 * @param img
 * @param iimg
 * @param converter
 * @param sum
 */
static private final <R extends NumericType<R>, T extends NumericType<T>> void populate2(final Img<R> img, final Img<T> iimg, final Converter<R, T> converter, final T sum) {
	final RandomAccess<R> r1 = img.randomAccess();
	final RandomAccess<T> r2 = iimg.randomAccess();
	final T tmp = sum.createVariable();
	// Position r2 at 1,1
	r2.fwd(0);
	r2.fwd(1);
	// Integrate rows
	for (long pos1 = 0; pos1 < img.dimension(1); ++pos1) { // for every row
		sum.setZero();
		r1.setPosition(0L, 0);
		r2.setPosition(1L, 0);
		for (long pos0 = 0; pos0 < img.dimension(0); ++pos0) { // for every element in row
			converter.convert(r1.get(), tmp);
			sum.add(tmp);
			r2.get().set(sum);
			r1.fwd(0);
			r2.fwd(0);
		}
		r1.fwd(1);
		r2.fwd(1);
	}
	// Integrate columns
	r2.setPosition(1L, 0);
	for (long pos0 = 0; pos0 < img.dimension(0); ++pos0) {
		sum.setZero();
		r2.setPosition(1L, 1);
		for (long pos1 = 0; pos1 < img.dimension(1); ++pos1) {
			sum.add(r2.get());
			r2.get().set(sum);
			r2.fwd(1);
		}
		r2.fwd(0);
	}
}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:43,代码来源:FastIntegralImg.java


示例15: integrateRows

import net.imglib2.type.numeric.NumericType; //导入依赖的package包/类
static private final <T extends NumericType<T>> void integrateRows(
		final int rowDimension,
		final Interval iimg,
		final RandomAccess<T> r2,
		final T sum,
		final int[] rowDims) {
	long nRows = 1;
	for (int i=0; i<rowDims.length; ++i) nRows *= iimg.dimension(rowDims[i]) -1;
	
	while (0 != nRows) {
		// Integrate an interval over rowDimension
		integrateRow(rowDimension, iimg, r2, sum);
		--nRows;
		
		for (int i=0; i<rowDims.length; ++i) {
			// Advance to the next interval to integrate
			r2.fwd(rowDims[i]);
			// If beyond bounds in the d dimension
			if (r2.getLongPosition(rowDims[i]) == iimg.dimension(rowDims[i])) {
				// Reset the d dimension
				r2.setPosition(1L, rowDims[i]);
				// Advance the next dimension
				continue;
			}
			// Else integrate the next interval
			break;
		}
	}
}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:30,代码来源:FastIntegralImg.java


示例16: integrateRow

import net.imglib2.type.numeric.NumericType; //导入依赖的package包/类
static private final <T extends NumericType<T>> void integrateRow(
		final int rowDimension,
		final Interval iimg,
		final RandomAccess<T> r2,
		final T sum) {
	sum.setZero();
	r2.setPosition(1L, rowDimension);
	for (long i = 1; i < iimg.dimension(rowDimension); ++i) {
		sum.add(r2.get());
		r2.get().set(sum);
		r2.fwd(rowDimension);
	}
}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:14,代码来源:FastIntegralImg.java


示例17: withValue

import net.imglib2.type.numeric.NumericType; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
private static final NumericType<?> withValue(final Img<? extends NumericType<?>> img, final NumericType<?> type, final Number val) {
	final NumericType t = img.firstElement().createVariable();
	if (ARGBType.class.isAssignableFrom(t.getClass())) {
		int i = val.intValue();
		t.set(new ARGBType(i));
	} else {
		((RealType)t).setReal(val.doubleValue());
	}
	return t;
}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:12,代码来源:AbstractAffine3D.java


示例18: main

import net.imglib2.type.numeric.NumericType; //导入依赖的package包/类
static public final <T extends NumericType<T> & NativeType<T>> void main(final String[] args) {
	
	// Generate some data
	final FloatProcessor b1 = new FloatProcessor(512, 512);
	b1.setValue(127);
	b1.setRoi(new Roi(100, 100, 200, 200));
	b1.fill();
	
	final FloatProcessor b2 = new FloatProcessor(512, 512);
	b2.setValue(128);
	b2.setRoi(new Roi(10, 30, 200, 200));
	b2.fill();
	
	final Img<T> img1 = ImageJFunctions.wrap(new ImagePlus("1", b1));
	final Img<T> img2 = ImageJFunctions.wrap(new ImagePlus("2", b2));
	
	
	// Add two ROIs of both images
	final RectangleROI<T> r1 = new RectangleROI<T>(img1, 50, 50, 200, 200);
	final RectangleROI<T> r2 = new RectangleROI<T>(img2, 50, 50, 200, 200);
	try {
		final Img<FloatType> result = new Add(r1, r2).asImage(1);
		
		new ImageJ();
		
		ImageJFunctions.show(r1, "r1");
		ImageJFunctions.show(r2, "r2");
		ImageJFunctions.show(img1, "img1");
		ImageJFunctions.show(img2, "img2");
		ImageJFunctions.show(result, "added rois");

	} catch (final Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:36,代码来源:Rois.java


示例19: add

import net.imglib2.type.numeric.NumericType; //导入依赖的package包/类
@OpMethod(op = net.imagej.ops.math.IIToIIOutputII.Add.class)
public <T extends NumericType<T>> IterableInterval<T> add(
	final IterableInterval<T> out, final IterableInterval<T> in1,
	final IterableInterval<T> in2)
{
	@SuppressWarnings("unchecked")
	final IterableInterval<T> result = (IterableInterval<T>) ops().run(
		net.imagej.ops.Ops.Math.Add.class, out, in1, in2);
	return result;
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:11,代码来源:MathNamespace.java


示例20: divide

import net.imglib2.type.numeric.NumericType; //导入依赖的package包/类
@OpMethod(op = net.imagej.ops.math.IIToIIOutputII.Divide.class)
public <T extends NumericType<T>> IterableInterval<T> divide(
	final IterableInterval<T> out, final IterableInterval<T> in1,
	final IterableInterval<T> in2)
{
	@SuppressWarnings("unchecked")
	final IterableInterval<T> result = (IterableInterval<T>) ops().run(
		net.imagej.ops.Ops.Math.Divide.class, out, in1, in2);
	return result;
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:11,代码来源:MathNamespace.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java GameMath类代码示例发布时间:2022-05-21
下一篇:
Java Activity类代码示例发布时间: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