Java源码示例:net.imglib2.interpolation.InterpolatorFactory

示例1
@SuppressWarnings("unchecked")
public RandomAccessibleIntervalDataSource(
		final RandomAccessibleInterval<D> dataSource,
		final RandomAccessibleInterval<T> source,
		final AffineTransform3D mipmapTransform,
		final Invalidate<Long> invalidate,
		final Function<Interpolation, InterpolatorFactory<D, RandomAccessible<D>>> dataInterpolation,
		final Function<Interpolation, InterpolatorFactory<T, RandomAccessible<T>>> interpolation,
		final String name) {
	this(
			new RandomAccessibleInterval[] {dataSource},
			new RandomAccessibleInterval[] {source},
			new AffineTransform3D[] {mipmapTransform},
			invalidate,
			dataInterpolation,
			interpolation,
			name);
}
 
示例2
public RandomAccessibleIntervalDataSource(
		final RandomAccessibleInterval<D>[] dataSources,
		final RandomAccessibleInterval<T>[] sources,
		final AffineTransform3D[] mipmapTransforms,
		final Invalidate<Long> invalidate,
		final Function<Interpolation, InterpolatorFactory<D, RandomAccessible<D>>> dataInterpolation,
		final Function<Interpolation, InterpolatorFactory<T, RandomAccessible<T>>> interpolation,
		final String name) {
	this(
			dataSources,
			sources,
			mipmapTransforms,
			invalidate,
			dataInterpolation,
			interpolation,
			() -> Util.getTypeFromInterval(dataSources[0]).createVariable(),
			() -> Util.getTypeFromInterval(sources[0]).createVariable(),
			name
	    );
}
 
示例3
public RandomAccessibleIntervalDataSource(
		final RandomAccessibleInterval<D>[] dataSources,
		final RandomAccessibleInterval<T>[] sources,
		final AffineTransform3D[] mipmapTransforms,
		final Invalidate<Long> invalidate,
		final Function<Interpolation, InterpolatorFactory<D, RandomAccessible<D>>> dataInterpolation,
		final Function<Interpolation, InterpolatorFactory<T, RandomAccessible<T>>> interpolation,
		final Supplier<D> dataTypeSupplier,
		final Supplier<T> typeSupplier,
		final String name) {
	super();
	this.mipmapTransforms = mipmapTransforms;
	this.dataSources = dataSources;
	this.sources = sources;
	this.invalidate = invalidate;
	this.dataInterpolation = dataInterpolation;
	this.interpolation = interpolation;
	this.dataTypeSupplier = dataTypeSupplier;
	this.typeSupplier = typeSupplier;
	this.name = name;
}
 
示例4
public ConvertedDataSource(
		final DataSource<D, T> source,
		final Converter<D, U> dataTypeConverter,
		final Converter<T, V> typeConverter,
		final Supplier<U> dataTypeSupplier,
		final Supplier<V> typeSupplier,
		final Function<Interpolation, InterpolatorFactory<U, RandomAccessible<U>>> dataInterpolation,
		final Function<Interpolation, InterpolatorFactory<V, RandomAccessible<V>>> interpolation,
		final String name)
{
	super();
	this.source = source;
	this.dataTypeConverter = dataTypeConverter;
	this.typeConverter = typeConverter;
	this.dataTypeExtensionSupplier = dataTypeSupplier;
	this.typeExtensionSupplier = typeSupplier;
	this.dataInterpolation = dataInterpolation;
	this.interpolation = interpolation;
	this.name = name;
}
 
示例5
public N5DataSource(
		final N5Meta meta,
		final AffineTransform3D transform,
		final String name,
		final SharedQueue queue,
		final int priority,
		final Function<Interpolation, InterpolatorFactory<D, RandomAccessible<D>>> dataInterpolation,
		final Function<Interpolation, InterpolatorFactory<T, RandomAccessible<T>>> interpolation) throws
		IOException {
	super(
			RandomAccessibleIntervalDataSource.asDataWithInvalidate((ImagesWithTransform<D, T>[])getData(meta.writer(), meta.dataset(), transform, queue, priority)),
			dataInterpolation,
			interpolation,
			name);

	this.meta = meta;
}
 
示例6
/**
 *
 * @param reader container
 * @param dataset dataset
 * @param transform transforms voxel data into real world coordinates
 * @param priority in fetching queue
 * @param dataInterpolation interpolator factory for data
 * @param interpolation interpolator factory for viewer data
 * @param name initialize with this name
 * @param <T> data type
 * @param <V> viewer type
 * @return {@link DataSource}
 * @throws IOException if any N5 operation throws {@link IOException}
 */
public static <T extends NativeType<T>, V extends Volatile<T> & NativeType<V>>
DataSource<T, V> openScalarAsSource(
		final N5Reader reader,
		final String dataset,
		final AffineTransform3D transform,
		final SharedQueue queue,
		final int priority,
		final Function<Interpolation, InterpolatorFactory<T, RandomAccessible<T>>> dataInterpolation,
		final Function<Interpolation, InterpolatorFactory<V, RandomAccessible<V>>> interpolation,
		final String name) throws IOException, ReflectionException {

	LOG.debug("Creating N5 Data source from {} {}", reader, dataset);
	return new N5DataSource<>(
			Objects.requireNonNull(N5Meta.fromReader(reader, dataset)),
			transform,
			name,
			queue,
			priority,
			dataInterpolation,
			interpolation);
}
 
示例7
/**
 * @param  interpolatorFactory  factory to include in the returned warp field.
 *
 * @return a warp field built from this builder's consensus set data.
 *         The returned field will utilize the specified interpolator factory.
 */
public AffineWarpField build(final InterpolatorFactory<RealComposite<DoubleType>, RandomAccessible<RealComposite<DoubleType>>> interpolatorFactory) {

    final int[] modelIndexGrid = buildModelIndexGrid();

    final AffineWarpField affineWarpField =
            new AffineWarpField(width, height, rowCount, columnCount, interpolatorFactory);

    for (int row = 0; row < rowCount; row++) {
        for (int column = 0; column < columnCount; column++) {

            final int gridIndex = (row * rowCount) + column;
            final int modelIndex = modelIndexGrid[gridIndex];
            final Affine2D model = consensusSetModelList.get(modelIndex);

            final double[] affineMatrixElements = new double[6];
            model.toArray(affineMatrixElements);

            affineWarpField.set(row, column, affineMatrixElements);
        }
    }

    return affineWarpField;
}
 
示例8
/**
 * Appends serialization of this transform's offsets and warp field to the specified data string.
 *
 * @param  data             target data string.
 */
private void serializeWarpField(final StringBuilder data) {
    data.append(locationOffsets[0]).append(' ').append(locationOffsets[1]).append(' ');
    data.append(affineWarpField.getWidth()).append(' ').append(affineWarpField.getHeight()).append(' ');
    data.append(affineWarpField.getRowCount()).append(' ').append(affineWarpField.getColumnCount()).append(' ');
    final InterpolatorFactory<RealComposite<DoubleType>, RandomAccessible<RealComposite<DoubleType>>> factory =
            affineWarpField.getInterpolatorFactory();
    data.append(factory.getClass().getCanonicalName()).append(' ');
    final double[] values = affineWarpField.getValues();
    if (values.length < 64) { // skip encoding for smaller fields to simplify visual inspection and testing
        data.append(NO_ENCODING);
        for (final double value : values) {
            data.append(' ').append(value);
        }
    } else {
        data.append(BASE_64_ENCODING).append(' ').append(DoubleArrayConverter.encodeBase64(values));
    }
}
 
示例9
public ProcessIndependentPortion(
		final ImagePortion portion,
		final RandomAccessibleInterval< T > img,
		final InterpolatorFactory<T, RandomAccessible< T > > interpolatorFactory,
		final AffineTransform3D transform,
		final Img< T > fusedImg,
		final BoundingBoxGUI bb )
{
	this.portion = portion;
	this.img = img;
	this.interpolatorFactory = interpolatorFactory;
	this.transform = transform;
	this.fusedImg = fusedImg;
	this.bb = bb;
	this.downSampling = bb.getDownSampling();
	
	if ( downSampling == 1 )
		doDownSampling = false;
	else
		doDownSampling = true;
}
 
示例10
public ProcessParalellPortion(
		final ImagePortion portion,
		final ArrayList< RandomAccessibleInterval< T > > imgs,
		final InterpolatorFactory<T, RandomAccessible< T > > interpolatorFactory,
		final AffineTransform3D[] transforms,
		final Img< T > fusedImg,
		final BoundingBoxGUI bb )
{
	this.portion = portion;
	this.imgs = imgs;
	this.interpolatorFactory = interpolatorFactory;
	this.transforms = transforms;
	this.fusedImg = fusedImg;
	this.bb = bb;
	this.downSampling = bb.getDownSampling();
	
	if ( downSampling == 1 )
		doDownSampling = false;
	else
		doDownSampling = true;
}
 
示例11
public RandomAccessibleIntervalDataSource(
		final DataWithInvalidate<D, T> dataWithInvalidate,
		final Function<Interpolation, InterpolatorFactory<D, RandomAccessible<D>>> dataInterpolation,
		final Function<Interpolation, InterpolatorFactory<T, RandomAccessible<T>>> interpolation,
		final String name) {
	this(
			dataWithInvalidate.data,
			dataWithInvalidate.viewData,
			dataWithInvalidate.transforms,
			dataWithInvalidate.invalidate,
			dataInterpolation,
			interpolation,
			name);
}
 
示例12
public RandomAccessibleIntervalDataSource(
		final Triple<RandomAccessibleInterval<D>[], RandomAccessibleInterval<T>[], AffineTransform3D[]> data,
		final Invalidate<Long> invalidate,
		final Function<Interpolation, InterpolatorFactory<D, RandomAccessible<D>>> dataInterpolation,
		final Function<Interpolation, InterpolatorFactory<T, RandomAccessible<T>>> interpolation,
		final String name) {
	this(data.getA(), data.getB(), data.getC(), invalidate, dataInterpolation, interpolation, name);
}
 
示例13
@Override
public InterpolatorFactory<T, RandomAccessible<T>> apply(final Interpolation t)
{
	return t.equals(Interpolation.NLINEAR)
	       ? new NLinearInterpolatorFactory<>()
	       : new NearestNeighborInterpolatorFactory<>();
}
 
示例14
private static <T extends NativeType<T>> Function<Interpolation, InterpolatorFactory<T, RandomAccessible<T>>>
interpolation(final N5Reader n5, final String dataset)
throws IOException
{
	return N5Types.isLabelMultisetType(n5, dataset)
	       ? i -> new NearestNeighborInterpolatorFactory<>()
	       : (Function) realTypeInterpolation();
}
 
示例15
private static <T extends RealType<T>> Function<Interpolation, InterpolatorFactory<T, RandomAccessible<T>>>
realTypeInterpolation()
{
	return i -> i.equals(Interpolation.NLINEAR)
	            ? new NLinearInterpolatorFactory<>()
	            : new NearestNeighborInterpolatorFactory<>();
}
 
示例16
public ImageInterpolation( final Img< T > image, final InterpolatorFactory< T, RandomAccessible< T > > interpolatorFactory, final boolean mirror )
{
	this.image = image;
	this.interpolatorFactory = interpolatorFactory;
	if ( mirror )
		this.interpolated = Views.interpolate( Views.extendMirrorSingle( image ), interpolatorFactory );
	else
		this.interpolated = Views.interpolate( Views.extendZero( image ), interpolatorFactory );
}
 
示例17
/**
 * Constructs a field with the specified dimensions.
 * Each affine is initialized with identity values.
 *
 * @param  width                pixel width of the warp field.
 * @param  height               pixel height of the warp field.
 * @param  rowCount             number of affine rows in the warp field.
 * @param  columnCount          number of affine columns in the warp field.
 * @param  interpolatorFactory  factory for desired interpolator instance.
 */
public AffineWarpField(final double width,
                       final double height,
                       final int rowCount,
                       final int columnCount,
                       final InterpolatorFactory<RealComposite<DoubleType>, RandomAccessible<RealComposite<DoubleType>>> interpolatorFactory)
        throws IllegalArgumentException {
    this(width, height, rowCount, columnCount,
         getDefaultValues(rowCount, columnCount),
         interpolatorFactory);
}
 
示例18
/**
 * Returns a {@link RealRandomAccessible} using interpolation
 *
 * @param input the {@link EuclideanSpace} to be interpolated
 * @param factory the {@link InterpolatorFactory} to provide interpolators for
 *          source
 * @return
 */
@OpMethod(
	op = net.imagej.ops.transform.interpolateView.DefaultInterpolateView.class)
public <T, I extends EuclideanSpace> RealRandomAccessible<T> interpolateView(
	final I input, final InterpolatorFactory<T, I> factory)
{
	return (RealRandomAccessible<T>) ops().run(
		Ops.Transform.InterpolateView.class, input, factory);
}
 
示例19
/**
 * Executes the "scale" operation on the given arguments.
 *
 * @param in
 * @param scaleFactors
 * @param interpolator
 * @return
 */
@OpMethod(op = net.imagej.ops.transform.scaleView.DefaultScaleView.class)
public <T extends RealType<T>> RandomAccessibleInterval<T> scaleView(
	final RandomAccessibleInterval<T> in, final double[] scaleFactors,
	final InterpolatorFactory<T, RandomAccessible<T>> interpolator)
{
	@SuppressWarnings("unchecked")
	final RandomAccessibleInterval<T> result =
		(RandomAccessibleInterval<T>) ops().run(Ops.Transform.ScaleView.class, in,
			scaleFactors, interpolator);
	return result;
}
 
示例20
/**
 * Executes the "scale" operation on the given arguments while preserving
 * interval bounds.
 *
 * @param in
 * @param scaleFactors
 * @param interpolator
 * @param outOfBoundsFactory
 * @return
 */
@OpMethod(ops = net.imagej.ops.transform.scaleView.DefaultScaleView.class)
public <T extends RealType<T>> RandomAccessibleInterval<T> scaleView(
	final RandomAccessibleInterval<T> in, final double[] scaleFactors,
	final InterpolatorFactory<T, RandomAccessible<T>> interpolator,
	final OutOfBoundsFactory<T, RandomAccessible<T>> outOfBoundsFactory)
{
	final RandomAccessibleInterval<T> result =
		(RandomAccessibleInterval<T>) ops().run(Ops.Transform.ScaleView.class, in,
			scaleFactors, interpolator, outOfBoundsFactory);
	return result;
}
 
示例21
public ProcessSequentialPortionWeights(
		final ImagePortion portion,
		final ArrayList< RandomAccessibleInterval< T > > imgs,
		final ArrayList< ArrayList< RealRandomAccessible< FloatType > > > weights,
		final InterpolatorFactory< T, RandomAccessible< T > > interpolatorFactory,
		final AffineTransform3D[] transforms,
		final Img< T > fusedImg,
		final Img< FloatType > weightImg,
		final BoundingBoxGUI bb )
{
	super( portion, imgs, interpolatorFactory, transforms, fusedImg, weightImg, bb );
	
	this.weights = weights;
}
 
示例22
public ProcessSequentialPortion(
		final ImagePortion portion,
		final ArrayList< RandomAccessibleInterval< T > > imgs,
		final InterpolatorFactory<T, RandomAccessible< T > > interpolatorFactory,
		final AffineTransform3D[] transforms,
		final Img< T > fusedImg,
		final Img< FloatType > weightImg,
		final BoundingBoxGUI bb )
{
	super( portion, imgs, interpolatorFactory, transforms, fusedImg, bb );
	
	this.weightImg = weightImg;
}
 
示例23
public ProcessParalellPortionWeight(
		final ImagePortion portion,
		final ArrayList< RandomAccessibleInterval< T > > imgs,
		final ArrayList< RealRandomAccessible< FloatType > > weights,
		final InterpolatorFactory< T, RandomAccessible< T > > interpolatorFactory,
		final AffineTransform3D[] transforms,
		final Img< T > fusedImg,
		final BoundingBoxGUI bb )
{
	super( portion, imgs, interpolatorFactory, transforms, fusedImg, bb );
	
	this.weights = weights;
}
 
示例24
public < T extends RealType< T > > InterpolatorFactory< T, RandomAccessible< T > > getInterpolatorFactory( final T type )
{
	if ( getInterpolation() == 0 )
		return new NearestNeighborInterpolatorFactory<T>();
	else
		return new NLinearInterpolatorFactory< T >();
}
 
示例25
public ProcessSequentialPortionWeight(
		final ImagePortion portion,
		final ArrayList< RandomAccessibleInterval< T > > imgs,
		final ArrayList< RealRandomAccessible< FloatType > > weights,
		final InterpolatorFactory< T, RandomAccessible< T > > interpolatorFactory,
		final AffineTransform3D[] transforms,
		final Img< T > fusedImg,
		final Img< FloatType > weightImg,
		final BoundingBoxGUI bb )
{
	super( portion, imgs, interpolatorFactory, transforms, fusedImg, weightImg, bb );
	
	this.weights = weights;
}
 
示例26
public ProcessParalellPortionWeights(
		final ImagePortion portion,
		final ArrayList< RandomAccessibleInterval< T > > imgs,
		final ArrayList< ArrayList< RealRandomAccessible< FloatType > > > weights,
		final InterpolatorFactory< T, RandomAccessible< T > > interpolatorFactory,
		final AffineTransform3D[] transforms,
		final Img< T > fusedImg,
		final BoundingBoxGUI bb )
{
	super( portion, imgs, interpolatorFactory, transforms, fusedImg, bb );
	
	this.weights = weights;
}
 
示例27
final static private < T extends RealType< T > >InterpolatorFactory< RealComposite< T >, RandomAccessible< RealComposite< T > > > interpolatorFactory( final Interpolation interpolation )
{
	switch ( interpolation )
	{
	case NN:
		return new NearestNeighborInterpolatorFactory< RealComposite< T > >();
	default:
		return new NLinearInterpolatorFactory< RealComposite< T > >();
	}
}
 
示例28
public LinearIntensityMap( final RandomAccessibleInterval< T > source, final InterpolatorFactory< RealComposite< T >, RandomAccessible< RealComposite< T > > > interpolatorFactory )
{
	this.interpolatorFactory = interpolatorFactory;
	final CompositeIntervalView< T, RealComposite< T > > collapsedSource = Views.collapseReal( source );
	dimensions = new FinalInterval( collapsedSource );
	final double[] shift = new double[ dimensions.numDimensions() ];
	for ( int d = 0; d < shift.length; ++d )
		shift[ d ] = 0.5;
	translation = new Translation( shift );

	final RandomAccessible< RealComposite< T > > extendedCollapsedSource = Views.extendBorder( collapsedSource );
	coefficients = Views.interpolate( extendedCollapsedSource, interpolatorFactory );
}
 
示例29
public static <T extends NumericType<T>> Function<Interpolation, InterpolatorFactory<T, RandomAccessible<T>>>
nearestNeighborOrNLinear()
{
	return new NeaerestNeighborOrNLinear<>();
}
 
示例30
public static <T> Function<Interpolation, InterpolatorFactory<T, RandomAccessible<T>>> nearestNeighbor()
{
	return new NearestNeighborOnly<>();
}