本文整理了Java中net.imglib2.view.Views.pair()
方法的一些代码示例,展示了Views.pair()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Views.pair()
方法的具体详情如下:
包路径:net.imglib2.view.Views
类名称:Views
方法名:pair
[英]Compose two RandomAccessible sources into a RandomAccessible of Pair.
[中]将两个随机可访问源组合成一对随机可访问源。
代码示例来源:origin: net.imglib2/imglib2
/**
* Checks if both images have equal intervals and content.
* A predicate must be given to check if two pixels are equal.
*/
public static < T, U > boolean imagesEqual( final RandomAccessibleInterval< ? extends T > a, final RandomAccessibleInterval< ? extends U > b, final BiPredicate< T, U > pixelEquals )
{
if ( !Intervals.equals( a, b ) )
return false;
for ( final Pair< ? extends T, ? extends U > pair : Views.interval( Views.pair( a, b ), b ) )
if ( !pixelEquals.test( pair.getA(), pair.getB() ) )
return false;
return true;
}
代码示例来源:origin: imglib/imglib2
/**
* Checks if both images have equal intervals and content.
* A predicate must be given to check if two pixels are equal.
*/
public static < T, U > boolean imagesEqual( final RandomAccessibleInterval< ? extends T > a, final RandomAccessibleInterval< ? extends U > b, final BiPredicate< T, U > pixelEquals )
{
if ( !Intervals.equals( a, b ) )
return false;
for ( final Pair< ? extends T, ? extends U > pair : Views.interval( Views.pair( a, b ), b ) )
if ( !pixelEquals.test( pair.getA(), pair.getB() ) )
return false;
return true;
}
代码示例来源:origin: net.imglib2/imglib2
/**
* Throws an AssertionError, if the content or intervals of the two images differ.
* Comparision is done pixel wise. Two pixels are considered equal, if the give
* predicate returns true.
*/
public static < A, B >
void assertImageEquals( final RandomAccessibleInterval< ? extends A > a, final RandomAccessibleInterval< ? extends B > b, BiPredicate< A, B > equals )
{
assertIntervalEquals( a, b );
IntervalView< ? extends Pair< ? extends A, ? extends B > > pairs = Views.interval( Views.pair( a, b ), b );
Cursor< ? extends Pair< ? extends A, ? extends B > > cursor = pairs.cursor();
while ( cursor.hasNext() )
{
Pair< ? extends A, ? extends B > p = cursor.next();
if ( !equals.test( p.getA(), p.getB() ) )
fail( "Pixel values differ on coordinate " +
positionToString( cursor ) + ", expected: "
+ p.getA() + " actual: " + p.getB() );
}
}
代码示例来源:origin: imglib/imglib2
/**
* Throws an AssertionError, if the content or intervals of the two images differ.
* Comparision is done pixel wise. Two pixels are considered equal, if the give
* predicate returns true.
*/
public static < A, B >
void assertImageEquals( final RandomAccessibleInterval< ? extends A > a, final RandomAccessibleInterval< ? extends B > b, BiPredicate< A, B > equals )
{
assertIntervalEquals( a, b );
IntervalView< ? extends Pair< ? extends A, ? extends B > > pairs = Views.interval( Views.pair( a, b ), b );
Cursor< ? extends Pair< ? extends A, ? extends B > > cursor = pairs.cursor();
while ( cursor.hasNext() )
{
Pair< ? extends A, ? extends B > p = cursor.next();
if ( !equals.test( p.getA(), p.getB() ) )
fail( "Pixel values differ on coordinate " +
positionToString( cursor ) + ", expected: "
+ p.getA() + " actual: " + p.getB() );
}
}
代码示例来源:origin: imglib/imglib2
@Benchmark
public void copy_pairedView()
{
Views.interval( Views.pair( in, out ), out ).forEach( p -> p.getA().set( p.getB() ) );
}
代码示例来源:origin: imglib/imglib2
private static void assertImageEquals(
RandomAccessibleInterval< ByteType > expected,
RandomAccessibleInterval< ByteType > actual )
{
for ( final Pair< ByteType, ByteType > p : Views.interval( Views.pair( expected, actual ), expected ) )
Assert.assertEquals( p.getA().getInteger(), p.getB().getInteger() );
}
}
代码示例来源:origin: net.imglib2/imglib2-algorithm
final RandomAccessible< Pair< T, U > > paired = Views.pair( source, target );
代码示例来源:origin: imagej/imagej-ops
private static < T extends ValueEquals< T > > void testEqual( final RandomAccessibleInterval< T > rai1, final RandomAccessibleInterval< T > rai2 )
{
Assert.assertArrayEquals( Intervals.minAsLongArray( rai1 ), Intervals.minAsLongArray( rai2 ) );
Assert.assertArrayEquals( Intervals.maxAsLongArray( rai1 ), Intervals.maxAsLongArray( rai2 ) );
for ( final Pair< T, T > p : Views.interval( Views.pair( rai1, rai2 ), rai1 ) )
Assert.assertTrue( p.getA().valueEquals( p.getB() ) );
}
代码示例来源:origin: net.imglib2/imglib2-algorithm
final RandomAccessible< Pair< T, U > > paired = Views.pair( source, target );
代码示例来源:origin: imglib/imglib2
for ( final Cursor< Pair< DoubleType, DoubleType > > c = Views.interval( Views.pair( data, converted ), data ).cursor(); c.hasNext(); )
内容来源于网络,如有侵权,请联系作者删除!