@Override public MixedTransformView<T> calculate(RandomAccessible<T> input) { return Views.offset(input, offset); }
final static protected < T > RandomAccessibleInterval< T > zeroMinN( final RandomAccessibleInterval< T > source ) { final long[] min = new long[ source.numDimensions() ]; final int n = min.length - 1; min[ n ] = source.min( n ); return Views.offset( source, min ); }
final static protected < T > RandomAccessibleInterval< T > zeroMinN( final RandomAccessibleInterval< T > source ) { final long[] min = new long[ source.numDimensions() ]; final int n = min.length - 1; min[ n ] = source.min( n ); return Views.offset( source, min ); }
/** * Define an interval on a RandomAccessible and translate it such that the * min corner is at the origin. It is the callers responsibility to ensure * that the source RandomAccessible is defined in the specified interval. * * @param randomAccessible * the source * @param offset * offset of min corner. * @param dimension * size of the interval. * @return a RandomAccessibleInterval */ public static < T > IntervalView< T > offsetInterval( final RandomAccessible< T > randomAccessible, final long[] offset, final long[] dimension ) { final int n = randomAccessible.numDimensions(); final long[] min = new long[ n ]; final long[] max = new long[ n ]; for ( int d = 0; d < n; ++d ) max[ d ] = dimension[ d ] - 1; return Views.interval( Views.offset( randomAccessible, offset ), min, max ); }
/** * Define an interval on a RandomAccessible and translate it such that the * min corner is at the origin. It is the callers responsibility to ensure * that the source RandomAccessible is defined in the specified interval. * * @param randomAccessible * the source * @param offset * offset of min corner. * @param dimension * size of the interval. * @return a RandomAccessibleInterval */ public static < T > IntervalView< T > offsetInterval( final RandomAccessible< T > randomAccessible, final long[] offset, final long[] dimension ) { final int n = randomAccessible.numDimensions(); final long[] min = new long[ n ]; final long[] max = new long[ n ]; for ( int d = 0; d < n; ++d ) max[ d ] = dimension[ d ] - 1; return Views.interval( Views.offset( randomAccessible, offset ), min, max ); }
/** * @deprecated Please use {@link Views#translate(RandomAccessibleInterval, long...)} * with a negative offset instead. * <p> * Translate such that pixel at offset in interval is at the origin in the * resulting view. This is equivalent to translating by -offset. * * @param interval * the source * @param offset * offset of the source view. The pixel at offset becomes the * origin of resulting view. */ @Deprecated public static < T > IntervalView< T > offset( final RandomAccessibleInterval< T > interval, final long... offset ) { final int n = interval.numDimensions(); final long[] min = new long[ n ]; final long[] max = new long[ n ]; interval.min( min ); interval.max( max ); for ( int d = 0; d < n; ++d ) { min[ d ] -= offset[ d ]; max[ d ] -= offset[ d ]; } return Views.interval( Views.offset( ( RandomAccessible< T > ) interval, offset ), min, max ); }
/** * Define an interval on a RandomAccessible and translate it such that the * min corner is at the origin. It is the callers responsibility to ensure * that the source RandomAccessible is defined in the specified interval. * * @param randomAccessible * the source * @param interval * the interval on source that should be cut out and translated * to the origin. * @return a RandomAccessibleInterval */ public static < T > IntervalView< T > offsetInterval( final RandomAccessible< T > randomAccessible, final Interval interval ) { final int n = randomAccessible.numDimensions(); final long[] offset = new long[ n ]; final long[] min = new long[ n ]; final long[] max = new long[ n ]; interval.min( offset ); interval.max( max ); for ( int d = 0; d < n; ++d ) max[ d ] -= offset[ d ]; return Views.interval( Views.offset( randomAccessible, offset ), min, max ); }
/** * Translate such that pixel at offset in interval is at the origin in the * resulting view. This is equivalent to translating by -offset. * * @param interval * the source * @param offset * offset of the source view. The pixel at offset becomes the * origin of resulting view. */ public static < T > IntervalView< T > offset( final RandomAccessibleInterval< T > interval, final long... offset ) { final int n = interval.numDimensions(); final long[] min = new long[ n ]; final long[] max = new long[ n ]; interval.min( min ); interval.max( max ); for ( int d = 0; d < n; ++d ) { min[ d ] -= offset[ d ]; max[ d ] -= offset[ d ]; } return Views.interval( Views.offset( ( RandomAccessible< T > ) interval, offset ), min, max ); }
/** * Define an interval on a RandomAccessible and translate it such that the * min corner is at the origin. It is the callers responsibility to ensure * that the source RandomAccessible is defined in the specified interval. * * @param randomAccessible * the source * @param interval * the interval on source that should be cut out and translated * to the origin. * @return a RandomAccessibleInterval */ public static < T > IntervalView< T > offsetInterval( final RandomAccessible< T > randomAccessible, final Interval interval ) { final int n = randomAccessible.numDimensions(); final long[] offset = new long[ n ]; final long[] min = new long[ n ]; final long[] max = new long[ n ]; interval.min( offset ); interval.max( max ); for ( int d = 0; d < n; ++d ) max[ d ] -= offset[ d ]; return Views.interval( Views.offset( randomAccessible, offset ), min, max ); }
/** * @param <T> The {@link Type} of the source image. * @param source The image to paste, which can be smaller than the {@param target} image. * @param target The function that expresses the target image. * @param offset The offset from origin for the pasting operation. * @throws Exception */ public Paste( final RandomAccessibleInterval<T> source, final IFunction target, final long[] offset) throws Exception { this.background = AlgorithmUtil.type(source, 0); this.a = new ImageFunction<T>(new RandomAccessibleIntervalImgProxy<T>( Views.interval( Views.offset(Views.extendValue(source, background), offset), extractDimensions(target)))); this.b = target; }
final IntervalView< T > offsetTarget = Views.offset( target, offset ); final ExtendedRandomAccessibleInterval< T, Img< T >> extended = Views.extendValue( source, minVal );
public <R extends RealType<R>> Paste( final RandomAccessibleInterval<T> source, final IterableRealInterval<R> target, final long[] offset) throws Exception { this.background = AlgorithmUtil.type(source, 0); this.a = new ImageFunction<T>(new RandomAccessibleIntervalImgProxy<T>( Views.interval( Views.offset(Views.extendValue(source, background), offset), new FinalInterval(Util.intervalDimensions(target))))); this.b = new ImageFunction<R>(target); }
@Override public void run() { final IntervalView< T > intervalView = Views.offset( largeSource, offset ); final Cursor< T > cursor = create.cursor(); cursor.jumpFwd( chunk.getStartPosition() ); final RandomAccess< T > randomAccess = intervalView.randomAccess(); for ( long step = 0; step < chunk.getLoopSize(); step++ ) { cursor.fwd(); randomAccess.setPosition( cursor ); cursor.get().set( randomAccess.get() ); } } };
minopposite[ d ] = -minopposite[ d ]; final IntervalView< FloatType > to = Views.offset( floatImg, minopposite ); spots = DetectionUtils.findLocalMaxima( to, threshold, calibration, radius, doSubPixelLocalization, numThreads );
final IntervalView< T > offsetTarget = Views.offset( target, offset ); final T minVal = MorphologyUtils.createVariable( source, source ); minVal.setReal( minVal.getMinValue() );
final IntervalView< T > offsetTarget = Views.offset( target, offset ); final T maxVal = MorphologyUtils.createVariable( source, source ); maxVal.setReal( maxVal.getMaxValue() );
/** * Copy an interval of the specified source image on a float image. * * @param img * the source image. * @param interval * the interval in the source image to copy. * @param factory * a factory used to build the float image. * @return a new float Img. Careful: even if the specified interval does not * start at (0, 0), the new image will have its first pixel at * coordinates (0, 0). */ public static final < T extends RealType< T >> Img< FloatType > copyToFloatImg( final RandomAccessible< T > img, final Interval interval, final ImgFactory< FloatType > factory ) { final Img< FloatType > output = factory.create( interval ); final long[] min = new long[ interval.numDimensions() ]; interval.min( min ); final RandomAccess< T > in = Views.offset( img, min ).randomAccess(); final Cursor< FloatType > out = output.cursor(); final RealFloatConverter< T > c = new RealFloatConverter< >(); while ( out.hasNext() ) { out.fwd(); in.setPosition( out ); c.convert( in.get(), out.get() ); } return output; }
/** * Copy an interval of the specified source image on a float image. * * @param img * the source image. * @param interval * the interval in the source image to copy. * @param factory * a factory used to build the float image. * @return a new float Img. Careful: even if the specified interval does not * start at (0, 0), the new image will have its first pixel at * coordinates (0, 0). */ public static final < T extends RealType< T >> Img< FloatType > copyToFloatImg( final RandomAccessible< T > img, final Interval interval, final ImgFactory< FloatType > factory ) { final Img< FloatType > output = factory.create( interval, new FloatType() ); final long[] min = new long[ interval.numDimensions() ]; interval.min( min ); final RandomAccess< T > in = Views.offset( img, min ).randomAccess(); final Cursor< FloatType > out = output.cursor(); final RealFloatConverter< T > c = new RealFloatConverter< >(); while ( out.hasNext() ) { out.fwd(); in.setPosition( out ); c.convert( in.get(), out.get() ); } return output; }
@Test public void defaultOffsetTest() { Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType()); MixedTransformView<DoubleType> il2 = Views.offset((RandomAccessible<DoubleType>) img, new long[] { 2, 2 }); MixedTransformView<DoubleType> opr = ops.transform().offsetView((RandomAccessible<DoubleType>) img, new long[] { 2, 2 }); for (int i = 0; i < il2.getTransformToSource().getMatrix().length; i++) { for (int j = 0; j < il2.getTransformToSource().getMatrix()[i].length; j++) { assertEquals(il2.getTransformToSource().getMatrix()[i][j], opr.getTransformToSource().getMatrix()[i][j], 1e-10); } } }