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

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

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

Views.rotate介绍

[英]Create view that is rotated by 90 degrees. The rotation is specified by the fromAxis and toAxis arguments. If fromAxis=0 and toAxis=1, this means that the X-axis of the source view is mapped to the Y-Axis of the rotated view. That is, it corresponds to a 90 degree clock-wise rotation of the source view in the XY plane. fromAxis=1 and toAxis=0 corresponds to a counter-clock-wise rotation in the XY plane.
[中]创建旋转90度的视图。旋转由fromAxis和toAxis参数指定。如果fromAxis=0且toAxis=1,则表示源视图的X轴映射到旋转视图的Y轴。也就是说,它对应于XY平面中源视图的90度顺时针旋转。fromAxis=1和toAxis=0对应于XY平面中的逆时针旋转。

代码示例

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

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

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

  1. @Override
  2. public IntervalView<T> calculate(RandomAccessibleInterval<T> input) {
  3. return Views.rotate(input, fromAxis, toAxis);
  4. }

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

  1. static private final <R extends RealType<R>> IntervalView<R> process(final Img<R> img, final Mode mode) {
  2. IntervalView<R> iv;
  3. if (Mode.R90 == mode) {
  4. iv = Views.rotate(img, 0, 1);
  5. } else if (Mode.R270 == mode) {
  6. iv = Views.rotate(img, 1, 0);
  7. } else if (Mode.R180 == mode) {
  8. iv = Views.rotate(Views.rotate(img, 0, 1), 0, 1);
  9. } else {
  10. throw new IllegalArgumentException("Invalid Mode: " + mode);
  11. }
  12. return Views.zeroMin(iv);
  13. }
  14. }

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

  1. /**
  2. * Create view that is rotated by 90 degrees. The rotation is specified by
  3. * the fromAxis and toAxis arguments.
  4. *
  5. * If fromAxis=0 and toAxis=1, this means that the X-axis of the source view
  6. * is mapped to the Y-Axis of the rotated view. That is, it corresponds to a
  7. * 90 degree clock-wise rotation of the source view in the XY plane.
  8. *
  9. * fromAxis=1 and toAxis=0 corresponds to a counter-clock-wise rotation in
  10. * the XY plane.
  11. */
  12. public static < T > IntervalView< T > rotate( final RandomAccessibleInterval< T > interval, final int fromAxis, final int toAxis )
  13. {
  14. final int n = interval.numDimensions();
  15. final long[] min = new long[ n ];
  16. final long[] max = new long[ n ];
  17. interval.min( min );
  18. interval.max( max );
  19. if ( fromAxis != toAxis )
  20. {
  21. final long fromMinNew = -max[ toAxis ];
  22. final long fromMaxNew = -min[ toAxis ];
  23. min[ toAxis ] = min[ fromAxis ];
  24. max[ toAxis ] = max[ fromAxis ];
  25. min[ fromAxis ] = fromMinNew;
  26. max[ fromAxis ] = fromMaxNew;
  27. }
  28. return Views.interval( Views.rotate( ( RandomAccessible< T > ) interval, fromAxis, toAxis ), min, max );
  29. }

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

  1. /**
  2. * Create view that is rotated by 90 degrees. The rotation is specified by
  3. * the fromAxis and toAxis arguments.
  4. *
  5. * If fromAxis=0 and toAxis=1, this means that the X-axis of the source view
  6. * is mapped to the Y-Axis of the rotated view. That is, it corresponds to a
  7. * 90 degree clock-wise rotation of the source view in the XY plane.
  8. *
  9. * fromAxis=1 and toAxis=0 corresponds to a counter-clock-wise rotation in
  10. * the XY plane.
  11. */
  12. public static < T > IntervalView< T > rotate( final RandomAccessibleInterval< T > interval, final int fromAxis, final int toAxis )
  13. {
  14. final int n = interval.numDimensions();
  15. final long[] min = new long[ n ];
  16. final long[] max = new long[ n ];
  17. interval.min( min );
  18. interval.max( max );
  19. if ( fromAxis != toAxis )
  20. {
  21. final long fromMinNew = -max[ toAxis ];
  22. final long fromMaxNew = -min[ toAxis ];
  23. min[ toAxis ] = min[ fromAxis ];
  24. max[ toAxis ] = max[ fromAxis ];
  25. min[ fromAxis ] = fromMinNew;
  26. max[ fromAxis ] = fromMaxNew;
  27. }
  28. return Views.interval( Views.rotate( ( RandomAccessible< T > ) interval, fromAxis, toAxis ), min, max );
  29. }

代码示例来源:origin: net.preibisch/multiview-reconstruction

  1. final Img< FloatType > maxAvgPSF = PSFCombination.computeMaxAverageTransformedPSF( psfs.values(), new ArrayImgFactory< FloatType >() );
  2. DisplayImage.getImagePlusInstance( Views.rotate( avgPSF, 0, 2 ), false, "avgPSF", 0, 1 ).show();
  3. DisplayImage.getImagePlusInstance( maxAvgPSF, false, "maxAvgPSF", 0, 1 ).show();

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

  1. @Test
  2. public void testDefaultRotate() {
  3. final Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 20, 10 }, new DoubleType());
  4. final MixedTransformView<DoubleType> il2 = Views.rotate((RandomAccessible<DoubleType>) img, 1, 0);
  5. final MixedTransformView<DoubleType> opr = ops.transform().rotateView(deinterval(img), 1, 0);
  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. }

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

  1. @Test
  2. public void testIntervalRotate() {
  3. final Img<DoubleType> img = ArrayImgs.doubles(20,10);
  4. final IntervalView<DoubleType> il2 = Views.rotate((RandomAccessibleInterval<DoubleType>) img, 1, 0);
  5. final IntervalView<DoubleType> opr = (IntervalView<DoubleType>) ops.transform().rotateView((RandomAccessibleInterval<DoubleType>) img, 1, 0);
  6. for (int i = 0; i < ((MixedTransformView<DoubleType>) il2.getSource()).getTransformToSource()
  7. .getMatrix().length; i++) {
  8. for (int j = 0; j < ((MixedTransformView<DoubleType>) il2.getSource()).getTransformToSource()
  9. .getMatrix()[i].length; j++) {
  10. assertEquals(
  11. ((MixedTransformView<DoubleType>) il2.getSource()).getTransformToSource().getMatrix()[i][j],
  12. ((MixedTransformView<DoubleType>) opr.getSource()).getTransformToSource().getMatrix()[i][j],
  13. 1e-10);
  14. }
  15. }
  16. }

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

  1. @Test
  2. public void testIntervalRotateInterval() {
  3. final Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 20, 10 }, new DoubleType());
  4. final IntervalView<DoubleType> il2 = Views.rotate((RandomAccessibleInterval<DoubleType>) img, 1, 0);
  5. final IntervalView<DoubleType> opr = ops.transform().rotateView((RandomAccessibleInterval<DoubleType>) img, 1, 0);
  6. assertEquals(img.min(1), il2.min(0));
  7. assertEquals(img.max(1), il2.max(0));
  8. assertEquals(img.min(0), -il2.max(1));
  9. assertEquals(img.max(0), -il2.min(1));
  10. for (int i = 0; i < il2.numDimensions(); i++) {
  11. assertEquals(il2.max(i), opr.max(i));
  12. assertEquals(il2.min(i), opr.min(i));
  13. }
  14. }
  15. }

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

  1. rotatedKernelB = Views.rotate(rotatedKernelB, i, i + 1);
  2. rotatedKernelA = Views.rotate(rotatedKernelA, j, j + 1);

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

  1. @Test
  2. public void test()
  3. {
  4. final long[] sizes = { 3, 4 };
  5. final long n = LongStream.of( sizes ).reduce( 1, ( x, y ) -> x * y );
  6. final long[] data = new long[ ( int ) n ];
  7. for ( int i = 0; i < n; i++ )
  8. {
  9. data[ i ] = i;
  10. }
  11. final RandomAccessibleInterval< LongType > source = ArrayImgs.longs( data, sizes );
  12. final RandomAccess< LongType > sourceRA = source.randomAccess();
  13. final RandomAccessibleInterval< LongType > actual = Views.rotate( source, 0, 1 );
  14. final RandomAccess< LongType > actualRA = actual.randomAccess();
  15. // check each value matches with their rotated counterparts
  16. for ( int i = 0; i < sizes[ 0 ]; i++ )
  17. {
  18. for ( int j = 0; j < sizes[ 1 ]; j++ )
  19. {
  20. sourceRA.setPosition( new long[] { i, j } );
  21. actualRA.setPosition( new long[] { -j, i } );
  22. assertEquals( sourceRA.get().get(), actualRA.get().get() );
  23. }
  24. }
  25. // check to make sure the bounds are the same
  26. assertEquals( source.min( 0 ), actual.min( 1 ) );
  27. assertEquals( source.max( 0 ), actual.max( 1 ) );
  28. assertEquals( source.min( 1 ), -actual.max( 0 ) );
  29. assertEquals( source.max( 1 ), -actual.min( 0 ) );
  30. }

相关文章