本文整理了Java中net.imglib2.view.Views.permute()
方法的一些代码示例,展示了Views.permute()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Views.permute()
方法的具体详情如下:
包路径:net.imglib2.view.Views
类名称:Views
方法名:permute
[英]Create view with permuted axes. fromAxis and toAxis are swapped. If fromAxis=0 and toAxis=2, this means that the X-axis of the source view is mapped to the Z-Axis of the permuted view and vice versa. For a XYZ source, a ZYX view would be created.
[中]创建具有排列轴的视图。fromAxis和toAxis是交换的。如果fromAxis=0且toAxis=2,则表示源视图的X轴映射到置换视图的Z轴,反之亦然。对于XYZ源,将创建ZYX视图。
代码示例来源:origin: imagej/imagej-ops
@Override
public IntervalView<T> calculate(final RandomAccessibleInterval<T> input) {
return Views.permute(input, fromAxis, toAxis);
}
代码示例来源:origin: imagej/imagej-ops
@Override
public MixedTransformView<T> calculate(RandomAccessible<T> input) {
return Views.permute(input, fromAxis, toAxis);
}
代码示例来源:origin: net.imglib2/imglib2
/**
* Create view with permuted axes. fromAxis is moved to toAxis. While the
* order of the other axes is preserved.
*
* If fromAxis=2 and toAxis=4, and axis order of image is XYCZT, then
* a view to the image with axis order XYZTC would be created.
*/
public static < T > RandomAccessible< T > moveAxis( final RandomAccessible< T > image, final int fromAxis, final int toAxis )
{
if ( fromAxis == toAxis )
return image;
final int direction = toAxis > fromAxis ? 1 : -1;
RandomAccessible< T > res = image;
for ( int i = fromAxis; i != toAxis; i += direction )
res = Views.permute( res, i, i + direction );
return res;
}
代码示例来源:origin: net.imglib2/imglib2
/**
* Create view with permuted axes. fromAxis is moved to toAxis. While the
* order of the other axes is preserved.
*
* If fromAxis=2 and toAxis=4, and axis order of image is XYCZT, then
* a view to the image with axis order XYZTC would be created.
*/
public static < T > RandomAccessibleInterval< T > moveAxis( final RandomAccessibleInterval< T > image, final int fromAxis, final int toAxis )
{
if ( fromAxis == toAxis )
return image;
final int direction = toAxis > fromAxis ? 1 : -1;
RandomAccessibleInterval< T > res = image;
for ( int i = fromAxis; i != toAxis; i += direction )
res = Views.permute( res, i, i + direction );
return res;
}
代码示例来源:origin: imglib/imglib2
/**
* Create view with permuted axes. fromAxis is moved to toAxis. While the
* order of the other axes is preserved.
*
* If fromAxis=2 and toAxis=4, and axis order of image is XYCZT, then
* a view to the image with axis order XYZTC would be created.
*/
public static < T > RandomAccessible< T > moveAxis( final RandomAccessible< T > image, final int fromAxis, final int toAxis )
{
if ( fromAxis == toAxis )
return image;
final int direction = toAxis > fromAxis ? 1 : -1;
RandomAccessible< T > res = image;
for ( int i = fromAxis; i != toAxis; i += direction )
res = Views.permute( res, i, i + direction );
return res;
}
代码示例来源:origin: imglib/imglib2
/**
* Create view with permuted axes. fromAxis is moved to toAxis. While the
* order of the other axes is preserved.
*
* If fromAxis=2 and toAxis=4, and axis order of image is XYCZT, then
* a view to the image with axis order XYZTC would be created.
*/
public static < T > RandomAccessibleInterval< T > moveAxis( final RandomAccessibleInterval< T > image, final int fromAxis, final int toAxis )
{
if ( fromAxis == toAxis )
return image;
final int direction = toAxis > fromAxis ? 1 : -1;
RandomAccessibleInterval< T > res = image;
for ( int i = fromAxis; i != toAxis; i += direction )
res = Views.permute( res, i, i + direction );
return res;
}
代码示例来源:origin: sc.fiji/bigdataviewer-vistools
sourceStacks.set( i, Views.permute( sourceStacks.get( i ), 2, 3 ) );
代码示例来源:origin: net.imglib2/imglib2
/**
* Create view with permuted axes. fromAxis and toAxis are swapped.
*
* If fromAxis=0 and toAxis=2, this means that the X-axis of the source view
* is mapped to the Z-Axis of the permuted view and vice versa. For a XYZ
* source, a ZYX view would be created.
*/
public static < T > IntervalView< T > permute( 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 );
final long fromMinNew = min[ toAxis ];
final long fromMaxNew = max[ toAxis ];
min[ toAxis ] = min[ fromAxis ];
max[ toAxis ] = max[ fromAxis ];
min[ fromAxis ] = fromMinNew;
max[ fromAxis ] = fromMaxNew;
return Views.interval( Views.permute( ( RandomAccessible< T > ) interval, fromAxis, toAxis ), min, max );
}
代码示例来源:origin: imglib/imglib2
/**
* Create view with permuted axes. fromAxis and toAxis are swapped.
*
* If fromAxis=0 and toAxis=2, this means that the X-axis of the source view
* is mapped to the Z-Axis of the permuted view and vice versa. For a XYZ
* source, a ZYX view would be created.
*/
public static < T > IntervalView< T > permute( 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 );
final long fromMinNew = min[ toAxis ];
final long fromMaxNew = max[ toAxis ];
min[ toAxis ] = min[ fromAxis ];
max[ toAxis ] = max[ fromAxis ];
min[ fromAxis ] = fromMinNew;
max[ fromAxis ] = fromMaxNew;
return Views.interval( Views.permute( ( RandomAccessible< T > ) interval, fromAxis, toAxis ), min, max );
}
代码示例来源:origin: sc.fiji/bigdataviewer-vistools
interval = new FinalInterval( min, max );
for ( int i = 0; i < sourceStacks.size(); ++i )
sourceStacks.set( i, Views.permute( sourceStacks.get( i ), 2, 3 ) );
代码示例来源: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: 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: imagej/imagej-ops
@Test
public void defaultPermuteTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[]{10, 10}, new DoubleType());
MixedTransformView<DoubleType> il2 = Views.permute((RandomAccessible<DoubleType>)img, 1, 0);
MixedTransformView<DoubleType> opr = ops.transform().permuteView(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 testIntervalPermute() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[]{10, 10}, new DoubleType());
IntervalView<DoubleType> expected = Views.permute((RandomAccessibleInterval<DoubleType>)img, 1, 0);
IntervalView<DoubleType> actual = ops.transform().permuteView((RandomAccessibleInterval<DoubleType>)img, 1, 0);
for (int i = 0; i < ((MixedTransformView<DoubleType>) expected.getSource()).getTransformToSource().getMatrix().length; i++) {
for (int j = 0; j < ((MixedTransformView<DoubleType>) expected.getSource()).getTransformToSource().getMatrix()[i].length; j++) {
assertEquals(((MixedTransformView<DoubleType>) expected.getSource()).getTransformToSource().getMatrix()[i][j], ((MixedTransformView<DoubleType>) actual.getSource()).getTransformToSource().getMatrix()[i][j],
1e-10);
}
}
}
代码示例来源:origin: net.imglib2/imglib2-ops
resRndAccessible = Views.permute(resRndAccessible, srcIdx, d);
代码示例来源:origin: net.imagej/imagej-deprecated
resRndAccessible = Views.permute(resRndAccessible, srcIdx, d);
内容来源于网络,如有侵权,请联系作者删除!