@Override public RandomAccess< LongType > randomAccess() { return counts.randomAccess(); }
@Override public RandomAccess< LongType > randomAccess( final Interval interval ) { return counts.randomAccess( interval ); }
/** * returns the nValue image's RandomAccess * * @return the RandomAccess containing the nValues */ protected RandomAccess<DoubleType> getNValuesRandomAccess() { return nValues.randomAccess(); }
@Override public RandomAccess< LongType > randomAccess( final Interval interval ) { return counts.randomAccess( interval ); }
@Override public RandomAccess<T> randomAccess(final Interval interval) { return img.randomAccess(interval); }
@Override public RandomAccess<T> randomAccess() { return img.randomAccess(); }
@Override public RandomAccess<T> randomAccess() { return img.randomAccess(); }
@Override public RandomAccess< LongType > randomAccess() { return counts.randomAccess(); }
@Override public RandomAccess<T> randomAccess(final Interval interval) { return img.randomAccess(interval); }
/** * returns the pValue image's RandomAccess * * @return the RandomAccess containing the pValues */ protected RandomAccess<DoubleType> getPValuesRandomAccess() { return pValues.randomAccess(); }
/** * returns the gradient image's RandomAccess * * @return the RandomAccess containing the gradients */ protected RandomAccess<DoubleType> getGradientsRandomAccess() { return gradients.randomAccess(); } }
/** * Construct an n-dimensional counter using a provided {@code Img<LongType>} to * store counts. */ public DiscreteFrequencyDistribution( final Img< LongType > img ) { counts = img; accessor = counts.randomAccess(); resetCounters(); }
@Override public RandomAccess< LabelingType< T > > randomAccess() { final RandomAccess< I > rndAccess = img.randomAccess(); return new LabelingConvertedRandomAccess< I, T >( rndAccess, generation, mapping ); }
/** * Construct an n-dimensional counter using a provided {@code Img<LongType>} to * store counts. */ public DiscreteFrequencyDistribution( final Img< LongType > img ) { counts = img; accessor = counts.randomAccess(); resetCounters(); }
/** * Convenience helper to access single pixels */ protected < T extends RealType< T >> float get( final Img< T > image, final int[] pos ) { final RandomAccess< T > cursor = image.randomAccess(); cursor.setPosition( pos ); final float result = cursor.get().getRealFloat(); return result; }
@Test public void testRandomAccess() { final RandomAccess< UnsignedByteType > a = img.randomAccess(); final long[] pos = new long[] { 28, 30, 5, 5, 12 }; final long[] dist = new long[] { 2, 3, 4, 2, 1 }; testlocalize( a, pos ); testfwd( a, pos ); testbck( a, pos ); testmove( a, pos, 3 ); testmove( a, pos, dist ); }
@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() ) ); }
public void copyWithSourceIteration( final Img< IntType > srcImg, final Img< IntType > dstImg ) { final int[] pos = new int[ dimensions.length ]; final Cursor< IntType > src = srcImg.localizingCursor(); final RandomAccess< IntType > dst = dstImg.randomAccess(); while ( src.hasNext() ) { src.fwd(); src.localize( pos ); dst.setPosition( pos ); dst.get().set( src.get() ); } }
@Test public void testCopy() { ops.run(ConvertIIs.class, out, in, new CopyRealTypes<ShortType, ByteType>()); final Cursor<ShortType> c = in.localizingCursor(); final RandomAccess<ByteType> ra = out.randomAccess(); while (c.hasNext()) { final short value = c.next().get(); ra.setPosition(c); assertEquals(copy(value), ra.get().get()); } }
@Test public void testNormalizeScale() { ops.run(ConvertIIs.class, out, in, ops.op(NormalizeScaleRealTypes.class, out.firstElement(), in.firstElement())); final Cursor<ShortType> c = in.localizingCursor(); final RandomAccess<ByteType> ra = out.randomAccess(); while (c.hasNext()) { final short value = c.next().get(); ra.setPosition(c); assertEquals(normalizeScale(value), ra.get().get()); } }