@Override public int numDimensions() { return cursor.numDimensions(); }
@Override public int numDimensions() { return c.numDimensions(); }
@Override public int numDimensions() { return source.numDimensions(); }
@Override public int numDimensions() { return source.numDimensions(); }
@Override public int numDimensions() { return cursor.numDimensions(); }
@Override public int numDimensions() { return cursor.numDimensions(); }
public SpotNeighborhoodCursor(SpotNeighborhood<T> sn) { this.cursor = sn.neighborhood.cursor(); this.calibration = sn.calibration; this.center = sn.center; this.pos = new long[cursor.numDimensions()]; reset(); }
public SpotNeighborhoodCursor(SpotNeighborhood<T> sn) { this.cursor = sn.neighborhood.cursor(); this.calibration = sn.calibration; this.center = sn.center; this.pos = new long[cursor.numDimensions()]; reset(); }
public TwinCursor(final RandomAccess<T> channel1, final RandomAccess<T> channel2, final Cursor<BitType> mask) { final Predicate<BitType> predicate = new MaskPredicate(); this.mask = new PredicateCursor<BitType>(mask, predicate); this.channel1 = channel1; this.channel2 = channel2; position = new long[mask.numDimensions()]; mask.localize(position); }
protected void testCursorJumpFwd( Cursor< IntType > cursor, Interval i ) { long[] position = new long[ cursor.numDimensions() ]; long[] ref = new long[ cursor.numDimensions() ]; i.min( ref ); ref[ 0 ] += 17; cursor.jumpFwd( 18 ); cursor.localize( position ); assertArrayEquals( "jumpFwd position incorrect.", ref, position ); }
@Override public DoubleType compute(IterableInterval<BitType> input, DoubleType output) { double diameter = 0.0f; Cursor<BitType> cursor = input.localizingCursor(); List<Point> points = new ArrayList<Point>((int) input.size()); int[] position = new int[cursor.numDimensions()]; while (cursor.hasNext()) { cursor.fwd(); if (cursor.get().get()) { cursor.localize(position); points.add(new Point(position)); } } for (Point p : points) { for (Point p2 : points) { double dist = 0.0f; for (int i = 0; i < p.numDimensions(); i++) { dist += (p.getIntPosition(i) - p2.getIntPosition(i)) * (p.getIntPosition(i) - p2.getIntPosition(i)); } diameter = Math.max(diameter, dist); } } // sqrt for euclidean diameter = Math.sqrt(diameter); output.set(diameter); return output; }
@Override public DoubleType compute(IterableInterval<BitType> input, DoubleType output) { double diameter = 0.0f; Cursor<BitType> cursor = input.localizingCursor(); List<Point> points = new ArrayList<Point>((int) input.size()); int[] position = new int[cursor.numDimensions()]; while (cursor.hasNext()) { cursor.fwd(); if (cursor.get().get()) { cursor.localize(position); points.add(new Point(position)); } } for (Point p : points) { for (Point p2 : points) { double dist = 0.0f; for (int i = 0; i < p.numDimensions(); i++) { dist += (p.getIntPosition(i) - p2.getIntPosition(i)) * (p.getIntPosition(i) - p2.getIntPosition(i)); } diameter = Math.max(diameter, dist); } } // sqrt for euclidean diameter = Math.sqrt(diameter); output.set(diameter); return output; }
/** * Create a Cursor that forwards all {@link Cursor} methods to * {@code source}, except {@link Localizable} methods. Localize calls are * propagated through {@code transformToSource}. */ SlicingCursor( final Cursor< T > source, final Slicing transformToSource ) { super( transformToSource.numSourceDimensions() ); // n == transformToSource.numSourceDimensions() // m == transformToSource.numTargetDimensions() assert source.numDimensions() == transformToSource.numTargetDimensions(); s = source; m = transformToSource.numTargetDimensions(); final boolean[] targetZero = new boolean[ m ]; final int[] targetComponent = new int[ m ]; transformToSource.getComponentZero( targetZero ); transformToSource.getComponentMapping( targetComponent ); sourceComponent = new int[ n ]; for ( int d = 0; d < m; ++d ) if ( !transformToSource.getComponentZero( d ) ) sourceComponent[ transformToSource.getComponentMapping( d ) ] = d; tmpPosition = new long[ m ]; transformToSource.getTranslation( tmpPosition ); }
/** * Create a Cursor that forwards all {@link Cursor} methods to * {@code source}, except {@link Localizable} methods. Localize calls are * propagated through {@code transformToSource}. */ SlicingCursor( final Cursor< T > source, final Slicing transformToSource ) { super( transformToSource.numSourceDimensions() ); // n == transformToSource.numSourceDimensions() // m == transformToSource.numTargetDimensions() assert source.numDimensions() == transformToSource.numTargetDimensions(); s = source; m = transformToSource.numTargetDimensions(); final boolean[] targetZero = new boolean[ m ]; final int[] targetComponent = new int[ m ]; transformToSource.getComponentZero( targetZero ); transformToSource.getComponentMapping( targetComponent ); sourceComponent = new int[ n ]; for ( int d = 0; d < m; ++d ) if ( !transformToSource.getComponentZero( d ) ) sourceComponent[ transformToSource.getComponentMapping( d ) ] = d; tmpPosition = new long[ m ]; transformToSource.getTranslation( tmpPosition ); }
final int dim = cursor.numDimensions(); final int[] pos = new int[ dim ]; while ( cursor.hasNext() )
/** * Check whether an image is identical to a generated image, with fuzz */ protected < T extends RealType< T >> boolean match( final Img< T > image, final Function function, final float tolerance ) { final Cursor< T > cursor = image.localizingCursor(); final long[] pos = new long[ cursor.numDimensions() ]; while ( cursor.hasNext() ) { cursor.fwd(); cursor.localize( pos ); if ( Math.abs( function.calculate( pos ) - cursor.get().getRealFloat() ) > tolerance ) return false; } return true; }
/** * Check whether an image is identical to a generated image */ protected < T extends RealType< T >> boolean match( final Img< T > image, final Function function ) { final Cursor< T > cursor = image.localizingCursor(); final long[] pos = new long[ cursor.numDimensions() ]; while ( cursor.hasNext() ) { cursor.fwd(); cursor.localize( pos ); if ( function.calculate( pos ) != cursor.get().getRealFloat() ) return false; } return true; }
/** * Generate an image */ protected < T extends RealType< T > & NativeType< T >> Img< T > makeImage( final T type, final Function function, final long[] dims ) { final ImgFactory< T > factory = new ArrayImgFactory<>( type ); final Img< T > result = factory.create( dims ); final Cursor< T > cursor = result.cursor(); final long[] pos = new long[ cursor.numDimensions() ]; while ( cursor.hasNext() ) { cursor.fwd(); cursor.localize( pos ); final float value = function.calculate( pos ); cursor.get().setReal( value ); } return result; }
protected void testCursorIteration( Cursor< IntType > cursor, Interval i ) { long[] position = new long[ cursor.numDimensions() ]; long[] min = new long[ cursor.numDimensions() ]; i.min( min ); cursor.fwd(); cursor.localize( position ); cursor.reset(); int ctr = 0; long sum = 0; final RandomAccess< BitType > check = Views.translate( new ArrayImgFactory<>( new BitType() ).create( i ), min ).randomAccess(); while ( cursor.hasNext() ) { cursor.fwd(); cursor.localize( position ); check.setPosition( position ); assertFalse( check.get().get() ); check.get().set( true ); sum += cursor.get().get(); ctr++; } assertEquals( "wrong number of elements accessed.", getIntervalSize( i ), ctr ); assertEquals( "sum of elements incorrect.", sum, getSum( i ) ); }
final double pos = c.getDoublePosition( c.numDimensions() - 1 ); Assert.assertEquals( pos * p.getA().get(), p.getB().get(), 0.0 );