net.imglib2.interpolation.InterpolatorFactory Java Examples

The following examples show how to use net.imglib2.interpolation.InterpolatorFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RandomAccessibleIntervalDataSource.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
@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);
}
 
Example #2
Source File: RandomAccessibleIntervalDataSource.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
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
	    );
}
 
Example #3
Source File: RandomAccessibleIntervalDataSource.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #4
Source File: ConvertedDataSource.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #5
Source File: ProcessParalellPortion.java    From SPIM_Registration with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #6
Source File: AffineWarpFieldTransform.java    From render with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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));
    }
}
 
Example #7
Source File: N5DataSource.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #8
Source File: ProcessIndependentPortion.java    From SPIM_Registration with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #9
Source File: ConsensusWarpFieldBuilder.java    From render with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @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;
}
 
Example #10
Source File: N5Data.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
/**
 *
 * @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);
}
 
Example #11
Source File: WeightedAverageFusion.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
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 >();
}
 
Example #12
Source File: TransformNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * 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);
}
 
Example #13
Source File: TransformNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * 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;
}
 
Example #14
Source File: TransformNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * 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;
}
 
Example #15
Source File: ProcessSequentialPortionWeights.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #16
Source File: ProcessSequentialPortion.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #17
Source File: ProcessParalellPortionWeight.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #18
Source File: AffineWarpField.java    From render with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #19
Source File: ProcessSequentialPortionWeight.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #20
Source File: ProcessParalellPortionWeights.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #21
Source File: LinearIntensityMap.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
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 > >();
	}
}
 
Example #22
Source File: LinearIntensityMap.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
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 );
}
 
Example #23
Source File: RandomAccessibleIntervalDataSource.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example #24
Source File: ImageInterpolation.java    From Stitching with GNU General Public License v2.0 5 votes vote down vote up
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 );
}
 
Example #25
Source File: N5DataSource.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
private static <T extends RealType<T>> Function<Interpolation, InterpolatorFactory<T, RandomAccessible<T>>>
realTypeInterpolation()
{
	return i -> i.equals(Interpolation.NLINEAR)
	            ? new NLinearInterpolatorFactory<>()
	            : new NearestNeighborInterpolatorFactory<>();
}
 
Example #26
Source File: N5DataSource.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
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();
}
 
Example #27
Source File: Interpolations.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
@Override
public InterpolatorFactory<T, RandomAccessible<T>> apply(final Interpolation t)
{
	return t.equals(Interpolation.NLINEAR)
	       ? new NLinearInterpolatorFactory<>()
	       : new NearestNeighborInterpolatorFactory<>();
}
 
Example #28
Source File: RandomAccessibleIntervalDataSource.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example #29
Source File: AffineWarpField.java    From render with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @return the default interpolator factory for warp field instances.
 */
public static InterpolatorFactory<RealComposite<DoubleType>, RandomAccessible<RealComposite<DoubleType>>> getDefaultInterpolatorFactory() {
    return new NLinearInterpolatorFactory<>();
}
 
Example #30
Source File: AffineWarpField.java    From render with GNU General Public License v2.0 4 votes vote down vote up
public InterpolatorFactory<RealComposite<DoubleType>, RandomAccessible<RealComposite<DoubleType>>> getInterpolatorFactory() {
    return interpolatorFactory;
}