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

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

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

Views.collapseReal介绍

[英]Collapse the nth dimension of an n -dimensional RandomAccessible<T extends RealType<T>> into an (n-1)-dimensional RandomAccessible< RealComposite<T>>
[中]将n维RandomAccessible<T扩展RealType<T>>的nth维折叠为(n-1)维RandomAccessible<RealComposite<T>>

代码示例

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

@Override
public CompositeView<T, RealComposite<T>> calculate(RandomAccessible<T> input) {
  return Views.collapseReal(input, numChannels);
}

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

@Override
public CompositeIntervalView<T, RealComposite<T>> calculate(RandomAccessibleInterval<T> input) {
  return Views.collapseReal(input);
}

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

@Override
  public CompositeIntervalView<T, RealComposite<T>> calculate(RandomAccessibleInterval<T> input) {
    List<RandomAccessibleInterval<T>> derivatives = new ArrayList<>();
    for (int i = 0; i < derivativeFunctions.length; i++) {
      RandomAccessibleInterval<T> derivative = derivativeFunctions[i].calculate(input);
      derivatives.add(derivative);
    }

    RandomAccessibleInterval<T> stacked = Views.stack(derivatives);
    return Views.collapseReal(stacked);
  }
}

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

/**
 * Compose a list of same {@link Interval} and same {@link RealType} A
 * {@link RandomAccessibleInterval RandomAccessibleIntervals} into a
 * {@link RandomAccessibleInterval} of some target {@link Type} B using a
 * {@link Converter} from {@link Composite} of A to B.
 *
 * @param components
 * @param composer
 * @param targetType
 * @return
 */
final static public < A extends RealType< A >, B extends Type< B > > RandomAccessibleInterval< B > composeReal(
    final List< RandomAccessibleInterval< A > > components,
    final Converter< RealComposite< A >, B > composer,
    final B targetType )
{
  return convert(
      Views.collapseReal( Views.stack( components ) ),
      composer,
      targetType );
}

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

/**
 * Compose a list of same {@link Interval} and same {@link RealType} A
 * {@link RandomAccessibleInterval RandomAccessibleIntervals} into a
 * {@link RandomAccessibleInterval} of some target {@link Type} B using a
 * {@link Converter} from {@link Composite} of A to B.
 *
 * @param components
 * @param composer
 * @param targetType
 * @return
 */
final static public < A extends RealType< A >, B extends Type< B > > RandomAccessibleInterval< B > composeReal(
    final List< RandomAccessibleInterval< A > > components,
    final Converter< RealComposite< A >, B > composer,
    final B targetType )
{
  return convert(
      Views.collapseReal( Views.stack( components ) ),
      composer,
      targetType );
}

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

@Override
public CompositeIntervalView<T, RealComposite<T>> calculate(RandomAccessibleInterval<T> input) {
  List<RandomAccessibleInterval<T>> derivatives = new ArrayList<>();
  for (int i = 0; i < derivativeComputers.length; i++) {
    RandomAccessibleInterval<T> derivative = createRAI.calculate(input);
    derivativeComputers[i].compute(input, derivative);
    for (int j = 0; j < derivativeComputers.length; j++) {
      RandomAccessibleInterval<T> out = createRAI.calculate(input);
      derivativeComputers[j].compute(derivative, out);
      derivatives.add(out);
    }
  }
  RandomAccessibleInterval<T> stackedDerivatives = Views.stack(derivatives);
  return Views.collapseReal(stackedDerivatives);
}

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

public LinearIntensityMap( final RandomAccessibleInterval< T > source, final InterpolatorFactory< RealComposite< T >, RandomAccessible< RealComposite< T > > > interpolatorFactory )
{
  this.interpolatorFactory = interpolatorFactory;
  final CompositeIntervalView< T, RealComposite< T > > collapsedSource = Views.collapseReal( source );
  dimensions = new FinalInterval( collapsedSource );
  final double[] shift = new double[ dimensions.numDimensions() ];
  for ( int d = 0; d < shift.length; ++d )
    shift[ d ] = 0.5;
  translation = new Translation( shift );
  final RandomAccessible< RealComposite< T > > extendedCollapsedSource = Views.extendBorder( collapsedSource );
  coefficients = Views.interpolate( extendedCollapsedSource, interpolatorFactory );
}

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

private static < T extends RealType< T >, U extends RealType< U > > void transformAlongDimension(
    final RandomAccessible< T > source,
    final RandomAccessibleInterval< U > target,
    final Distance d,
    final int dim )
{
  final int lastDim = target.numDimensions() - 1;
  final long size = target.dimension( dim );
  final RealComposite< DoubleType > tmp = Views.collapseReal( createAppropriateOneDimensionalImage( size, new DoubleType() ) ).randomAccess().get();
  // do not permute if we already work on last dimension
  final Cursor< RealComposite< T > > s = Views.flatIterable( Views.collapseReal( dim == lastDim ? Views.interval( source, target ) : Views.permute( Views.interval( source, target ), dim, lastDim ) ) ).cursor();
  final Cursor< RealComposite< U > > t = Views.flatIterable( Views.collapseReal( dim == lastDim ? target : Views.permute( target, dim, lastDim ) ) ).cursor();
  final RealComposite< LongType > lowerBoundDistanceIndex = Views.collapseReal( createAppropriateOneDimensionalImage( size, new LongType() ) ).randomAccess().get();
  final RealComposite< DoubleType > envelopeIntersectLocation = Views.collapseReal( createAppropriateOneDimensionalImage( size + 1, new DoubleType() ) ).randomAccess().get();
  while ( s.hasNext() )
  {
    final RealComposite< T > sourceComp = s.next();
    final RealComposite< U > targetComp = t.next();
    for ( long i = 0; i < size; ++i )
    {
      tmp.get( i ).set( sourceComp.get( i ).getRealDouble() );
    }
    transformSingleColumn( tmp, targetComp, lowerBoundDistanceIndex, envelopeIntersectLocation, d, dim, size );
  }
}

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

private static < T extends RealType< T >, U extends ComplexType< U > > RandomAccessibleInterval< U > calculateEigenValuesImpl(
    final RandomAccessibleInterval< T > tensor,
    final RandomAccessibleInterval< U > eigenvalues,
    final EigenValues< T, U > ev )
{
  final Cursor< RealComposite< T > > m = Views.iterable( Views.collapseReal( tensor ) ).cursor();
  final Cursor< NumericComposite< U > > e = Views.iterable( Views.collapseNumeric( eigenvalues ) ).cursor();
  while ( m.hasNext() )
    ev.compute( m.next(), e.next() );
  return eigenvalues;
}

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

private static < T extends RealType< T >, U extends RealType< U > > void transformL1AlongDimension(
    final RandomAccessible< T > source,
    final RandomAccessibleInterval< U > target,
    final int dim,
    final double weight )
{
  final int lastDim = target.numDimensions() - 1;
  final long size = target.dimension( dim );
  final RealComposite< DoubleType > tmp = Views.collapseReal( createAppropriateOneDimensionalImage( size, new DoubleType() ) ).randomAccess().get();
  // do not permute if we already work on last dimension
  final Cursor< RealComposite< T > > s = Views.flatIterable( Views.collapseReal( dim == lastDim ? Views.interval( source, target ) : Views.permute( Views.interval( source, target ), dim, lastDim ) ) ).cursor();
  final Cursor< RealComposite< U > > t = Views.flatIterable( Views.collapseReal( dim == lastDim ? target : Views.permute( target, dim, lastDim ) ) ).cursor();
  while ( s.hasNext() )
  {
    final RealComposite< T > sourceComp = s.next();
    final RealComposite< U > targetComp = t.next();
    for ( long i = 0; i < size; ++i )
    {
      tmp.get( i ).set( sourceComp.get( i ).getRealDouble() );
    }
    transformL1SingleColumn( tmp, targetComp, weight, size );
  }
}

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

@Test
public void defaultCollapseRealTest() {
  Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 },
      new DoubleType());
  CompositeIntervalView<DoubleType, RealComposite<DoubleType>> il2 = Views
      .collapseReal((RandomAccessibleInterval<DoubleType>) img);
  CompositeIntervalView<DoubleType, RealComposite<DoubleType>> opr = ops.transform()
      .collapseRealView((RandomAccessibleInterval<DoubleType>) img);
  assertEquals(il2.numDimensions(), opr.numDimensions());
  CompositeView<DoubleType, RealComposite<DoubleType>> il2_2 = Views
      .collapseReal((RandomAccessible<DoubleType>) img, 1);
  CompositeView<DoubleType, RealComposite<DoubleType>> opr_2 = ops.transform()
      .collapseRealView((RandomAccessible<DoubleType>) img, 1);
  assertEquals(il2_2.numDimensions(), opr_2.numDimensions());
}

相关文章