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

Java Converter类代码示例

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

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



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


示例16: getImage

import net.imglib2.converter.Converter; //导入依赖的package包/类
@Override
public RandomAccessibleInterval< UnsignedShortType > getImage( final ViewId view )
{
	final String fn = filenames.get( view );
	if ( useImageJOpener )
	{
		final ImagePlus imp = new ImagePlus( fn );
		if ( imp.getType() == ImagePlus.GRAY16 )
			return new ImgPlus<>( ImageJFunctions.wrapShort( imp ) );
		else if ( imp.getType() == ImagePlus.GRAY8 )
		{
			System.out.println( "wrapping" );
			return new ImgPlus<>(
				new ImgView<>(
						Converters.convert(
								( RandomAccessibleInterval<UnsignedByteType> ) ImageJFunctions.wrapByte( imp ),
								new Converter< UnsignedByteType, UnsignedShortType >() {
									@Override
									public void convert( final UnsignedByteType input, final UnsignedShortType output )
									{
										output.set( input.get() );
									}
								},
								new UnsignedShortType()
						), null ) );
		}
		else
			useImageJOpener = false;
	}

	try
	{
		return opener.openImg( fn, factory, type );
	}
	catch ( final ImgIOException e )
	{
		throw new RuntimeException( e );
	}
}
 
开发者ID:bigdataviewer,项目名称:bigdataviewer_fiji,代码行数:40,代码来源:LegacyStackImageLoader.java


示例17: createCompositeProjector

import net.imglib2.converter.Converter; //导入依赖的package包/类
private void createCompositeProjector( final IntervalView in, final Img< ARGBType > out )
    {
//        final UnsignedShortType min = new UnsignedShortType();
//        final UnsignedShortType max = new UnsignedShortType();
//        computeMinMax(Views.hyperSlice(in, 2, 0), min, max);

        converterListARGB = new ArrayList< Converter< UnsignedShortType, ARGBType > >();
        converterListARGB.add( new RealARGBConverter< UnsignedShortType >( 0, 10000 ) );
//        converterListARGB.add( new RealARGBConverter< UnsignedShortType >( min.get(), max.get() * 0.1 ) );
        converterListARGB.add( new ChannelARGBConverter( G ) );
        converterListARGB.add( new ChannelARGBConverter( R ) );
        converterListARGB.add( new ChannelARGBConverter( B ) );

        projector = new CompositeXYRandomAccessibleProjector( in, out, converterListARGB, 2 );

        projector.setComposite( true );
//		projector.setComposite( 0, false );
//		projector.setComposite( 1, true );
//		projector.setComposite( 2, false );
        projector.map();

        currentInteractiveViewer2D.getJHotDrawDisplay().setImageDim(new Dimension((int)in.max(0), (int)in.max(1)));
        currentInteractiveViewer2D.updateConverter(new TypeIdentity<ARGBType>());
        final ARGBType t = new ARGBType();
        t.set(150 << 16 | 150 << 8 | 150);
        currentInteractiveViewer2D.updateIntervalSource(Views.extendValue(out, t));
        currentInteractiveViewer2D.getJHotDrawDisplay().resetTransform();
    }
 
开发者ID:fjug,项目名称:IDDEA,代码行数:29,代码来源:InteractiveDisplayView.java


示例18: updateRealConverter

import net.imglib2.converter.Converter; //导入依赖的package包/类
/**
 * Update the realConverter with new converter.
 * @param converter
 */
public void updateRealConverter(final Converter converter)
{
    if(InteractiveRealViewer2D.class.isInstance(currentInteractiveViewer2D))
    {
        ((InteractiveRealViewer2D) currentInteractiveViewer2D).updateConverter(converter);
    }
}
 
开发者ID:fjug,项目名称:IDDEA,代码行数:12,代码来源:InteractiveDisplayView.java


示例19: RAIToPNG

import net.imglib2.converter.Converter; //导入依赖的package包/类
@Override
public <T extends RealType<T>> Object RAIToPNG(
        final RandomAccessibleInterval<T> source, //
        final int xAxis, final int yAxis, final int cAxis, //
        final ValueScaling scaling, final long... pos) {

    final IntervalView<T> image = ops.transform().zeroMinView(source);

    final int w = xAxis >= 0 ? (int) image.dimension(xAxis) : 1;
    final int h = yAxis >= 0 ? (int) image.dimension(yAxis) : 1;
    final int c = cAxis >= 0 ? (int) image.dimension(cAxis) : 1;
    final ARGBScreenImage target = new ARGBScreenImage(w, h);
    final ArrayList<Converter<T, ARGBType>> converters = new ArrayList<>(c);

    final double min, max;
    final boolean full = scaling == ValueScaling.FULL
            || //
            scaling == ValueScaling.AUTO && isNarrowType(source);

    if (full) {
        // scale the intensities based on the full range of the type
        min = image.firstElement().getMinValue();
        max = image.firstElement().getMaxValue();
    } else {
        // scale the intensities based on the sample values
        final IterableInterval<T> ii = ops.transform().flatIterableView(source);
        final Pair<T, T> minMax = ops.stats().minMax(ii);
        min = minMax.getA().getRealDouble();
        max = minMax.getB().getRealDouble();
    }

    for (int i = 0; i < c; i++) {
        final ColorTable8 lut = c == 1
                ? //
                ColorTables.GRAYS : ColorTables.getDefaultColorTable(i);
        converters.add(new RealLUTConverter<>(min, max, lut));
    }
    final CompositeXYProjector<T> proj = new CompositeXYProjector<>(image,
            target, converters, cAxis);
    if (pos != null && pos.length > 0) {
        proj.setPosition(pos);
    }
    proj.setComposite(true);
    proj.map();

    // Convert to PNG
    return NotebookConverters.toPNG(target.image());

}
 
开发者ID:scijava,项目名称:scijava-jupyter-kernel,代码行数:50,代码来源:DefaultImageJNotebookService.java


示例20: FastIntegralImg

import net.imglib2.converter.Converter; //导入依赖的package包/类
/** Chooses the smallest type possible to hold the sums; may have to iterate all values and sum them to find out. */
public FastIntegralImg(final Img<R> img) {
	super(create(img, (Converter<R,T>)null));
}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:5,代码来源:FastIntegralImg.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java Focused类代码示例发布时间:2022-05-22
下一篇:
Java OccurrenceConsumer类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap