本文整理了Java中net.imglib2.img.Img.forEach()
方法的一些代码示例,展示了Img.forEach()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Img.forEach()
方法的具体详情如下:
包路径:net.imglib2.img.Img
类名称:Img
方法名:forEach
暂无
代码示例来源:origin: imglib/imglib2
private RandomAccessibleInterval< IntType > randomImage( final int randomSeed )
{
final Img< IntType > result = ArrayImgs.ints( 3, 2, 5 );
final Random random = new Random( randomSeed );
result.forEach( x -> x.set( random.nextInt() ) );
return Views.translate( result, random.nextInt(), random.nextInt(), random.nextInt() );
}
代码示例来源:origin: imglib/imglib2
@Test
public void testIntervalLoop()
{
// setup
final Img< IntType > img = ArrayImgs.ints( 1, 20, 5 );
final RandomAccess< IntType > ra = img.randomAccess();
// process
final Runnable loop = LoopUtils.createIntervalLoop( ra, img,
() -> ra.get().set( 42 ) );
loop.run();
// test
img.forEach( value -> assertEquals( 42, value.get() ) );
}
}
代码示例来源:origin: imagej/imagej-ops
/** Test the op with an interval that's full of foreground elements */
@Test
public void testAllForeground() throws Exception {
// SETUP
final Img<BitType> img = ArrayImgs.bits(3, 3, 3);
img.forEach(BitType::setOne);
// EXECUTE
final Img<BitType> result = (Img<BitType>) ops.morphology().outline(img,
Boolean.TRUE);
// VERIFY
assertEquals("Output should contain no foreground", 0, countForeground(
result));
}
代码示例来源:origin: imglib/imglib2
@Test
public void testLoopLine()
{
// setup
final Img< IntType > img = ArrayImgs.ints( 1, 1, 5 );
final RandomAccess< IntType > ra = img.randomAccess();
// process
final Runnable loop = LoopUtils.createLineLoop( ra, img.dimension( 2 ), 2,
() -> ra.get().set( 42 ) );
loop.run();
// test
img.forEach( value -> assertEquals( 42, value.get() ) );
}
代码示例来源:origin: imagej/imagej-ops
@Test
public void testIsNeighborhoodEmpty() throws Exception {
final Img<BitType> img = ArrayImgs.bits(2, 2, 2);
Octant<BitType> octant = new Octant<>(img);
octant.setNeighborhood(1, 1, 1);
assertTrue("Neighborhood should be empty", octant.isNeighborhoodEmpty());
img.forEach(BitType::setOne);
octant.setNeighborhood(1, 1, 1);
assertFalse("Neighborhood should not be empty", octant.isNeighborhoodEmpty());
}
代码示例来源:origin: imagej/imagej-ops
@Test
public void testAllForeground() {
// SETUP
final double scalingPow = DoubleStream.generate(() -> SCALING).limit(
DIMENSIONS).reduce((i, j) -> i * j).orElse(0);
final double[] expectedCounts = DoubleStream.iterate(1.0, i -> i *
scalingPow).map(Math::log).limit(ITERATIONS).toArray();
final Img<BitType> img = ArrayImgs.bits(TEST_DIMS);
img.forEach(BitType::setOne);
// EXECUTE
final List<ValuePair<DoubleType, DoubleType>> points = ops.topology()
.boxCount(img, MAX_SIZE, MIN_SIZE, SCALING);
// VERIFY
for (int i = 0; i < ITERATIONS; i++) {
assertEquals(EXPECTED_SIZES[i], points.get(i).a.get(), 1e-12);
assertEquals(expectedCounts[i], points.get(i).b.get(), 1e-12);
}
}
内容来源于网络,如有侵权,请联系作者删除!