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


Java Img.firstElement方法代码示例

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


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

示例1: imageStats

import net.imglib2.img.Img; //导入方法依赖的package包/类
public static <T extends RealType<T> & NativeType<T>> void imageStats( Img<T> img  )
{

	RealImageFunction<T,T> imgfun = new RealImageFunction<T,T>( img, img.firstElement() );
	IterableIntervalPointSet ptset = new IterableIntervalPointSet( img );

	StatCalculator<T> sc = new	StatCalculator<T>( imgfun, ptset );

	double am = sc.arithmeticMean();
	double sd = sc.sampleStdDev();
	double sk = sc.sampleSkew();
	double kr = sc.sampleKurtosis();

	logger.info("am: " + am);
	logger.info("sd: " + sd);
	logger.info("sk: " + sk);
	logger.info("kr: " + kr);

}
 
开发者ID:bogovicj,项目名称:hhmi-exp,代码行数:20,代码来源:OpsExamples.java

示例2: validateFormat

import net.imglib2.img.Img; //导入方法依赖的package包/类
private void validateFormat(final Img<T> image) throws IOException {
	final int ndims = image.numDimensions();
	if (ndims != 2) {
		final long[] dims = new long[ndims];
		image.dimensions(dims);
		throw new IOException("Can only process 2D images, not an image with " +
			ndims + " dimensions (" + Arrays.toString(dims) + ")");
	}
	if (!(image.firstElement() instanceof UnsignedShortType)) {
		throw new IOException("Can only process uint16 images. " +
			"Please convert your image first via Image > Type > 16-bit.");
	}
}
 
开发者ID:fiji,项目名称:microscope-image-quality,代码行数:14,代码来源:MicroscopeImageFocusQualityClassifier.java

示例3: computeSmallestType

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

示例4: process

import net.imglib2.img.Img; //导入方法依赖的package包/类
@SuppressWarnings({"rawtypes", "unchecked"})
static private final <R extends RealType<R>> Img<FloatType>
process(final Img<R> img, final double[] sigma)throws Exception {
	// NB: Reference type as RealType<?> rather than R to avoid javac issue.
	// We also use a raw cast for img below, to avoid another javac limitation.
	// Caution: These issues are not apparent when using the Eclipse compiler.
	final RealType<?> type = img.firstElement();
	return processFloat(
			type instanceof FloatType ?
			  (Img)img
			: Compute.inFloats(1, new ImageFunction(img)), sigma);
}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:13,代码来源:Gauss.java

示例5: evalFun

import net.imglib2.img.Img; //导入方法依赖的package包/类
public static <T extends RealType<T> & NativeType<T>> void evalFun( Img<T> img1, Img<T> img2, RealBinaryOperation<T,T,T> fun  )
{
	Img<T> res = img1.factory().create( img1, img1.firstElement() );
	RealImageFunction<T,T> imgfun = new RealImageFunction<T,T>( img1, img1.firstElement() );
	
	ImgCombine<T,T,T> imcomb = new ImgCombine<T,T,T>(fun);
	imcomb.compute(img1, img2, res);
	
	ImgOps.writeFloat(res, "/groups/jain/home/bogovicj/learning/advanced-imglib2/images/bee-1-wave.tif");
	
}
 
开发者ID:bogovicj,项目名称:hhmi-exp,代码行数:12,代码来源:OpsExamples.java

示例6: testInvertUnsigned

import net.imglib2.img.Img; //导入方法依赖的package包/类
@Test
public void testInvertUnsigned() {

	// unsigned type test
	Img<UnsignedByteType> in = generateUnsignedByteArrayTestImg(true, 5, 5);
	Img<UnsignedByteType> out = in.factory().create(in, new UnsignedByteType());

	ops.run(InvertII.class, out, in);

	UnsignedByteType firstIn = in.firstElement();
	UnsignedByteType firstOut = out.firstElement();

	assertEquals((int) firstIn.getMaxValue() - firstIn.getInteger(), firstOut
		.getInteger());

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

示例7: testInvertSigned

import net.imglib2.img.Img; //导入方法依赖的package包/类
@Test
public void testInvertSigned() {

	// signed type test
	Img<ByteType> in = generateByteArrayTestImg(true, 5, 5);
	Img<ByteType> out = in.factory().create(in, new ByteType());

	ops.run(InvertII.class, out, in);

	ByteType firstIn = in.firstElement();
	ByteType firstOut = out.firstElement();

	assertEquals(firstIn.get() * -1 - 1, firstOut.get());

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


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