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


Java DoubleType.add方法代码示例

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


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

示例1: compute

import net.imglib2.type.numeric.real.DoubleType; //导入方法依赖的package包/类
@Override
public void compute(final I center,
	final RectangleNeighborhood<Composite<DoubleType>> neighborhood,
	final BitType output)
{

	final DoubleType threshold = new DoubleType(0.0d);

	final DoubleType mean = new DoubleType();
	integralMean.compute(neighborhood, mean);

	threshold.add(mean);

	final DoubleType variance = new DoubleType();
	integralVariance.compute(neighborhood, variance);

	final DoubleType stdDev = new DoubleType(Math.sqrt(variance.get()));
	stdDev.mul(k);

	threshold.add(stdDev);

	// Subtract the contrast
	threshold.sub(new DoubleType(c));

	// Set value
	final Converter<I, DoubleType> conv = new RealDoubleConverter<>();
	final DoubleType centerPixelAsDoubleType = variance; // NB: Reuse
	// DoubleType
	conv.convert(center, centerPixelAsDoubleType);

	output.set(centerPixelAsDoubleType.compareTo(threshold) > 0);
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:33,代码来源:LocalNiblackThresholdIntegral.java

示例2: compute

import net.imglib2.type.numeric.real.DoubleType; //导入方法依赖的package包/类
@Override
public void compute(final RectangleNeighborhood<I> input,
	final DoubleType output)
{
	// computation according to
	// https://en.wikipedia.org/wiki/Summed_area_table
	final IntegralCursor<I> cursor = new IntegralCursor<>(input);
	final int dimensions = input.numDimensions();

	// Compute \sum (-1)^{dim - ||cornerVector||_{1}} * I(x^{cornerVector})
	final DoubleType sum = new DoubleType();
	sum.setZero();

	// Convert from input to return type
	final Converter<I, DoubleType> conv = new RealDoubleConverter<>();
	final DoubleType valueAsDoubleType = new DoubleType();

	while (cursor.hasNext()) {
		final I value = cursor.next().copy();
		conv.convert(value, valueAsDoubleType);

		// Obtain the cursor position encoded as corner vector
		final int cornerInteger = cursor.getCornerRepresentation();

		// Determine if the value has to be added (factor==1) or subtracted
		// (factor==-1)
		final DoubleType factor = new DoubleType(Math.pow(-1.0d, dimensions -
			IntegralMean.norm(cornerInteger)));
		valueAsDoubleType.mul(factor);

		sum.add(valueAsDoubleType);
	}

	output.set(sum);
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:36,代码来源:IntegralSum.java

示例3: compute

import net.imglib2.type.numeric.real.DoubleType; //导入方法依赖的package包/类
@Override
public void compute(final RectangleNeighborhood<Composite<I>> input,
	final DoubleType output)
{
	// computation according to
	// https://en.wikipedia.org/wiki/Summed_area_table
	final IntegralCursor<Composite<I>> cursorS1 = new IntegralCursor<>(input);
	final int dimensions = input.numDimensions();

	// Compute \sum (-1)^{dim - ||cornerVector||_{1}} * I(x^{cornerVector})
	final DoubleType sum1 = new DoubleType();
	sum1.setZero();

	// Convert from input to return type
	final Converter<I, DoubleType> conv = new RealDoubleConverter<>();

	// Compute \sum (-1)^{dim - ||cornerVector||_{1}} * I(x^{cornerVector})
	final DoubleType sum2 = new DoubleType();
	sum2.setZero();

	final DoubleType valueAsDoubleType = new DoubleType();

	while (cursorS1.hasNext()) {
		final Composite<I> compositeValue = cursorS1.next();
		final I value1 = compositeValue.get(0).copy();
		conv.convert(value1, valueAsDoubleType);

		// Obtain the cursor position encoded as corner vector
		final int cornerInteger1 = cursorS1.getCornerRepresentation();

		// Determine if the value has to be added (factor==1) or subtracted
		// (factor==-1)
		final DoubleType factor = new DoubleType(Math.pow(-1.0d, dimensions -
			IntegralMean.norm(cornerInteger1)));
		valueAsDoubleType.mul(factor);

		sum1.add(valueAsDoubleType);

		final I value2 = compositeValue.get(1).copy();
		conv.convert(value2, valueAsDoubleType);

		// Determine if the value has to be added (factor==1) or subtracted
		// (factor==-1)
		valueAsDoubleType.mul(factor);

		sum2.add(valueAsDoubleType);
	}

	final int area = (int) Intervals.numElements(Intervals.expand(input, -1l));

	valueAsDoubleType.set(area); // NB: Reuse available DoubleType
	sum1.mul(sum1);
	sum1.div(valueAsDoubleType); // NB

	sum2.sub(sum1);
	valueAsDoubleType.sub(new DoubleType(1)); // NB
	sum2.div(valueAsDoubleType); // NB

	output.set(sum2);
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:61,代码来源:IntegralVariance.java

示例4: compute

import net.imglib2.type.numeric.real.DoubleType; //导入方法依赖的package包/类
@Override
public void compute(final RectangleNeighborhood<Composite<I>> input,
	final DoubleType output)
{
	// computation according to
	// https://en.wikipedia.org/wiki/Summed_area_table
	final IntegralCursor<Composite<I>> cursor = new IntegralCursor<>(input);
	final int dimensions = input.numDimensions();

	// Compute \sum (-1)^{dim - ||cornerVector||_{1}} * I(x^{cornerVector})
	final DoubleType sum = new DoubleType();
	sum.setZero();

	// Convert from input to return type
	final Converter<I, DoubleType> conv = new RealDoubleConverter<>();
	final DoubleType valueAsDoubleType = new DoubleType();

	while (cursor.hasNext()) {
		final I value = cursor.next().get(0).copy();
		conv.convert(value, valueAsDoubleType);

		// Obtain the cursor position encoded as corner vector
		final int cornerInteger = cursor.getCornerRepresentation();

		// Determine if the value has to be added (factor==1) or subtracted
		// (factor==-1)
		final DoubleType factor = new DoubleType(Math.pow(-1.0d, dimensions -
			IntegralMean.norm(cornerInteger)));
		valueAsDoubleType.mul(factor);

		sum.add(valueAsDoubleType);
	}

	final int area = (int) Intervals.numElements(Intervals.expand(input, -1l));

	// Compute mean by dividing the sum divided by the number of elements
	valueAsDoubleType.set(area); // NB: Reuse DoubleType
	sum.div(valueAsDoubleType);

	output.set(sum);
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:42,代码来源:IntegralMean.java


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