@Override public Cursor< LongType > cursor() { return counts.cursor(); }
@Override public Cursor< LongType > cursor() { return counts.cursor(); }
@Override public Cursor< LabelingType< T > > cursor() { final Cursor< I > c = img.cursor(); return new LabelingConvertedCursor< I, T >( c, generation, mapping ); }
final public static void multiplyComplex( final Img< ComplexFloatType > img, final Img< ComplexFloatType > kernel ) { final Cursor< ComplexFloatType > cursorA = img.cursor(); final Cursor< ComplexFloatType > cursorB = kernel.cursor(); while ( cursorA.hasNext() ) cursorA.next().mul( cursorB.next() ); }
private static < O extends RealType< O >> void fillImage( Img< O > img ) { Random rng = new Random(); Cursor< O > cursor = img.cursor(); while ( cursor.hasNext() ) { double value = 256 * rng.nextDouble(); cursor.next().setReal( value ); } } }
/** Execute the given {@link OutputAlgorithm} and prepare a cursor to deliver * its pixel values one by one in successive calls to {@code eval()}. */ public Process(final OutputAlgorithm<Img<? extends RealType<?>>> algorithm) throws Exception { execute(algorithm); this.img = algorithm.getResult(); this.c = this.img.cursor(); }
final public static void multiplyComplex( final Img< ComplexFloatType > img, final Img< ComplexFloatType > kernel ) { final Cursor< ComplexFloatType > cursorA = img.cursor(); final Cursor< ComplexFloatType > cursorB = kernel.cursor(); while ( cursorA.hasNext() ) cursorA.next().mul( cursorB.next() ); }
/** * Resets all frequency counts to zero. */ public void resetCounters() { final Cursor< LongType > cursor = counts.cursor(); while ( cursor.hasNext() ) { cursor.next().setZero(); } totalValues = 0; }
/** * Resets all frequency counts to zero. */ public void resetCounters() { final Cursor< LongType > cursor = counts.cursor(); while ( cursor.hasNext() ) { cursor.next().setZero(); } totalValues = 0; }
protected void multiplyInPlace( final Img<ComplexFloatType> fftImage1, final Img<ComplexFloatType> fftImage2 ) { final Cursor<ComplexFloatType> cursor1 = fftImage1.cursor(); final Cursor<ComplexFloatType> cursor2 = fftImage2.cursor(); while ( cursor1.hasNext() ) { cursor1.fwd(); cursor2.fwd(); cursor1.get().mul( cursor2.get() ); } }
public static FloatProcessor toProcessor( final Img< ? extends RealType< ? > > img ) { final FloatProcessor fp = new FloatProcessor( (int)img.dimension( 0 ), (int)img.dimension( 1 ) ); final float[] array = (float[])fp.getPixels(); final Cursor< ? extends RealType< ? > > c = img.cursor(); for ( int i = 0; i < array.length; ++ i) array[ i ] = c.next().getRealFloat(); return fp; }
@Override public Void call() throws Exception { final Cursor< UnsignedShortType > in = Views.iterable( ushortImg ).cursor(); final Cursor< FloatType > out = floatImg.cursor(); in.jumpFwd( startPosition ); out.jumpFwd( startPosition ); for ( long j = 0; j < loopSize; ++j ) out.next().set( in.next().getRealFloat() ); return null; } } );
@Test public void copyRAIWithOutputTest() { final Img<UnsignedByteType> output = input.factory().create(input, input .firstElement()); ops.run(CopyRAI.class, output, input); final Cursor<UnsignedByteType> inc = input.cursor(); final Cursor<UnsignedByteType> outc = output.cursor(); while (inc.hasNext()) { assertEquals(inc.next().get(), outc.next().get()); } }
@Test public void testJoin2Inplaces() { final Op op = ops.op(DefaultJoin2Inplaces.class, in, inplaceOp, inplaceOp); op.run(); // test final Cursor<ByteType> c = in.cursor(); while (c.hasNext()) { assertEquals(2, c.next().get()); } }
@Test public void testJoinComputerAndInplace() { final Op op = ops.op(DefaultJoinComputerAndInplace.class, out, in, computerOp, inplaceOp); op.run(); // test final Cursor<ByteType> c = out.cursor(); while (c.hasNext()) { assertEquals(2, c.next().get()); } }
@Test(expected = IllegalArgumentException.class) public void testTooManyDimensions() { final byte[] data = { 2, 2, 2, 2, 2, 2, 2, 2 }; final Img<ByteType> in = ArrayImgs.bytes(data, 2, 2); final Img<ByteType> out = generateByteArrayTestImg(false, 2, 2, 2); ops.run(DefaultBilateral.class, out, in, 15, 5, 2); final byte[] expected = { 2, 2, 2, 2, 2, 2, 2, 2 }; Cursor<ByteType> cout = out.cursor(); for (int i = 0; i < expected.length; i++) { assertEquals(cout.next().get(), expected[i]); } }
@Test(expected = IllegalArgumentException.class) public void testMismatchedDimensions() { final byte[] data = { 1, 1, 1, 1, 1, 1 }; final Img<ByteType> in = ArrayImgs.bytes(data, 2, 3); final Img<ByteType> out = generateByteArrayTestImg(false, 3, 2); ops.run(DefaultBilateral.class, out, in, 15, 5, 2); final byte[] expected = { 1, 1, 1, 1, 1, 1 }; Cursor<ByteType> cout = out.cursor(); for (int i = 0; i < expected.length; i++) { assertEquals(cout.next().get(), expected[i]); } }
@Test public void testFillHoles() { Img<BitType> result = ops.create().img(imgWithHoles); ops.morphology().fillHoles(result, imgWithHoles, new DiamondShape(1)); Cursor<BitType> resultC = result.cursor(); final BitType one = new BitType(true); while (resultC.hasNext()) { assertEquals(one, resultC.next()); } }