public PSFExtraction( final RandomAccessibleInterval< T > img, final Collection< RealLocalizable > locations, final T type, final long[] size, final boolean multithreaded ) { // Mirror produces some artifacts ... so we use periodic this( Views.extendPeriodic( img ), locations, type, size, multithreaded ); }
@Override public ExtendedRandomAccessibleInterval<T, F> calculate(F input) { return Views.extendPeriodic(input); } }
public ExtendPeriodic(final RandomAccessibleInterval<T> img) { super(Views.interval(Views.extendPeriodic(img), img)); }
/** * Expand a RandomAccessibleInterval as specified by border. source will be * extended with a periodic out-of-bounds strategy. * * @param source * the interval to expand. * @return Expansion of the {@link RandomAccessibleInterval} source as * specified by border. */ public static < T > IntervalView< T > expandPeriodic( final RandomAccessibleInterval< T > source, final long... border ) { return interval( extendPeriodic( source ), Intervals.expand( source, border ) ); }
/** * Expand a RandomAccessibleInterval as specified by border. source will be * extended with a periodic out-of-bounds strategy. * * @param source * the interval to expand. * @return Expansion of the {@link RandomAccessibleInterval} source as * specified by border. */ public static < T > IntervalView< T > expandPeriodic( final RandomAccessibleInterval< T > source, final long... border ) { return interval( extendPeriodic( source ), Intervals.expand( source, border ) ); }
public static < R extends RealType< R > > Img< ComplexFloatType > computeKernelFFT( final Interval kernelConvolutionInterval, final long[] min, final long[] max, final boolean complexConjugate, final RandomAccessible< R > kernel, final ImgFactory< ComplexFloatType > fftFactory, final ExecutorService service ) { // assemble the correct kernel (size of the input + extended periodic + // top left at center of input kernel) final RandomAccessibleInterval< R > kernelInput = Views.interval( Views.extendPeriodic( Views.interval( kernel, kernelConvolutionInterval ) ), new FinalInterval( min, max ) ); final Img< ComplexFloatType > fftKernel = FFT.realToComplex( kernelInput, fftFactory, service ); // if complexConjugate is set we are computing the correlation // instead of the convolution (same as mirroring the kernel) // should be false by default if ( complexConjugate ) FFTMethods.complexConjugate( fftKernel ); return fftKernel; }
public static < R extends RealType< R > > Img< ComplexFloatType > computeKernelFFT( final Interval kernelConvolutionInterval, final long[] min, final long[] max, final boolean complexConjugate, final RandomAccessible< R > kernel, final ImgFactory< ComplexFloatType > fftFactory, final ExecutorService service ) { // assemble the correct kernel (size of the input + extended periodic + // top left at center of input kernel) final RandomAccessibleInterval< R > kernelInput = Views.interval( Views.extendPeriodic( Views.interval( kernel, kernelConvolutionInterval ) ), new FinalInterval( min, max ) ); final Img< ComplexFloatType > fftKernel = FFT.realToComplex( kernelInput, fftFactory, service ); // if complexConjugate is set we are computing the correlation // instead of the convolution (same as mirroring the kernel) // should be false by default if ( complexConjugate ) FFTMethods.complexConjugate( fftKernel ); return fftKernel; }
/** * Creates the histograms for all contextual regions. The image is scanned * line by line as this (hopefully) speeds up the underlying image cursor. */ private int[] createHistograms( K img ) { RandomAccess< T > ra = Views.extendPeriodic( img ).randomAccess(); int[] histograms = new int[ m_ctxNrX * m_ctxNrY * histNrBins ]; for ( int ctxY = 0; ctxY < m_ctxNrY; ctxY++ ) { for ( int y = 0; y < ctxYSize; y++ ) { for ( int ctxX = 0; ctxX < m_ctxNrX; ctxX++ ) { for ( int x = 0; x < ctxXSize; x++ ) { ra.fwd( 0 ); final int bin = valueToBin( ra.get().getRealDouble() ); final int offSet = ctxY * m_ctxNrX * histNrBins + ctxX * histNrBins; final int index = offSet + bin; histograms[ index ]++; } } ra.fwd( 1 ); } } return histograms; }
ExtendedRandomAccessibleInterval<FloatType, Img<FloatType>> extendedInvPCM = Views.extendPeriodic(invPCM); final LocalNeighborhoodCursor<FloatType> localCursor = new LocalNeighborhoodCursor<FloatType>( extendedInvPCM.randomAccess(), 1 );
@Override @SuppressWarnings("unchecked") public O calculate(final I kernel, final Dimensions paddedDimensions) { Dimensions paddedFFTInputDimensions; // if an fftsize op has been set recompute padded size if (fftSizeOp != null) { long[][] sizes = fftSizeOp.calculate(paddedDimensions); paddedFFTInputDimensions = new FinalDimensions(sizes[0]); } else { paddedFFTInputDimensions = paddedDimensions; } // compute where to place the final Interval for the kernel so that the // coordinate in the center // of the kernel is shifted to position (0,0). final Interval kernelConvolutionInterval = paddingIntervalCentered.calculate( kernel, paddedFFTInputDimensions); final Interval kernelConvolutionIntervalOrigin = paddingIntervalOrigin .calculate(kernel, kernelConvolutionInterval); return (O) Views.interval(Views.extendPeriodic(Views.interval(Views .extendValue(kernel, Util.getTypeFromInterval(kernel).createVariable()), kernelConvolutionInterval)), kernelConvolutionIntervalOrigin); }
final RandomAccessibleInterval< R > kernelInput = Views.interval( Views.extendPeriodic( Views.interval( kernel, kernelConvolutionInterval ) ), new FinalInterval( min, max ) ); final RandomAccessibleInterval< R > imgInput = Views.interval( img, imgConvolutionInterval );
final RandomAccessibleInterval< R > kernelInput = Views.interval( Views.extendPeriodic( Views.interval( kernel, kernelConvolutionInterval ) ), new FinalInterval( min, max ) ); final RandomAccessibleInterval< R > imgInput = Views.interval( img, imgConvolutionInterval );
final RandomAccessibleInterval< R > kernelInput = Views.interval( Views.extendPeriodic( Views.interval( kernel, kernelConvolutionInterval ) ), new FinalInterval( min, max ) ); final RandomAccessibleInterval< R > imgInput = Views.interval( img, imgConvolutionInterval );
break; case PERIODICAL: RandomAccess< T > srcRA = Views.extendPeriodic( op ).randomAccess(); Cursor< T > resCur = Views.iterable( res ).localizingCursor(); while ( resCur.hasNext() )
cursor = Views.extendPeriodic( laPlacian ).randomAccess(); else cursor = laPlacian.randomAccess();
final RandomAccessibleInterval< R > kernelInput = Views.interval( Views.extendPeriodic( Views.interval( kernel, kernelConvolutionInterval ) ), new FinalInterval( min, max ) ); final RandomAccessibleInterval< R > imgInput = Views.interval( img, imgConvolutionInterval );
default: RandomAccess< T > srcRA = Views.extendPeriodic( op ).randomAccess(); Cursor< T > resCur = res.localizingCursor(); while ( resCur.hasNext() )
@Test public void extendPeriodicTest() { Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType()); OutOfBounds<DoubleType> il2 = Views.extendPeriodic(img).randomAccess(); OutOfBounds<DoubleType> opr = ops.transform().extendPeriodicView(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); }