本文整理了Java中net.imglib2.util.Intervals.translate()
方法的一些代码示例,展示了Intervals.translate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Intervals.translate()
方法的具体详情如下:
包路径:net.imglib2.util.Intervals
类名称:Intervals
方法名:translate
[英]Translate an interval in one dimension. Create a FinalInterval , which is the input interval shifted by t in dimension d.
[中]在一维中平移间隔。创建一个FinalInterval,它是在维度d中按t移位的输入间隔。
代码示例来源:origin: imglib/imglib2
/**
* Translate the source view by the given translation vector. Pixel
* <em>x</em> in the source view has coordinates <em>(x + translation)</em>
* in the resulting view.
*
* @param interval
* the source
* @param translation
* translation vector of the source view. The pixel at <em>x</em>
* in the source view becomes <em>(x + translation)</em> in the
* resulting view.
*/
public static < T > IntervalView< T > translate( final RandomAccessibleInterval< T > interval, final long... translation )
{
return Views.interval(
Views.translate( ( RandomAccessible< T > ) interval, translation ),
Intervals.translate( interval, translation ) );
}
代码示例来源:origin: net.imglib2/imglib2
/**
* Translate the source view by the given translation vector. Pixel
* <em>x</em> in the source view has coordinates <em>(x + translation)</em>
* in the resulting view.
*
* @param interval
* the source
* @param translation
* translation vector of the source view. The pixel at <em>x</em>
* in the source view becomes <em>(x + translation)</em> in the
* resulting view.
*/
public static < T > IntervalView< T > translate( final RandomAccessibleInterval< T > interval, final long... translation )
{
return Views.interval(
Views.translate( ( RandomAccessible< T > ) interval, translation ),
Intervals.translate( interval, translation ) );
}
代码示例来源:origin: net.imglib2/imglib2-algorithm
/**
* Compute the partial derivative (central difference approximation) of source
* in a particular dimension:
* {@code d_f( x ) = ( f( x + e ) - f( x - e ) ) / 2},
* where {@code e} is the unit vector along that dimension.
*
* @param source
* source image, has to provide valid data in the interval of the
* gradient image plus a one pixel border in dimension.
* @param result
* output image
* @param dimension
* along which dimension the partial derivatives are computed
*/
public static < T extends NumericType< T > > void gradientCentralDifference( final RandomAccessible< T > source,
final RandomAccessibleInterval< T > result, final int dimension )
{
final RandomAccessibleInterval< T > back = Views.interval( source, Intervals.translate( result, -1, dimension ) );
final RandomAccessibleInterval< T > front = Views.interval( source, Intervals.translate( result, 1, dimension ) );
LoopBuilder.setImages( result, back, front ).forEachPixel( ( r, b, f ) -> {
r.set( f );
r.sub( b );
r.mul( 0.5 );
} );
}
代码示例来源:origin: net.imglib2/imglib2-algorithm
/**
* Compute the backward difference of source in a particular dimension:
* {@code d_f( x ) = ( f( x ) - f( x - e ) )}
* where {@code e} is the unit vector along that dimension
*
* @param source source image, has to provide valid data in the interval of
* the gradient image plus a one pixel border in dimension.
* @param result output image
* @param dimension along which dimension the partial derivatives are computed
*/
public static < T extends NumericType< T > > void gradientBackwardDifference( final RandomAccessible< T > source,
final RandomAccessibleInterval< T > result, final int dimension )
{
final RandomAccessibleInterval< T > back = Views.interval( source, Intervals.translate( result, -1, dimension ) );
final RandomAccessibleInterval< T > front = Views.interval( source, result );
LoopBuilder.setImages( result, back, front ).forEachPixel( ( r, b, f ) -> {
r.set( f );
r.sub( b );
} );
}
代码示例来源:origin: net.imglib2/imglib2-algorithms
/**
* Compute the partial derivative of source in a particular dimension.
*
* @param source
* source image, has to provide valid data in the interval of the
* gradient image plus a one pixel border in dimension.
* @param gradient
* output image
* @param dimension
* along which dimension the partial derivatives are computed
*/
public static < T extends NumericType< T > > void gradientCentralDifference2( final RandomAccessible< T > source, final RandomAccessibleInterval< T > gradient, final int dimension )
{
final Cursor< T > front = Views.flatIterable( Views.interval( source, Intervals.translate( gradient, 1, dimension ) ) ).cursor();
final Cursor< T > back = Views.flatIterable( Views.interval( source, Intervals.translate( gradient, -1, dimension ) ) ).cursor();
for( final T t : Views.flatIterable( gradient ) )
{
t.set( front.next() );
t.sub( back.next() );
t.mul( 0.5 );
}
}
代码示例来源:origin: net.imglib2/imglib2-algorithm
/**
* Compute the forward difference of source in a particular dimension:
* {@code d_f( x ) = ( f( x + e ) - f( x ) )}
* where {@code e} is the unit vector along that dimension
* @param source source image, has to provide valid data in the interval of
* the gradient image plus a one pixel border in dimension.
* @param result output image
* @param dimension along which dimension the partial derivatives are computed
*/
public static < T extends NumericType< T > > void gradientForwardDifference( final RandomAccessible< T > source,
final RandomAccessibleInterval< T > result, final int dimension )
{
final RandomAccessibleInterval< T > back = Views.interval( source, result );
final RandomAccessibleInterval< T > front = Views.interval( source, Intervals.translate( result, 1, dimension ) );
LoopBuilder.setImages( result, back, front ).forEachPixel( ( r, b, f ) -> {
r.set( f );
r.sub( b );
} );
}
}
代码示例来源:origin: net.imglib2/imglib2-algorithm
/**
* Compute the partial derivative (central difference approximation) of source
* in a particular dimension:
* {@code d_f( x ) = ( f( x + e ) - f( x - e ) ) / 2},
* where {@code e} is the unit vector along that dimension.
*
* @param source
* source image, has to provide valid data in the interval of the
* gradient image plus a one pixel border in dimension.
* @param gradient
* output image
* @param dimension
* along which dimension the partial derivatives are computed
*/
public static < T extends NumericType< T > > void gradientCentralDifference2( final RandomAccessible< T > source, final RandomAccessibleInterval< T > gradient, final int dimension )
{
final Cursor< T > front = Views.flatIterable( Views.interval( source, Intervals.translate( gradient, 1, dimension ) ) ).cursor();
final Cursor< T > back = Views.flatIterable( Views.interval( source, Intervals.translate( gradient, -1, dimension ) ) ).cursor();
for ( final T t : Views.flatIterable( gradient ) )
{
t.set( front.next() );
t.sub( back.next() );
t.mul( 0.5 );
}
}
代码示例来源:origin: imglib/imglib2
@Benchmark
public void gradient_niceAndFast()
{
final RandomAccessibleInterval< DoubleType > backSource = Views.interval( in, Intervals.translate( out, -1, 0 ) );
final RandomAccessibleInterval< DoubleType > frontSource = Views.interval( in, Intervals.translate( out, 1, 0 ) );
LoopBuilder.setImages( out, backSource, frontSource ).forEachPixel(
( result, back, front ) -> {
result.set( front );
result.sub( back );
result.mul( 0.5 );
} );
}
代码示例来源:origin: imglib/imglib2
@Benchmark
public void gradient_niceAndSlow()
{
final Cursor< DoubleType > front = Views.flatIterable( Views.interval( in, Intervals.translate( out, 1, 0 ) ) ).cursor();
final Cursor< DoubleType > back = Views.flatIterable( Views.interval( in, Intervals.translate( out, -1, 0 ) ) ).cursor();
for ( final DoubleType t : Views.flatIterable( out ) )
{
t.set( front.next() );
t.sub( back.next() );
t.mul( 0.5 );
}
}
代码示例来源:origin: net.imglib2/imglib2-algorithms
final RandomAccess< T > back = source.randomAccess( Intervals.translate( gradient, 1, dimension ) );
final RandomAccess< T > front = source.randomAccess( Intervals.translate( gradient, -1, dimension ) );
内容来源于网络,如有侵权,请联系作者删除!