@Override public RealRandomAccessible<T> calculate(I input) { return Views.interpolate(input, factory); }
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 ); }
public PSFExtraction( final RandomAccessible< T > img, final Collection< RealLocalizable > locations, final T type, final long[] size, final boolean multithreaded ) { this( Views.interpolate( img, new NLinearInterpolatorFactory< T >() ), locations, type, size, multithreaded ); }
public DeformationFieldTransform( final RandomAccessibleInterval< T > def ) { this( Views.interpolate( def, new NLinearInterpolatorFactory< T >() ) ); }
@SuppressWarnings( { "unchecked", "rawtypes" } ) public InterpolatingSource( final RandomAccessible< T > source, final A sourceTransform, final Converter< ? super T, ARGBType > converter ) { final InterpolatorFactory< T, RandomAccessible< T > > nLinearInterpolatorFactory; if ( ARGBType.class.isInstance( source.randomAccess().get() ) ) nLinearInterpolatorFactory = ( InterpolatorFactory ) new NLinearInterpolatorARGBFactory(); else nLinearInterpolatorFactory = new NLinearInterpolatorFactory< >(); this.sourceTransform = sourceTransform; this.converter = converter; sourceInterpolants = new RealRandomAccessible[] { Views.interpolate( source, new NearestNeighborInterpolatorFactory< T >() ), Views.interpolate( source, nLinearInterpolatorFactory ) }; interpolation = 0; }
@Override public RealRandomAccessible< T > getInterpolatedSource( final int t, final int level, final Interpolation method ) { return Views.interpolate( Views.extendZero( getSource( t, level ) ), interpolators.get( method ) ); }
@Override public RealRandomAccess<FloatType> realRandomAccess( final RealInterval interval ) { return Views.interpolate( Views.extendZero( this.contentBasedImg ), new NLinearInterpolatorFactory< FloatType >() ).realRandomAccess( interval ); }
@Override public RealRandomAccess<FloatType> realRandomAccess() { return Views.interpolate( Views.extendZero( this.contentBasedImg ), new NLinearInterpolatorFactory< FloatType >() ).realRandomAccess(); }
public static Img< FloatType > extractLI( final Img< FloatType > img, final long[] dim, final double[] center ) { final Img< FloatType > psf = new ArrayImgFactory< FloatType >().create( dim, new FloatType() ); final ArrayList< RealLocalizable > locations = new ArrayList<>(); locations.add( new RealPoint( center ) ); //locations.add( new RealPoint( new double[] { i.dimension( 0 ) / 2, i.dimension( 1 ) / 2, i.dimension( 2 ) / 2 } ) ); final RealRandomAccessible< FloatType > rra = Views.interpolate( Views.extendMirrorSingle( img ), new NLinearInterpolatorFactory<>() ); PSFExtraction.extractPSFLocal( rra, locations, psf ); return psf; }
public static Img< FloatType > extractNN( final Img< FloatType > img, final long[] dim, final double[] center ) { final Img< FloatType > psf = new ArrayImgFactory< FloatType >().create( dim, new FloatType() ); final ArrayList< RealLocalizable > locations = new ArrayList<>(); locations.add( new RealPoint( center ) ); //locations.add( new RealPoint( new double[] { i.dimension( 0 ) / 2, i.dimension( 1 ) / 2, i.dimension( 2 ) / 2 } ) ); final RealRandomAccessible< FloatType > rra = Views.interpolate( Views.extendMirrorSingle( img ), new NearestNeighborInterpolatorFactory<>()); PSFExtraction.extractPSFLocal( rra, locations, psf ); return psf; }
public RealRandomAccessible< FloatType > getRealRandomAccessible() { final NearestNeighborSearch< FloatType > search = new NearestNeighborSearchOnKDTree<>( new KDTree<>( qualityList ) ); return Views.interpolate( search, new NearestNeighborSearchInterpolatorFactory< FloatType >() ); }
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 ); }
public RandomAccessibleSource( final RandomAccessible< T > img, final Interval interval, final T type, final AffineTransform3D sourceTransform, final String name ) { super( type, name ); this.source = img; this.interval = interval; this.sourceTransform = sourceTransform; interpolatedSources = new RealRandomAccessible[ Interpolation.values().length ]; for ( final Interpolation method : Interpolation.values() ) interpolatedSources[ method.ordinal() ] = Views.interpolate( source, interpolators.get( method ) ); }
@Override public RandomAccessibleInterval<T> calculate(RandomAccessibleInterval<T> input) { final long[] newDims = Intervals.dimensionsAsLongArray(in()); for (int i = 0; i < Math.min(scaleFactors.length, in().numDimensions()); i++) { newDims[i] = Math.round(in().dimension(i) * scaleFactors[i]); } IntervalView<T> interval = Views.interval(Views.raster(RealViews.affineReal( Views.interpolate(Views.extendMirrorSingle(input), interpolator), new Scale(scaleFactors))), new FinalInterval(newDims)); return interval; }
public RandomAccessibleInterval< FloatType > getRandomAccessibleInterval( final int numPoints, final double power ) { final KNearestNeighborSearch< FloatType > search = new KNearestNeighborSearchOnKDTree<>( new KDTree<>( qualityList ), numPoints ); final RealRandomAccessible< FloatType > realRandomAccessible = Views.interpolate( search, new InverseDistanceWeightingInterpolatorFactory< FloatType >( power ) ); final RandomAccessible< FloatType > randomAccessible = Views.raster( realRandomAccessible ); final RandomAccessibleInterval< FloatType > rai = Views.interval( randomAccessible, interval ); return Views.interval( Views.extendZero( rai ), interval ); }
private void loadTimepoint( final int timepointIndex ) { currentTimePointIndex = timepointIndex; if ( isPresent( timepointIndex ) ) { final T zero = getType().createVariable(); zero.setZero(); currentSource = Views.hyperSlice( source, 3, timepointIndex ); for ( final Interpolation method : Interpolation.values() ) currentInterpolatedSources[ method.ordinal() ] = Views.interpolate( Views.extendValue( currentSource, zero ), interpolators.get( method ) ); } else { currentSource = null; Arrays.fill( currentInterpolatedSources, null ); } }
private void loadTimepoint( final int timepointIndex ) { currentTimePointIndex = timepointIndex; if ( isPresent( timepointIndex ) ) { final T zero = getType().createVariable(); zero.setZero(); final RandomAccessible< T > slice = Views.hyperSlice( source, 3, timepointIndex ); currentSource = Views.interval( slice, timeSliceInterval ); for ( final Interpolation method : Interpolation.values() ) currentInterpolatedSources[ method.ordinal() ] = Views.interpolate( slice, interpolators.get( method ) ); } else { currentSource = null; Arrays.fill( currentInterpolatedSources, null ); } }
public RandomAccessibleInterval< FloatType > getRandomAccessibleInterval() { // InverseDistanceWeightingInterpolatorFactory final NearestNeighborSearch< FloatType > search = new NearestNeighborSearchOnKDTree<>( new KDTree<>( qualityList ) ); final RealRandomAccessible< FloatType > realRandomAccessible = Views.interpolate( search, new NearestNeighborSearchInterpolatorFactory< FloatType >() ); final RandomAccessible< FloatType > randomAccessible = Views.raster( realRandomAccessible ); final RandomAccessibleInterval< FloatType > rai = Views.interval( randomAccessible, interval ); return Views.interval( Views.extendZero( rai ), interval ); }
public RandomAccessibleIntervalSource( final RandomAccessibleInterval< T > img, final T type, final AffineTransform3D sourceTransform, final String name ) { super( type, name ); this.source = img; this.sourceTransform = sourceTransform; interpolatedSources = new RealRandomAccessible[ Interpolation.values().length ]; final T zero = getType().createVariable(); zero.setZero(); for ( final Interpolation method : Interpolation.values() ) interpolatedSources[ method.ordinal() ] = Views.interpolate( Views.extendValue( source, zero ), interpolators.get( method ) ); }
@Test public void defaultInterpolateTest() { Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[]{10, 10}, new DoubleType()); MersenneTwisterFast r = new MersenneTwisterFast(SEED); for (DoubleType d : img) { d.set(r.nextDouble()); } RealRandomAccess<DoubleType> il2 = Views.interpolate(img, new FloorInterpolatorFactory<DoubleType>()).realRandomAccess(); RealRandomAccess<DoubleType> opr = ops.transform().interpolateView(img, new FloorInterpolatorFactory<DoubleType>()).realRandomAccess(); il2.setPosition(new double[]{1.75, 5.34}); opr.setPosition(new double[]{1.75, 5.34}); assertEquals(il2.get().get(), opr.get().get(), 1e-10); il2.setPosition(new double[]{3, 7}); opr.setPosition(new double[]{3, 7}); assertEquals(il2.get().get(), opr.get().get(), 1e-10); il2.setPosition(new double[]{8.37, 3.97}); opr.setPosition(new double[]{8.37, 3.97}); assertEquals(il2.get().get(), opr.get().get(), 1e-10); } }