@Override public ExtendedRandomAccessibleInterval<T, F> calculate(F input) { return Views.extendZero(input); }
/** * Constructs a new 2x2x2 neighborhood * * <p> * <em>NB</em>: Copies reference * </p> * * @param interval Image space where the neighborhood is located */ public Octant(final RandomAccessibleInterval<B> interval) { access = Views.extendZero(interval).randomAccess(); }
/** * Expand a RandomAccessibleInterval as specified by border. source will be * extended with the zero-element of that data type. * * @param source * the interval to expand. * @return Expansion of the {@link RandomAccessibleInterval} source as * specified by border. */ public static < T extends NumericType< T > > IntervalView< T > expandZero( final RandomAccessibleInterval< T > source, final long... border ) { return interval( extendZero( source ), Intervals.expand( source, border ) ); }
/** * Expand a RandomAccessibleInterval as specified by border. source will be * extended with the zero-element of that data type. * * @param source * the interval to expand. * @return Expansion of the {@link RandomAccessibleInterval} source as * specified by border. */ public static < T extends NumericType< T > > IntervalView< T > expandZero( final RandomAccessibleInterval< T > source, final long... border ) { return interval( extendZero( source ), Intervals.expand( source, border ) ); }
@Override public final < R extends RealType< R > > Img< FloatType > evaluate( final Img< R > img, final R alpha ) throws ParseException { RandomAccessibleInterval< FloatType > fimg = ImgLibUtils.copyToFloatTypeImage( img ); try { Gauss3.gauss( alpha.getRealDouble(), Views.extendZero( fimg ), fimg ); } catch ( IncompatibleTypeException e ) { throw new RuntimeException( e ); } return ( Img< FloatType > ) fimg; }
@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 ); }
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 ); }
@Override public RealRandomAccess<FloatType> realRandomAccess() { return Views.interpolate( Views.extendZero( this.contentBasedImg ), new NLinearInterpolatorFactory< FloatType >() ).realRandomAccess(); }
public Traverser(RandomAccessibleInterval<B> interval) { xSize = interval.dimension(0); ySize = interval.dimension(1); zSize = interval.dimension(2); x1 = xSize - 1; y1 = ySize - 1; z1 = zSize - 1; access = Views.extendZero(interval).randomAccess(); } }
public void convolve1( final RandomAccessibleInterval< FloatType > image, final Img< FloatType > kernel, final Img< ComplexFloatType > kernelFFT, final Img< FloatType > result ) { final FFTConvolution< FloatType > fftConvolution = new FFTConvolution< FloatType >( Views.extendMirrorSingle( image ), image, Views.extendZero( kernel ), kernel, result, fftFactory ); fftConvolution.setExecutorService( service ); fftConvolution.setKeepImgFFT( false ); fftConvolution.setKernelFFT( kernelFFT ); fftConvolution.convolve(); }
public void convolve1( final RandomAccessibleInterval< FloatType > image, final Img< FloatType > kernel, final Img< ComplexFloatType > kernelFFT, final Img< FloatType > result ) { final FFTConvolution< FloatType > fftConvolution = new FFTConvolution< FloatType >( Views.extendMirrorSingle( image ), image, Views.extendZero( kernel ), kernel, result, fftFactory ); fftConvolution.setExecutorService( service ); fftConvolution.setKeepImgFFT( false ); fftConvolution.setKernelFFT( kernelFFT ); fftConvolution.convolve(); }
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 ); }
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 void convolve2( final RandomAccessibleInterval< FloatType > image, final Img< FloatType > kernel, final Img< ComplexFloatType > kernelFFT, final Img< FloatType > result ) { final FFTConvolution< FloatType > fftConvolution = new FFTConvolution< FloatType >( Views.extendValue( image, new FloatType( 1.0f ) ), // ratio outside of the deconvolved space (psi) is 1, shouldn't matter here though image, Views.extendZero( kernel ), kernel, result, fftFactory ); fftConvolution.setExecutorService( service ); fftConvolution.setKeepImgFFT( false ); fftConvolution.setKernelFFT( kernelFFT ); fftConvolution.convolve(); }
public void convolve2( final RandomAccessibleInterval< FloatType > image, final Img< FloatType > kernel, final Img< ComplexFloatType > kernelFFT, final Img< FloatType > result ) { final FFTConvolution< FloatType > fftConvolution = new FFTConvolution< FloatType >( Views.extendValue( image, new FloatType( 1.0f ) ), // ratio outside of the deconvolved space (psi) is 1, shouldn't matter here though image, Views.extendZero( kernel ), kernel, result, fftFactory ); fftConvolution.setExecutorService( service ); fftConvolution.setKeepImgFFT( false ); fftConvolution.setKernelFFT( kernelFFT ); fftConvolution.convolve(); }
private void processSlice( final RandomAccessibleInterval< T > in, final IterableInterval< T > out ) { final Cursor< T > cursor = out.localizingCursor(); final RectangleShape shape = new RectangleShape( radius, false ); final NeighborhoodsAccessible< T > nracessible = shape.neighborhoodsRandomAccessible( Views.extendZero( in ) ); final RandomAccess< Neighborhood< T >> nra = nracessible.randomAccess( in ); final int size = ( int ) nra.get().size(); final double[] values = new double[ size ]; // Fill buffer with median values. while ( cursor.hasNext() ) { cursor.fwd(); nra.setPosition( cursor ); int index = 0; for ( final T pixel : nra.get() ) { values[ index++ ] = pixel.getRealDouble(); } Arrays.sort( values, 0, index ); cursor.get().setReal( values[ ( index - 1 ) / 2 ] ); } }
@Test public void UnshearIntervalTest() { Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 2, 2 }, new DoubleType()); Cursor<DoubleType> imgC = img.cursor(); while (imgC.hasNext()) { imgC.next().set(1); } Cursor<DoubleType> il2 = Views .unshear(Views.shear(Views.extendZero(img), 0, 1), new FinalInterval(new long[] { 0, 0 }, new long[] { 3, 3 }), 0, 1) .cursor(); RandomAccess<DoubleType> opr = ops.transform() .unshearView(Views.shear(Views.extendZero(img), 0, 1), new FinalInterval(new long[] { 0, 0 }, new long[] { 3, 3 }), 0, 1) .randomAccess(); while (il2.hasNext()) { il2.next(); opr.setPosition(il2); assertEquals(il2.get().get(), opr.get().get(), 1e-10); } } }
@Test public void defaultUnshearTest() { Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 2, 2 }, new DoubleType()); Cursor<DoubleType> imgC = img.cursor(); while (imgC.hasNext()) { imgC.next().set(1); } TransformView<DoubleType> il2 = Views.unshear(Views.shear(Views.extendZero(img), 0, 1), 0, 1); TransformView<DoubleType> opr = ops.transform().unshearView(Views.shear(Views.extendZero(img), 0, 1), 0, 1); Cursor<DoubleType> il2C = Views.interval(il2, new FinalInterval(new long[] { 0, 0 }, new long[] { 3, 3 })) .cursor(); RandomAccess<DoubleType> oprRA = Views .interval(opr, new FinalInterval(new long[] { 0, 0 }, new long[] { 3, 3 })).randomAccess(); while (il2C.hasNext()) { il2C.next(); oprRA.setPosition(il2C); assertEquals(il2C.get().get(), oprRA.get().get(), 1e-10); } }
@Test public void extendZeroTest() { Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType()); OutOfBounds<DoubleType> il2 = Views.extendZero(img).randomAccess(); OutOfBounds<DoubleType> opr = ops.transform().extendZeroView(img).randomAccess(); il2.setPosition(new int[] { -1, -1 }); opr.setPosition(new int[] { -1, -1 }); assertEquals(il2.get().get(), opr.get().get(), 1e-10); il2.setPosition(new int[] { 11, 11 }); opr.setPosition(new int[] { 11, 11 }); assertEquals(il2.get().get(), opr.get().get(), 1e-10); }