net.imglib2.view.Views.offset()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(10.5k)|赞(0)|评价(0)|浏览(101)

本文整理了Java中net.imglib2.view.Views.offset()方法的一些代码示例,展示了Views.offset()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Views.offset()方法的具体详情如下:
包路径:net.imglib2.view.Views
类名称:Views
方法名:offset

Views.offset介绍

暂无

代码示例

代码示例来源:origin: imagej/imagej-ops

  1. @Override
  2. public MixedTransformView<T> calculate(RandomAccessible<T> input) {
  3. return Views.offset(input, offset);
  4. }

代码示例来源:origin: net.imglib2/imglib2

  1. final static protected < T > RandomAccessibleInterval< T > zeroMinN( final RandomAccessibleInterval< T > source )
  2. {
  3. final long[] min = new long[ source.numDimensions() ];
  4. final int n = min.length - 1;
  5. min[ n ] = source.min( n );
  6. return Views.offset( source, min );
  7. }

代码示例来源:origin: imglib/imglib2

  1. final static protected < T > RandomAccessibleInterval< T > zeroMinN( final RandomAccessibleInterval< T > source )
  2. {
  3. final long[] min = new long[ source.numDimensions() ];
  4. final int n = min.length - 1;
  5. min[ n ] = source.min( n );
  6. return Views.offset( source, min );
  7. }

代码示例来源:origin: imglib/imglib2

  1. /**
  2. * Define an interval on a RandomAccessible and translate it such that the
  3. * min corner is at the origin. It is the callers responsibility to ensure
  4. * that the source RandomAccessible is defined in the specified interval.
  5. *
  6. * @param randomAccessible
  7. * the source
  8. * @param offset
  9. * offset of min corner.
  10. * @param dimension
  11. * size of the interval.
  12. * @return a RandomAccessibleInterval
  13. */
  14. public static < T > IntervalView< T > offsetInterval( final RandomAccessible< T > randomAccessible, final long[] offset, final long[] dimension )
  15. {
  16. final int n = randomAccessible.numDimensions();
  17. final long[] min = new long[ n ];
  18. final long[] max = new long[ n ];
  19. for ( int d = 0; d < n; ++d )
  20. max[ d ] = dimension[ d ] - 1;
  21. return Views.interval( Views.offset( randomAccessible, offset ), min, max );
  22. }

代码示例来源:origin: net.imglib2/imglib2

  1. /**
  2. * Define an interval on a RandomAccessible and translate it such that the
  3. * min corner is at the origin. It is the callers responsibility to ensure
  4. * that the source RandomAccessible is defined in the specified interval.
  5. *
  6. * @param randomAccessible
  7. * the source
  8. * @param offset
  9. * offset of min corner.
  10. * @param dimension
  11. * size of the interval.
  12. * @return a RandomAccessibleInterval
  13. */
  14. public static < T > IntervalView< T > offsetInterval( final RandomAccessible< T > randomAccessible, final long[] offset, final long[] dimension )
  15. {
  16. final int n = randomAccessible.numDimensions();
  17. final long[] min = new long[ n ];
  18. final long[] max = new long[ n ];
  19. for ( int d = 0; d < n; ++d )
  20. max[ d ] = dimension[ d ] - 1;
  21. return Views.interval( Views.offset( randomAccessible, offset ), min, max );
  22. }

代码示例来源:origin: imglib/imglib2

  1. /**
  2. * @deprecated Please use {@link Views#translate(RandomAccessibleInterval, long...)}
  3. * with a negative offset instead.
  4. * <p>
  5. * Translate such that pixel at offset in interval is at the origin in the
  6. * resulting view. This is equivalent to translating by -offset.
  7. *
  8. * @param interval
  9. * the source
  10. * @param offset
  11. * offset of the source view. The pixel at offset becomes the
  12. * origin of resulting view.
  13. */
  14. @Deprecated
  15. public static < T > IntervalView< T > offset( final RandomAccessibleInterval< T > interval, final long... offset )
  16. {
  17. final int n = interval.numDimensions();
  18. final long[] min = new long[ n ];
  19. final long[] max = new long[ n ];
  20. interval.min( min );
  21. interval.max( max );
  22. for ( int d = 0; d < n; ++d )
  23. {
  24. min[ d ] -= offset[ d ];
  25. max[ d ] -= offset[ d ];
  26. }
  27. return Views.interval( Views.offset( ( RandomAccessible< T > ) interval, offset ), min, max );
  28. }

代码示例来源:origin: net.imglib2/imglib2

  1. /**
  2. * Define an interval on a RandomAccessible and translate it such that the
  3. * min corner is at the origin. It is the callers responsibility to ensure
  4. * that the source RandomAccessible is defined in the specified interval.
  5. *
  6. * @param randomAccessible
  7. * the source
  8. * @param interval
  9. * the interval on source that should be cut out and translated
  10. * to the origin.
  11. * @return a RandomAccessibleInterval
  12. */
  13. public static < T > IntervalView< T > offsetInterval( final RandomAccessible< T > randomAccessible, final Interval interval )
  14. {
  15. final int n = randomAccessible.numDimensions();
  16. final long[] offset = new long[ n ];
  17. final long[] min = new long[ n ];
  18. final long[] max = new long[ n ];
  19. interval.min( offset );
  20. interval.max( max );
  21. for ( int d = 0; d < n; ++d )
  22. max[ d ] -= offset[ d ];
  23. return Views.interval( Views.offset( randomAccessible, offset ), min, max );
  24. }

代码示例来源:origin: net.imglib2/imglib2

  1. /**
  2. * Translate such that pixel at offset in interval is at the origin in the
  3. * resulting view. This is equivalent to translating by -offset.
  4. *
  5. * @param interval
  6. * the source
  7. * @param offset
  8. * offset of the source view. The pixel at offset becomes the
  9. * origin of resulting view.
  10. */
  11. public static < T > IntervalView< T > offset( final RandomAccessibleInterval< T > interval, final long... offset )
  12. {
  13. final int n = interval.numDimensions();
  14. final long[] min = new long[ n ];
  15. final long[] max = new long[ n ];
  16. interval.min( min );
  17. interval.max( max );
  18. for ( int d = 0; d < n; ++d )
  19. {
  20. min[ d ] -= offset[ d ];
  21. max[ d ] -= offset[ d ];
  22. }
  23. return Views.interval( Views.offset( ( RandomAccessible< T > ) interval, offset ), min, max );
  24. }

代码示例来源:origin: imglib/imglib2

  1. /**
  2. * Define an interval on a RandomAccessible and translate it such that the
  3. * min corner is at the origin. It is the callers responsibility to ensure
  4. * that the source RandomAccessible is defined in the specified interval.
  5. *
  6. * @param randomAccessible
  7. * the source
  8. * @param interval
  9. * the interval on source that should be cut out and translated
  10. * to the origin.
  11. * @return a RandomAccessibleInterval
  12. */
  13. public static < T > IntervalView< T > offsetInterval( final RandomAccessible< T > randomAccessible, final Interval interval )
  14. {
  15. final int n = randomAccessible.numDimensions();
  16. final long[] offset = new long[ n ];
  17. final long[] min = new long[ n ];
  18. final long[] max = new long[ n ];
  19. interval.min( offset );
  20. interval.max( max );
  21. for ( int d = 0; d < n; ++d )
  22. max[ d ] -= offset[ d ];
  23. return Views.interval( Views.offset( randomAccessible, offset ), min, max );
  24. }

代码示例来源:origin: net.imglib2/imglib2-script

  1. /**
  2. * @param <T> The {@link Type} of the source image.
  3. * @param source The image to paste, which can be smaller than the {@param target} image.
  4. * @param target The function that expresses the target image.
  5. * @param offset The offset from origin for the pasting operation.
  6. * @throws Exception
  7. */
  8. public Paste(
  9. final RandomAccessibleInterval<T> source,
  10. final IFunction target,
  11. final long[] offset) throws Exception {
  12. this.background = AlgorithmUtil.type(source, 0);
  13. this.a = new ImageFunction<T>(new RandomAccessibleIntervalImgProxy<T>(
  14. Views.interval(
  15. Views.offset(Views.extendValue(source, background), offset),
  16. extractDimensions(target))));
  17. this.b = target;
  18. }

代码示例来源:origin: net.imglib2/imglib2-algorithm

  1. final IntervalView< T > offsetTarget = Views.offset( target, offset );
  2. final ExtendedRandomAccessibleInterval< T, Img< T >> extended = Views.extendValue( source, minVal );

代码示例来源:origin: net.imglib2/imglib2-script

  1. public <R extends RealType<R>> Paste(
  2. final RandomAccessibleInterval<T> source,
  3. final IterableRealInterval<R> target,
  4. final long[] offset) throws Exception {
  5. this.background = AlgorithmUtil.type(source, 0);
  6. this.a = new ImageFunction<T>(new RandomAccessibleIntervalImgProxy<T>(
  7. Views.interval(
  8. Views.offset(Views.extendValue(source, background), offset),
  9. new FinalInterval(Util.intervalDimensions(target)))));
  10. this.b = new ImageFunction<R>(target);
  11. }

代码示例来源:origin: net.imglib2/imglib2-algorithm

  1. @Override
  2. public void run()
  3. {
  4. final IntervalView< T > intervalView = Views.offset( largeSource, offset );
  5. final Cursor< T > cursor = create.cursor();
  6. cursor.jumpFwd( chunk.getStartPosition() );
  7. final RandomAccess< T > randomAccess = intervalView.randomAccess();
  8. for ( long step = 0; step < chunk.getLoopSize(); step++ )
  9. {
  10. cursor.fwd();
  11. randomAccess.setPosition( cursor );
  12. cursor.get().set( randomAccess.get() );
  13. }
  14. }
  15. };

代码示例来源:origin: sc.fiji/TrackMate_

  1. final RandomAccessibleInterval< FloatType > dog = Views.offset( Util.getArrayOrCellImgFactory( interval, type ).create( interval, type ), min );
  2. final RandomAccessibleInterval< FloatType > dog2 = Views.offset( Util.getArrayOrCellImgFactory( interval, type ).create( interval, type ), min );

代码示例来源:origin: sc.fiji/TrackMate_

  1. minopposite[ d ] = -minopposite[ d ];
  2. final IntervalView< FloatType > to = Views.offset( floatImg, minopposite );
  3. spots = DetectionUtils.findLocalMaxima( to, threshold, calibration, radius, doSubPixelLocalization, numThreads );

代码示例来源:origin: net.imglib2/imglib2-algorithm

  1. final IntervalView< T > offsetTarget = Views.offset( target, offset );
  2. final T minVal = MorphologyUtils.createVariable( source, source );
  3. minVal.setReal( minVal.getMinValue() );

代码示例来源:origin: net.imglib2/imglib2-algorithm

  1. final IntervalView< T > offsetTarget = Views.offset( target, offset );
  2. final T maxVal = MorphologyUtils.createVariable( source, source );
  3. maxVal.setReal( maxVal.getMaxValue() );

代码示例来源:origin: fiji/TrackMate

  1. /**
  2. * Copy an interval of the specified source image on a float image.
  3. *
  4. * @param img
  5. * the source image.
  6. * @param interval
  7. * the interval in the source image to copy.
  8. * @param factory
  9. * a factory used to build the float image.
  10. * @return a new float Img. Careful: even if the specified interval does not
  11. * start at (0, 0), the new image will have its first pixel at
  12. * coordinates (0, 0).
  13. */
  14. public static final < T extends RealType< T >> Img< FloatType > copyToFloatImg( final RandomAccessible< T > img, final Interval interval, final ImgFactory< FloatType > factory )
  15. {
  16. final Img< FloatType > output = factory.create( interval );
  17. final long[] min = new long[ interval.numDimensions() ];
  18. interval.min( min );
  19. final RandomAccess< T > in = Views.offset( img, min ).randomAccess();
  20. final Cursor< FloatType > out = output.cursor();
  21. final RealFloatConverter< T > c = new RealFloatConverter< >();
  22. while ( out.hasNext() )
  23. {
  24. out.fwd();
  25. in.setPosition( out );
  26. c.convert( in.get(), out.get() );
  27. }
  28. return output;
  29. }

代码示例来源:origin: sc.fiji/TrackMate_

  1. /**
  2. * Copy an interval of the specified source image on a float image.
  3. *
  4. * @param img
  5. * the source image.
  6. * @param interval
  7. * the interval in the source image to copy.
  8. * @param factory
  9. * a factory used to build the float image.
  10. * @return a new float Img. Careful: even if the specified interval does not
  11. * start at (0, 0), the new image will have its first pixel at
  12. * coordinates (0, 0).
  13. */
  14. public static final < T extends RealType< T >> Img< FloatType > copyToFloatImg( final RandomAccessible< T > img, final Interval interval, final ImgFactory< FloatType > factory )
  15. {
  16. final Img< FloatType > output = factory.create( interval, new FloatType() );
  17. final long[] min = new long[ interval.numDimensions() ];
  18. interval.min( min );
  19. final RandomAccess< T > in = Views.offset( img, min ).randomAccess();
  20. final Cursor< FloatType > out = output.cursor();
  21. final RealFloatConverter< T > c = new RealFloatConverter< >();
  22. while ( out.hasNext() )
  23. {
  24. out.fwd();
  25. in.setPosition( out );
  26. c.convert( in.get(), out.get() );
  27. }
  28. return output;
  29. }

代码示例来源:origin: imagej/imagej-ops

  1. @Test
  2. public void defaultOffsetTest() {
  3. Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
  4. MixedTransformView<DoubleType> il2 = Views.offset((RandomAccessible<DoubleType>) img, new long[] { 2, 2 });
  5. MixedTransformView<DoubleType> opr = ops.transform().offsetView((RandomAccessible<DoubleType>) img, new long[] { 2, 2 });
  6. for (int i = 0; i < il2.getTransformToSource().getMatrix().length; i++) {
  7. for (int j = 0; j < il2.getTransformToSource().getMatrix()[i].length; j++) {
  8. assertEquals(il2.getTransformToSource().getMatrix()[i][j], opr.getTransformToSource().getMatrix()[i][j],
  9. 1e-10);
  10. }
  11. }
  12. }

相关文章