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


Java Converter类代码示例

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


Converter类属于net.imglib2.converter包,在下文中一共展示了Converter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: normalize

import net.imglib2.converter.Converter; //导入依赖的package包/类
private RandomAccessibleInterval<FloatType> normalize(final RandomAccessibleInterval<T> image) {
	// NB: Copied from previous Tensors class to give same results
	// NB: Theoretically unsound, but works in practice for needed
	// cases.
	final double min = image.randomAccess().get().getMinValue();
	final double max = image.randomAccess().get().getMaxValue();
	Converter<T, FloatType> normalizer = (input, output) -> output
			.setReal((input.getRealDouble() - min) / (max - min));
	return Converters.convert(image, normalizer, new FloatType());
}
 
开发者ID:fiji,项目名称:microscope-image-quality,代码行数:11,代码来源:MicroscopeImageFocusQualityClassifier.java

示例7: OuterProductView

import net.imglib2.converter.Converter; //导入依赖的package包/类
public OuterProductView( final RandomAccessibleInterval< T > vec1, final RandomAccessibleInterval< U > vec2, final Converter< T, V > c1, final Converter< U, V > c2, final V v )
{
	super( new FinalInterval( vec2.dimension( 0 ), vec1.dimension( 0 ) ) );
	this.vec1 = vec1;
	this.vec2 = vec2;
	this.c1 = c1;
	this.c2 = c2;
	this.v = v.createVariable();
	this.dim = new long[] { vec2.dimension( 0 ), vec1.dimension( 0 ) };
	this.max = Arrays.stream( this.dim ).map( l -> l - 1 ).toArray();
	this.min = new long[ N_DIM ];
}
 
开发者ID:saalfeldlab,项目名称:z-spacing,代码行数:13,代码来源:OuterProductView.java

示例8: identityRealTypeConverter

import net.imglib2.converter.Converter; //导入依赖的package包/类
static private final Converter<RealType<?>, RealType<?>> identityRealTypeConverter() {
	return new Converter<RealType<?>, RealType<?>>() {
		@Override
		public final void convert(final RealType<?> input, final RealType<?> output) {
			output.setReal(input.getRealDouble());
		}
	};
}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:9,代码来源:FastIntegralImg.java

示例9: identityIntegerTypeConverter

import net.imglib2.converter.Converter; //导入依赖的package包/类
static private final Converter<IntegerType<?>, IntegerType<?>> identityIntegerTypeConverter() {
	return new Converter<IntegerType<?>, IntegerType<?>>() {
		@Override
		public final void convert(final IntegerType<?> input, final IntegerType<?> output) {
			output.setInteger(input.getIntegerLong());
		}
	};
}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:9,代码来源:FastIntegralImg.java

示例10: 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

示例11: 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

示例12: process

import net.imglib2.converter.Converter; //导入依赖的package包/类
private static final <T extends RealType<T>> Img<DoubleType> process(
		final Img<T> img) {
	final IntegralImgDouble<T> o =
		new IntegralImgDouble<T>(img, new DoubleType(),
			new Converter<T, DoubleType>() {
				@Override
				public final void convert(final T input, final DoubleType output) {
					output.set(input.getRealDouble());
				}
			});
	o.process();
	return o.getResult();
}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:14,代码来源:IntegralImage.java

示例13: 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

示例14: initialize

import net.imglib2.converter.Converter; //导入依赖的package包/类
@Override
public void initialize() {
	es = ts.getExecutorService();

	createOp = Functions.unary(ops(), CreateImgFromDimsAndType.class, RandomAccessibleInterval.class,
			new FinalInterval(in().dimension(0), in().dimension(1), numOrientations), new FloatType());

	createImgOp = Functions.unary(ops(), CreateImgFromDimsAndType.class, RandomAccessibleInterval.class,
			new FinalInterval(in().dimension(0), in().dimension(1)), new FloatType());

	converterToFloat = new Converter<T, FloatType>() {
		@Override
		public void convert(final T arg0, final FloatType arg1) {
			arg1.setReal(arg0.getRealFloat());
		}
	};

	converterGetMax = new Converter<GenericComposite<FloatType>, FloatType>() {
		@Override
		public void convert(GenericComposite<FloatType> input, FloatType output) {
			int idx = 0;
			float max = 0;
			for (int i = 0; i < in().dimension(2); i++) {
				if (Math.abs(input.get(i).getRealFloat()) > max) {
					max = Math.abs(input.get(i).getRealFloat());
					idx = i;
				}
			}
			output.setReal(input.get(idx).getRealFloat());
		}
	};
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:33,代码来源:HistogramOfOrientedGradients2D.java

示例15: 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


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