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

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

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

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

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

  1. @Override
  2. public RandomAccessibleInterval<T> calculate(List<? extends RandomAccessibleInterval<T>> input) {
  3. return Views.stack(input);
  4. }

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

  1. @Override
  2. public CompositeIntervalView<T, RealComposite<T>> calculate(RandomAccessibleInterval<T> input) {
  3. List<RandomAccessibleInterval<T>> derivatives = new ArrayList<>();
  4. for (int i = 0; i < derivativeFunctions.length; i++) {
  5. RandomAccessibleInterval<T> derivative = derivativeFunctions[i].calculate(input);
  6. derivatives.add(derivative);
  7. }
  8. RandomAccessibleInterval<T> stacked = Views.stack(derivatives);
  9. return Views.collapseReal(stacked);
  10. }
  11. }

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

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

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

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

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

  1. /**
  2. * Compose a list of same {@link Interval} and same {@link Type} A
  3. * {@link RandomAccessibleInterval RandomAccessibleIntervals} into a
  4. * {@link RandomAccessibleInterval} of some target {@link Type} B using a
  5. * {@link Converter} from {@link Composite} of A to B.
  6. *
  7. * @param components
  8. * @param composer
  9. * @param targetType
  10. * @return
  11. */
  12. final static public < A, B extends Type< B > > RandomAccessibleInterval< B > compose(
  13. final List< RandomAccessibleInterval< A > > components,
  14. final Converter< Composite< A >, B > composer,
  15. final B targetType )
  16. {
  17. return convert(
  18. Views.collapse( Views.stack( components ) ),
  19. composer,
  20. targetType );
  21. }

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

  1. /**
  2. * Compose a list of same {@link Interval} and same {@link NumericType} A
  3. * {@link RandomAccessibleInterval RandomAccessibleIntervals} into a
  4. * {@link RandomAccessibleInterval} of some target {@link Type} B using a
  5. * {@link Converter} from {@link Composite} of A to B.
  6. *
  7. * @param components
  8. * @param composer
  9. * @param targetType
  10. * @return
  11. */
  12. final static public < A extends NumericType< A >, B extends Type< B > > RandomAccessibleInterval< B > composeNumeric(
  13. final List< RandomAccessibleInterval< A > > components,
  14. final Converter< NumericComposite< A >, B > composer,
  15. final B targetType )
  16. {
  17. return convert(
  18. Views.collapseNumeric( Views.stack( components ) ),
  19. composer,
  20. targetType );
  21. }

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

  1. /**
  2. * Compose a list of same {@link Interval} and same {@link Type} A
  3. * {@link RandomAccessibleInterval RandomAccessibleIntervals} into a
  4. * {@link RandomAccessibleInterval} of some target {@link Type} B using a
  5. * {@link Converter} from {@link Composite} of A to B.
  6. *
  7. * @param components
  8. * @param composer
  9. * @param targetType
  10. * @return
  11. */
  12. final static public < A, B extends Type< B > > RandomAccessibleInterval< B > compose(
  13. final List< RandomAccessibleInterval< A > > components,
  14. final Converter< Composite< A >, B > composer,
  15. final B targetType )
  16. {
  17. return convert(
  18. Views.collapse( Views.stack( components ) ),
  19. composer,
  20. targetType );
  21. }

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

  1. /**
  2. * Compose a list of same {@link Interval} and same {@link NumericType} A
  3. * {@link RandomAccessibleInterval RandomAccessibleIntervals} into a
  4. * {@link RandomAccessibleInterval} of some target {@link Type} B using a
  5. * {@link Converter} from {@link Composite} of A to B.
  6. *
  7. * @param components
  8. * @param composer
  9. * @param targetType
  10. * @return
  11. */
  12. final static public < A extends NumericType< A >, B extends Type< B > > RandomAccessibleInterval< B > composeNumeric(
  13. final List< RandomAccessibleInterval< A > > components,
  14. final Converter< NumericComposite< A >, B > composer,
  15. final B targetType )
  16. {
  17. return convert(
  18. Views.collapseNumeric( Views.stack( components ) ),
  19. composer,
  20. targetType );
  21. }

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

  1. /**
  2. * Compose a list of same {@link Interval} and same {@link RealType} A
  3. * {@link RandomAccessibleInterval RandomAccessibleIntervals} into a
  4. * {@link RandomAccessibleInterval} of some target {@link Type} B using a
  5. * {@link Converter} from {@link Composite} of A to B.
  6. *
  7. * @param components
  8. * @param composer
  9. * @param targetType
  10. * @return
  11. */
  12. final static public < A extends RealType< A >, B extends Type< B > > RandomAccessibleInterval< B > composeReal(
  13. final List< RandomAccessibleInterval< A > > components,
  14. final Converter< RealComposite< A >, B > composer,
  15. final B targetType )
  16. {
  17. return convert(
  18. Views.collapseReal( Views.stack( components ) ),
  19. composer,
  20. targetType );
  21. }

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

  1. /**
  2. * Compose a list of same {@link Interval} and same {@link RealType} A
  3. * {@link RandomAccessibleInterval RandomAccessibleIntervals} into a
  4. * {@link RandomAccessibleInterval} of some target {@link Type} B using a
  5. * {@link Converter} from {@link Composite} of A to B.
  6. *
  7. * @param components
  8. * @param composer
  9. * @param targetType
  10. * @return
  11. */
  12. final static public < A extends RealType< A >, B extends Type< B > > RandomAccessibleInterval< B > composeReal(
  13. final List< RandomAccessibleInterval< A > > components,
  14. final Converter< RealComposite< A >, B > composer,
  15. final B targetType )
  16. {
  17. return convert(
  18. Views.collapseReal( Views.stack( components ) ),
  19. composer,
  20. targetType );
  21. }

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

  1. @Override
  2. public CompositeIntervalView<T, RealComposite<T>> calculate(RandomAccessibleInterval<T> input) {
  3. List<RandomAccessibleInterval<T>> derivatives = new ArrayList<>();
  4. for (int i = 0; i < derivativeComputers.length; i++) {
  5. RandomAccessibleInterval<T> derivative = createRAI.calculate(input);
  6. derivativeComputers[i].compute(input, derivative);
  7. for (int j = 0; j < derivativeComputers.length; j++) {
  8. RandomAccessibleInterval<T> out = createRAI.calculate(input);
  9. derivativeComputers[j].compute(derivative, out);
  10. derivatives.add(out);
  11. }
  12. }
  13. RandomAccessibleInterval<T> stackedDerivatives = Views.stack(derivatives);
  14. return Views.collapseReal(stackedDerivatives);
  15. }

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

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

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

  1. /**
  2. * Create an (<em>n</em>+1)-dimensional {@link RandomAccessible} of an
  3. * <em>n</em>-dimensional {@link RandomAccessible} that maps the four
  4. * channels encoded in {@link ARGBType} into a dimension. The source is
  5. * being modified as expected by writing into the converted channels.
  6. *
  7. * @param source
  8. *
  9. * @return a converted {@link RandomAccessibleInterval} whose
  10. * {@link Sampler Samplers} perform on-the-fly value conversion
  11. * into and from the corresponding channels of the original
  12. * {@link ARGBType}.
  13. */
  14. final static public RandomAccessibleInterval< UnsignedByteType > argbChannels( final RandomAccessibleInterval< ARGBType > source )
  15. {
  16. return Views.stack(
  17. argbChannel( source, 0 ),
  18. argbChannel( source, 1 ),
  19. argbChannel( source, 2 ),
  20. argbChannel( source, 3 ) );
  21. }

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

  1. /**
  2. * Create an (<em>n</em>+1)-dimensional {@link RandomAccessible} of an
  3. * <em>n</em>-dimensional {@link RandomAccessible} that maps the four
  4. * channels encoded in {@link ARGBType} into a dimension. The source is
  5. * being modified as expected by writing into the converted channels.
  6. *
  7. * @param source
  8. *
  9. * @return a converted {@link RandomAccessibleInterval} whose
  10. * {@link Sampler Samplers} perform on-the-fly value conversion
  11. * into and from the corresponding channels of the original
  12. * {@link ARGBType}.
  13. */
  14. final static public RandomAccessibleInterval< UnsignedByteType > argbChannels( final RandomAccessibleInterval< ARGBType > source )
  15. {
  16. return Views.stack(
  17. argbChannel( source, 0 ),
  18. argbChannel( source, 1 ),
  19. argbChannel( source, 2 ),
  20. argbChannel( source, 3 ) );
  21. }

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

  1. @SuppressWarnings({ "unchecked", "rawtypes" })
  2. @Override
  3. public void compute(final RandomAccessibleInterval<I> input,
  4. final IterableInterval<BitType> output)
  5. {
  6. final List<RandomAccessibleInterval<RealType>> listOfIntegralImages =
  7. new ArrayList<>();
  8. for (final int order : requiredIntegralImages()) {
  9. final RandomAccessibleInterval<RealType> requiredIntegralImg =
  10. getIntegralImage(input, order);
  11. listOfIntegralImages.add(requiredIntegralImg);
  12. }
  13. // Composite image of integral images of order 1 and 2
  14. final RandomAccessibleInterval<RealType> stacked = Views.stack(
  15. listOfIntegralImages);
  16. final RandomAccessibleInterval<? extends Composite<RealType>> compositeRAI =
  17. Views.collapse(stacked);
  18. final RandomAccessibleInterval<? extends Composite<RealType>> extendedCompositeRAI =
  19. removeLeadingZeros(compositeRAI);
  20. final NeighborhoodsIterableInterval<? extends Composite<RealType>> neighborhoods =
  21. shape.neighborhoodsSafe(extendedCompositeRAI);
  22. if (map == null) {
  23. map = (BinaryComputerOp) ops().op(Map.class, out(), in(), neighborhoods,
  24. filterOp);
  25. }
  26. map.compute(input, neighborhoods, output);
  27. }

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

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

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

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

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

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

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

  1. @Test
  2. public void testStacking()
  3. {
  4. // lets create a stack with every second plane of the input image,
  5. // works!
  6. final List< RandomAccessibleInterval< UnsignedByteType >> intervals = new ArrayList< RandomAccessibleInterval< UnsignedByteType > >();
  7. for ( int d = 0; d < img.dimension( 2 ); d++ )
  8. {
  9. if ( d % 2 == 0 )
  10. 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 } ) ) ) );
  11. }
  12. // stack it!
  13. final RandomAccessibleInterval< UnsignedByteType > stack = Views.stack( intervals );
  14. assertTrue( stack.numDimensions() == 3 );
  15. assertTrue( intervals.size() == stack.dimension( 2 ) );
  16. final Cursor< UnsignedByteType > stackC = Views.iterable( stack ).cursor();
  17. while ( stackC.hasNext() )
  18. {
  19. assertTrue( stackC.next().get() % 2 == 0 );
  20. }
  21. }
  22. }

相关文章