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

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

本文整理了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

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

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

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 );
}

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

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 );
}

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

/**
 * 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 );
}

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

/**
 * 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 );
}

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

/**
 * @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 );
}

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

/**
 * 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 );
}

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

/**
 * 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 );
}

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

/**
 * 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 );
}

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

/**
 * @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;
}

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

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

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

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);
}

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

@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() );
    }
  }
};

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

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

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

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

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

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

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

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

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

/**
 * 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;
}

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

/**
 * 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;
}

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

@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);
    }
  }
}

相关文章