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

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

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

Views.stack介绍

[英]Form a (n+1)-dimensional RandomAccessibleInterval by stacking n-dimensional RandomAccessibleIntervals.
[中]通过叠加n-维度随机访问区间,形成一个*(n+1)*-维度随机访问区间。

代码示例

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

@Override
public RandomAccessibleInterval<T> calculate(List<? extends RandomAccessibleInterval<T>> input) {
  return Views.stack(stackAccessMode, input);
}

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

@Override
public RandomAccessibleInterval<T> calculate(List<? extends RandomAccessibleInterval<T>> input) {
  return Views.stack(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: net.imglib2/imglib2

/**
 * Create an (<em>n</em>+1)-dimensional {@link RandomAccessible} of an
 * <em>n</em>-dimensional {@link RandomAccessible} that maps the four
 * channels encoded in {@link ARGBType} into a dimension.  The order
 * of the channels passed as arguments is preserved.  The source is being
 * modified as expected by writing into the converted channels.
 *
 * @param source
 * @param channels 0 = alpha, 1 = red, 2 = green, 3 = blue
 *
 * @return a converted {@link RandomAccessibleInterval} whose
 *         {@link Sampler Samplers} perform on-the-fly value conversion
 *         into and from the corresponding channels of the original
 *         {@link ARGBType}.
 */
final static public RandomAccessibleInterval< UnsignedByteType > argbChannels( final RandomAccessibleInterval< ARGBType > source, final int... channels )
{
  final ArrayList< RandomAccessibleInterval< UnsignedByteType > > hyperSlices = new ArrayList<>();
  for ( final int channel : channels )
    hyperSlices.add( argbChannel( source, channel ) );
  return Views.stack( hyperSlices );
}

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

/**
 * Create an (<em>n</em>+1)-dimensional {@link RandomAccessible} of an
 * <em>n</em>-dimensional {@link RandomAccessible} that maps the four
 * channels encoded in {@link ARGBType} into a dimension.  The order
 * of the channels passed as arguments is preserved.  The source is being
 * modified as expected by writing into the converted channels.
 *
 * @param source
 * @param channels 0 = alpha, 1 = red, 2 = green, 3 = blue
 *
 * @return a converted {@link RandomAccessibleInterval} whose
 *         {@link Sampler Samplers} perform on-the-fly value conversion
 *         into and from the corresponding channels of the original
 *         {@link ARGBType}.
 */
final static public RandomAccessibleInterval< UnsignedByteType > argbChannels( final RandomAccessibleInterval< ARGBType > source, final int... channels )
{
  final ArrayList< RandomAccessibleInterval< UnsignedByteType > > hyperSlices = new ArrayList<>();
  for ( final int channel : channels )
    hyperSlices.add( argbChannel( source, channel ) );
  return Views.stack( hyperSlices );
}

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

/**
 * Compose a list of same {@link Interval} and same {@link Type} 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, B extends Type< B > > RandomAccessibleInterval< B > compose(
    final List< RandomAccessibleInterval< A > > components,
    final Converter< Composite< A >, B > composer,
    final B targetType )
{
  return convert(
      Views.collapse( Views.stack( components ) ),
      composer,
      targetType );
}

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

/**
 * Compose a list of same {@link Interval} and same {@link NumericType} 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 NumericType< A >, B extends Type< B > > RandomAccessibleInterval< B > composeNumeric(
    final List< RandomAccessibleInterval< A > > components,
    final Converter< NumericComposite< A >, B > composer,
    final B targetType )
{
  return convert(
      Views.collapseNumeric( Views.stack( components ) ),
      composer,
      targetType );
}

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

/**
 * Compose a list of same {@link Interval} and same {@link Type} 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, B extends Type< B > > RandomAccessibleInterval< B > compose(
    final List< RandomAccessibleInterval< A > > components,
    final Converter< Composite< A >, B > composer,
    final B targetType )
{
  return convert(
      Views.collapse( Views.stack( components ) ),
      composer,
      targetType );
}

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

/**
 * Compose a list of same {@link Interval} and same {@link NumericType} 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 NumericType< A >, B extends Type< B > > RandomAccessibleInterval< B > composeNumeric(
    final List< RandomAccessibleInterval< A > > components,
    final Converter< NumericComposite< A >, B > composer,
    final B targetType )
{
  return convert(
      Views.collapseNumeric( 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: 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: 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: net.imglib2/imglib2

hyperSlices.add( Views.hyperSlice( source, concatenationAxis, index ) );
final RandomAccessibleInterval< T > stacked = Views.stack( mode, hyperSlices );
return Views.moveAxis( stacked, stacked.numDimensions() - 1, concatenationAxis );

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

/**
 * Create an (<em>n</em>+1)-dimensional {@link RandomAccessible} of an
 * <em>n</em>-dimensional {@link RandomAccessible} that maps the four
 * channels encoded in {@link ARGBType} into a dimension.  The source is
 * being modified as expected by writing into the converted channels.
 *
 * @param source
 *
 * @return a converted {@link RandomAccessibleInterval} whose
 *         {@link Sampler Samplers} perform on-the-fly value conversion
 *         into and from the corresponding channels of the original
 *         {@link ARGBType}.
 */
final static public RandomAccessibleInterval< UnsignedByteType > argbChannels( final RandomAccessibleInterval< ARGBType > source )
{
  return Views.stack(
      argbChannel( source, 0 ),
      argbChannel( source, 1 ),
      argbChannel( source, 2 ),
      argbChannel( source, 3 ) );
}

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

/**
 * Create an (<em>n</em>+1)-dimensional {@link RandomAccessible} of an
 * <em>n</em>-dimensional {@link RandomAccessible} that maps the four
 * channels encoded in {@link ARGBType} into a dimension.  The source is
 * being modified as expected by writing into the converted channels.
 *
 * @param source
 *
 * @return a converted {@link RandomAccessibleInterval} whose
 *         {@link Sampler Samplers} perform on-the-fly value conversion
 *         into and from the corresponding channels of the original
 *         {@link ARGBType}.
 */
final static public RandomAccessibleInterval< UnsignedByteType > argbChannels( final RandomAccessibleInterval< ARGBType > source )
{
  return Views.stack(
      argbChannel( source, 0 ),
      argbChannel( source, 1 ),
      argbChannel( source, 2 ),
      argbChannel( source, 3 ) );
}

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

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void compute(final RandomAccessibleInterval<I> input,
  final IterableInterval<BitType> output)
{
  final List<RandomAccessibleInterval<RealType>> listOfIntegralImages =
    new ArrayList<>();
  for (final int order : requiredIntegralImages()) {
    final RandomAccessibleInterval<RealType> requiredIntegralImg =
      getIntegralImage(input, order);
    listOfIntegralImages.add(requiredIntegralImg);
  }
  // Composite image of integral images of order 1 and 2
  final RandomAccessibleInterval<RealType> stacked = Views.stack(
    listOfIntegralImages);
  final RandomAccessibleInterval<? extends Composite<RealType>> compositeRAI =
    Views.collapse(stacked);
  final RandomAccessibleInterval<? extends Composite<RealType>> extendedCompositeRAI =
    removeLeadingZeros(compositeRAI);
  final NeighborhoodsIterableInterval<? extends Composite<RealType>> neighborhoods =
    shape.neighborhoodsSafe(extendedCompositeRAI);
  if (map == null) {
    map = (BinaryComputerOp) ops().op(Map.class, out(), in(), neighborhoods,
      filterOp);
  }
  map.compute(input, neighborhoods, output);
}

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

@Test
public void stackWithAccessModeTest() {
  Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
  List<Img<DoubleType>> list = new ArrayList<>();
  list.add(img);
  list.add(img);
  
  RandomAccessibleInterval<DoubleType> il2 = Views.stack(StackAccessMode.DEFAULT, list);
  RandomAccessibleInterval<DoubleType> opr = ops.transform().stackView(list, StackAccessMode.DEFAULT);
  assertEquals(il2.dimension(2), opr.dimension(2));
}

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

@Test
public void defaultStackTest() {
  Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
  List<Img<DoubleType>> list = new ArrayList<>();
  list.add(img);
  list.add(img);
  
  RandomAccessibleInterval<DoubleType> il2 = Views.stack(list);
  RandomAccessibleInterval<DoubleType> opr = ops.transform().stackView(list);
  assertEquals(il2.dimension(2), opr.dimension(2));
}

代码示例来源:origin: net.imagej/imagej-legacy

private ImgPlus<UnsignedByteType> splitColorChannels(ImgPlus<ARGBType> input) {
  Img<ARGBType> colored = input.getImg();
  RandomAccessibleInterval<UnsignedByteType> colorStack = Views.stack(
      Converters.argbChannel( colored, 1 ),
      Converters.argbChannel( colored, 2 ),
      Converters.argbChannel( colored, 3 ) );
  ImgPlus<UnsignedByteType> result = new ImgPlus<>(ImgView.wrap(colorStack, new PlanarImgFactory<>()), input.getName());
  int lastAxis = colored.numDimensions();
  for (int i = 0; i < lastAxis; i++) result.setAxis(input.axis(i).copy(), i);
  result.setAxis(new DefaultLinearAxis(Axes.CHANNEL), lastAxis);
  return ImgPlusViews.moveAxis(result, lastAxis, 2);
}

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

@Test
  public void testStacking()
  {
    // lets create a stack with every second plane of the input image,
    // works!
    final List< RandomAccessibleInterval< UnsignedByteType >> intervals = new ArrayList< RandomAccessibleInterval< UnsignedByteType > >();
    for ( int d = 0; d < img.dimension( 2 ); d++ )
    {
      if ( d % 2 == 0 )
        intervals.add( Views.dropSingletonDimensions( Views.interval( img, new FinalInterval( new long[] { img.min( 0 ), img.min( 1 ), d }, new long[] { img.max( 0 ), img.max( 1 ), d } ) ) ) );
    }

    // stack it!
    final RandomAccessibleInterval< UnsignedByteType > stack = Views.stack( intervals );

    assertTrue( stack.numDimensions() == 3 );
    assertTrue( intervals.size() == stack.dimension( 2 ) );

    final Cursor< UnsignedByteType > stackC = Views.iterable( stack ).cursor();
    while ( stackC.hasNext() )
    {
      assertTrue( stackC.next().get() % 2 == 0 );
    }
  }
}

相关文章