|
| 1 | +package net.imglib2.algorithm.math; |
| 2 | + |
| 3 | +import java.util.Map; |
| 4 | + |
| 5 | +import net.imglib2.RandomAccessible; |
| 6 | +import net.imglib2.algorithm.math.abstractions.IFunction; |
| 7 | +import net.imglib2.algorithm.math.abstractions.OFunction; |
| 8 | +import net.imglib2.algorithm.math.abstractions.RandomAccessOnly; |
| 9 | +import net.imglib2.algorithm.math.abstractions.ViewableFunction; |
| 10 | +import net.imglib2.algorithm.math.execution.IterableRandomAccessibleFunction; |
| 11 | +import net.imglib2.algorithm.math.execution.LetBinding; |
| 12 | +import net.imglib2.algorithm.math.execution.RandomAccessibleOffsetSourceDirect; |
| 13 | +import net.imglib2.algorithm.math.execution.Variable; |
| 14 | +import net.imglib2.converter.Converter; |
| 15 | +import net.imglib2.type.numeric.RealType; |
| 16 | + |
| 17 | +public class OffsetSource< I extends RealType< I > > extends ViewableFunction implements RandomAccessOnly< I > |
| 18 | +{ |
| 19 | + private final IFunction f; |
| 20 | + private final long[] offset; |
| 21 | + |
| 22 | + public OffsetSource( final IFunction f, final long[] offset ) |
| 23 | + { |
| 24 | + this.f = f; |
| 25 | + this.offset = offset; |
| 26 | + } |
| 27 | + |
| 28 | + @Override |
| 29 | + public < O extends RealType< O > > OFunction< O > reInit( |
| 30 | + final O tmp, |
| 31 | + final Map< String, LetBinding< O > > bindings, |
| 32 | + final Converter< RealType< ? >, O > converter, |
| 33 | + final Map< Variable< O >, OFunction< O > > imgSources ) |
| 34 | + { |
| 35 | + return new RandomAccessibleOffsetSourceDirect< O >( |
| 36 | + tmp.copy(), |
| 37 | + new IterableRandomAccessibleFunction< O, O >( this.f, converter, tmp.createVariable(), tmp.createVariable(), null ), |
| 38 | + this.offset ); |
| 39 | + } |
| 40 | + |
| 41 | + @Override |
| 42 | + public RandomAccessible< I > getRandomAccessible() |
| 43 | + { |
| 44 | + return this.view(); |
| 45 | + } |
| 46 | +} |
0 commit comments