本文整理了Java中net.imglib2.view.Views.rotate()
方法的一些代码示例,展示了Views.rotate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Views.rotate()
方法的具体详情如下:
包路径:net.imglib2.view.Views
类名称: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
@Override
public MixedTransformView<T> calculate(RandomAccessible<T> input) {
return Views.rotate(input, fromAxis, toAxis);
}
代码示例来源:origin: imagej/imagej-ops
@Override
public IntervalView<T> calculate(RandomAccessibleInterval<T> input) {
return Views.rotate(input, fromAxis, toAxis);
}
代码示例来源:origin: net.imglib2/imglib2-script
static private final <R extends RealType<R>> IntervalView<R> process(final Img<R> img, final Mode mode) {
IntervalView<R> iv;
if (Mode.R90 == mode) {
iv = Views.rotate(img, 0, 1);
} else if (Mode.R270 == mode) {
iv = Views.rotate(img, 1, 0);
} else if (Mode.R180 == mode) {
iv = Views.rotate(Views.rotate(img, 0, 1), 0, 1);
} else {
throw new IllegalArgumentException("Invalid Mode: " + mode);
}
return Views.zeroMin(iv);
}
}
代码示例来源:origin: net.imglib2/imglib2
/**
* 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.
*/
public static < T > IntervalView< T > rotate( final RandomAccessibleInterval< T > interval, final int fromAxis, final int toAxis )
{
final int n = interval.numDimensions();
final long[] min = new long[ n ];
final long[] max = new long[ n ];
interval.min( min );
interval.max( max );
if ( fromAxis != toAxis )
{
final long fromMinNew = -max[ toAxis ];
final long fromMaxNew = -min[ toAxis ];
min[ toAxis ] = min[ fromAxis ];
max[ toAxis ] = max[ fromAxis ];
min[ fromAxis ] = fromMinNew;
max[ fromAxis ] = fromMaxNew;
}
return Views.interval( Views.rotate( ( RandomAccessible< T > ) interval, fromAxis, toAxis ), min, max );
}
代码示例来源:origin: imglib/imglib2
/**
* 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.
*/
public static < T > IntervalView< T > rotate( final RandomAccessibleInterval< T > interval, final int fromAxis, final int toAxis )
{
final int n = interval.numDimensions();
final long[] min = new long[ n ];
final long[] max = new long[ n ];
interval.min( min );
interval.max( max );
if ( fromAxis != toAxis )
{
final long fromMinNew = -max[ toAxis ];
final long fromMaxNew = -min[ toAxis ];
min[ toAxis ] = min[ fromAxis ];
max[ toAxis ] = max[ fromAxis ];
min[ fromAxis ] = fromMinNew;
max[ fromAxis ] = fromMaxNew;
}
return Views.interval( Views.rotate( ( RandomAccessible< T > ) interval, fromAxis, toAxis ), min, max );
}
代码示例来源:origin: net.preibisch/multiview-reconstruction
final Img< FloatType > maxAvgPSF = PSFCombination.computeMaxAverageTransformedPSF( psfs.values(), new ArrayImgFactory< FloatType >() );
DisplayImage.getImagePlusInstance( Views.rotate( avgPSF, 0, 2 ), false, "avgPSF", 0, 1 ).show();
DisplayImage.getImagePlusInstance( maxAvgPSF, false, "maxAvgPSF", 0, 1 ).show();
代码示例来源:origin: imagej/imagej-ops
@Test
public void testDefaultRotate() {
final Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 20, 10 }, new DoubleType());
final MixedTransformView<DoubleType> il2 = Views.rotate((RandomAccessible<DoubleType>) img, 1, 0);
final MixedTransformView<DoubleType> opr = ops.transform().rotateView(deinterval(img), 1, 0);
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);
}
}
}
代码示例来源:origin: imagej/imagej-ops
@Test
public void testIntervalRotate() {
final Img<DoubleType> img = ArrayImgs.doubles(20,10);
final IntervalView<DoubleType> il2 = Views.rotate((RandomAccessibleInterval<DoubleType>) img, 1, 0);
final IntervalView<DoubleType> opr = (IntervalView<DoubleType>) ops.transform().rotateView((RandomAccessibleInterval<DoubleType>) img, 1, 0);
for (int i = 0; i < ((MixedTransformView<DoubleType>) il2.getSource()).getTransformToSource()
.getMatrix().length; i++) {
for (int j = 0; j < ((MixedTransformView<DoubleType>) il2.getSource()).getTransformToSource()
.getMatrix()[i].length; j++) {
assertEquals(
((MixedTransformView<DoubleType>) il2.getSource()).getTransformToSource().getMatrix()[i][j],
((MixedTransformView<DoubleType>) opr.getSource()).getTransformToSource().getMatrix()[i][j],
1e-10);
}
}
}
代码示例来源:origin: imagej/imagej-ops
@Test
public void testIntervalRotateInterval() {
final Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 20, 10 }, new DoubleType());
final IntervalView<DoubleType> il2 = Views.rotate((RandomAccessibleInterval<DoubleType>) img, 1, 0);
final IntervalView<DoubleType> opr = ops.transform().rotateView((RandomAccessibleInterval<DoubleType>) img, 1, 0);
assertEquals(img.min(1), il2.min(0));
assertEquals(img.max(1), il2.max(0));
assertEquals(img.min(0), -il2.max(1));
assertEquals(img.max(0), -il2.min(1));
for (int i = 0; i < il2.numDimensions(); i++) {
assertEquals(il2.max(i), opr.max(i));
assertEquals(il2.min(i), opr.min(i));
}
}
}
代码示例来源:origin: imagej/imagej-ops
rotatedKernelB = Views.rotate(rotatedKernelB, i, i + 1);
rotatedKernelA = Views.rotate(rotatedKernelA, j, j + 1);
代码示例来源:origin: imglib/imglib2
@Test
public void test()
{
final long[] sizes = { 3, 4 };
final long n = LongStream.of( sizes ).reduce( 1, ( x, y ) -> x * y );
final long[] data = new long[ ( int ) n ];
for ( int i = 0; i < n; i++ )
{
data[ i ] = i;
}
final RandomAccessibleInterval< LongType > source = ArrayImgs.longs( data, sizes );
final RandomAccess< LongType > sourceRA = source.randomAccess();
final RandomAccessibleInterval< LongType > actual = Views.rotate( source, 0, 1 );
final RandomAccess< LongType > actualRA = actual.randomAccess();
// check each value matches with their rotated counterparts
for ( int i = 0; i < sizes[ 0 ]; i++ )
{
for ( int j = 0; j < sizes[ 1 ]; j++ )
{
sourceRA.setPosition( new long[] { i, j } );
actualRA.setPosition( new long[] { -j, i } );
assertEquals( sourceRA.get().get(), actualRA.get().get() );
}
}
// check to make sure the bounds are the same
assertEquals( source.min( 0 ), actual.min( 1 ) );
assertEquals( source.max( 0 ), actual.max( 1 ) );
assertEquals( source.min( 1 ), -actual.max( 0 ) );
assertEquals( source.max( 1 ), -actual.min( 0 ) );
}
内容来源于网络,如有侵权,请联系作者删除!