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


Java Converter.convert方法代码示例

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


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

示例1: intersect

import net.imglib2.converter.Converter; //导入方法依赖的package包/类
public static < T, U, V > void intersect(
			final RandomAccessibleInterval< T > source1,
			final RandomAccessibleInterval< U > source2,
			final RandomAccessibleInterval< V > target,
//			Filter< T, U > filter, // can be handled in writer? only writer: requires write for every pixel but simpler interface
			final Converter< Pair< T, U >, V > writer )
	{
		final RandomAccessiblePair< T, U > sourcesPair = new RandomAccessiblePair< >( source1, source2 );
		final RandomAccessiblePair< Pair< T, U >, V > sourcesTargetPair = new RandomAccessiblePair< >( sourcesPair, target );

		for ( final Pair< Pair< T, U >, V > entry : Views.interval( sourcesTargetPair, target ) )
		{
			final Pair< T, U > sources = entry.getA();
			writer.convert( sources, entry.getB() );
		}
	}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:17,代码来源:LabelRestrictToSegmentController.java

示例2: transferN

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

示例3: compute

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

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

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

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

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

示例4: compute

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

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

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

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

	final DoubleType threshold = new DoubleType(mean.getRealDouble() * (1.0d +
		p * Math.exp(-q * mean.getRealDouble()) + k * ((stdDev.getRealDouble() /
			r) - 1.0)));

	// 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,代码行数:27,代码来源:LocalPhansalkarThresholdIntegral.java

示例5: compute

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

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

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

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

	final DoubleType threshold = new DoubleType(mean.getRealDouble() * (1.0d +
		k * ((Math.sqrt(stdDev.getRealDouble()) / r) - 1.0)));

	// 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,代码行数:26,代码来源:LocalSauvolaThresholdIntegral.java

示例6: populate1

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

示例7: populate2

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

示例8: compute

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

示例9: compute

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

示例10: compute

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

示例11: compute

import net.imglib2.converter.Converter; //导入方法依赖的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.converter.Converter.convert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。