@Override public ExtendedRandomAccessibleInterval<T, F> calculate(F input) { return Views.extendMirrorDouble(input); }
public ExtendMirrorDouble(final RandomAccessibleInterval<T> img) { super(Views.interval(Views.extendMirrorDouble(img), img)); }
/** * Expand a RandomAccessibleInterval as specified by border. Out of bounds * pixels will be sampled by mirroring source. Boundary pixels are repeated. * * @param source * the interval to expand. * @return Expansion of the {@link RandomAccessibleInterval} source as * specified by border. */ public static < T > IntervalView< T > expandMirrorDouble( final RandomAccessibleInterval< T > source, final long... border ) { return interval( extendMirrorDouble( source ), Intervals.expand( source, border ) ); }
/** * Expand a RandomAccessibleInterval as specified by border. Out of bounds * pixels will be sampled by mirroring source. Boundary pixels are repeated. * * @param source * the interval to expand. * @return Expansion of the {@link RandomAccessibleInterval} source as * specified by border. */ public static < T > IntervalView< T > expandMirrorDouble( final RandomAccessibleInterval< T > source, final long... border ) { return interval( extendMirrorDouble( source ), Intervals.expand( source, border ) ); }
@Override public void compute(RandomAccessibleInterval<T> input, RandomAccessibleInterval<T> output) { RandomAccessibleInterval<T> in = input; for (int i = input.numDimensions() - 1; i >= 0; i--) { RandomAccessibleInterval<T> derivative = createRAI.calculate(input); if (dimension == i) { kernelBConvolveOp.compute(Views.interval(Views.extendMirrorDouble(in), input), derivative); } else { kernelAConvolveOps[i].compute(Views.interval(Views.extendMirrorDouble(in), input), derivative); } in = derivative; } addOp.compute(output, in, output); }
@Override public void run() { // HACK: Explicit assignment is needed for OpenJDK javac. ExtendedRandomAccessibleInterval<T, Img<T>> extendedInput = Views.extendMirrorDouble(input); OutOfBounds<T> ura = extendedInput.randomAccess(); // HACK: Explicit assignment is needed for OpenJDK javac. ExtendedRandomAccessibleInterval<FloatType, RandomAccessibleInterval<FloatType>> extendedD = Views.extendMirrorDouble(D); OutOfBounds<FloatType> dra = extendedD.randomAccess(); Cursor<FloatType> incrementCursor = increment.localizingCursor(); long[] position = new long[input.numDimensions()]; float[][] D = initDiffusionTensorArray(); float[] U = initDensityArray(); incrementCursor.jumpFwd(chunk.getStartPosition()); for (long j = 0; j < chunk.getLoopSize(); j++) { // Move input cursor. incrementCursor.fwd(); // Move local neighborhood input cursor. ura.setPosition(incrementCursor); incrementCursor.localize(position); // Move diffusion tensor cursor in the fist N dimension for (int i = 0; i < position.length; i++) { dra.setPosition(position[i], i); } // Iterate in local neighborhood and yield values yieldDensity(ura, U); yieldDiffusionTensor(dra, D); // Compute increment from arrays incrementCursor.get().setReal(diffusionScheme(U, D)); } // looping on all pixel }
ExtendedRandomAccessibleInterval< T, RandomAccessibleInterval< T >> extendedInput = Views.extendMirrorDouble( input ); OutOfBounds< T > ura = extendedInput.randomAccess(); ExtendedRandomAccessibleInterval< FloatType, RandomAccessibleInterval< FloatType >> extendedD = Views.extendMirrorDouble( D ); OutOfBounds< FloatType > dra = extendedD.randomAccess();
@SuppressWarnings("unchecked") @Override public void compute(RandomAccessibleInterval<T> in, RandomAccessibleInterval<T> out) { final RandomAccessible<FloatType> convertedIn = Converters.convert(Views.extendMirrorDouble(in), converterToFloat, new FloatType());
b.copyBlock( Views.extendMirrorDouble( image ), block );
@Test public void extendMirrorDoubleTest() { Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType()); OutOfBounds<DoubleType> il2 = Views.extendMirrorDouble(img).randomAccess(); OutOfBounds<DoubleType> opr = ops.transform().extendMirrorDoubleView(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); }