public < T extends BooleanType<T> >BoolType( final T type ) { this( type.get() ); }
public < T extends BooleanType<T> >BoolType( final T type ) { this( type.get() ); }
@Override public void convert( final B input, final R output ) { output.set( input.get() ? zero : maxValForR ); }
public static < T extends BooleanType< T > > long countTrue( final RandomAccessibleInterval< T > interval ) { long sum = 0; for ( final T t : Views.iterable( interval ) ) if ( t.get() ) ++sum; return sum; } }
@Override public void compute(final I input, final O output) { if (!input.get()) output.set(defaultVal); }
@Override public void compute(final I input, final O output) { output.set(input.get() ? ifTrueVal : ifFalseVal); }
@Override public boolean test( final Localizable l ) { final RandomAccess< B > accessor = ra.randomAccess(); accessor.setPosition( l ); return accessor.get().get(); }
@Override public boolean test( final RealLocalizable l ) { final RealRandomAccess< B > accessor = rra.realRandomAccess(); accessor.setPosition( l ); return accessor.get().get(); }
@Override public void fwd() { if ( empty ) return; do { randomAccess.fwd( 0 ); if ( ++lineIndex > maxLineIndex ) nextLine(); } while ( !randomAccess.get().get() ); ++index; }
@Override public Void call() throws Exception { // scan1 raIn.setPosition(0, 0); raIn.setPosition(y, 1); if (!raIn.get().get()) { tempValues[0][y] = 0; } else { tempValues[0][y] = infinite; } for (int x = 1; x < width; x++) { raIn.setPosition(x, 0); if (!raIn.get().get()) { tempValues[x][y] = 0; } else { tempValues[x][y] = tempValues[x - 1][y] + calibration[0]; } } // scan2 for (int x = width - 2; x >= 0; x--) { if (tempValues[x + 1][y] < tempValues[x][y]) { tempValues[x][y] = calibration[0] + tempValues[x + 1][y]; } } return null; }
/** Checks if any element in the neighbourhood is background */ private boolean isAnyBackground(final IntervalView<B> neighbourhood) { final Cursor<B> cursor = neighbourhood.cursor(); while (cursor.hasNext()) { cursor.fwd(); if (!cursor.get().get()) { return true; } } return false; }
@Override public boolean test( final Localizable l ) { if ( Intervals.contains( this, l ) ) { final RandomAccess< B > accessor = sourceInterval.randomAccess(); accessor.setPosition( l ); return accessor.get().get(); } return false; } }
@Override public boolean test( final RealLocalizable l ) { if ( Intervals.contains( this, l ) ) { final RealRandomAccess< B > accessor = sourceInterval.realRandomAccess(); accessor.setPosition( l ); return accessor.get().get(); } return false; } }
private boolean getAtLocation(final RandomAccess<B> access, final long x, final long y, final long z) { access.setPosition(x, 0); access.setPosition(y, 1); access.setPosition(z, 2); return access.get().get(); } }
@Override public Void call() throws Exception { // scan1 raIn.setPosition(0, 0); raIn.setPosition(y, 1); raIn.setPosition(z, 2); if (!raIn.get().get()) { tempValues[0][y][z] = 0; } else { tempValues[0][y][z] = infinite; } for (int x = 1; x < width; x++) { raIn.setPosition(x, 0); if (!raIn.get().get()) { tempValues[x][y][z] = 0; } else { tempValues[x][y][z] = tempValues[x - 1][y][z] + 1; } } // scan2 for (int x = width - 2; x >= 0; x--) { if (tempValues[x + 1][y][z] < tempValues[x][y][z]) { tempValues[x][y][z] = 1 + tempValues[x + 1][y][z]; } } return null; }
/** * @see ImgUtil#copy(Img, double[], int, int[]) */ public static < T extends BooleanType< T >> void copy( final Img< T > src, final boolean[] dest, final int offset, final int[] stride ) { final Cursor< T > c = src.localizingCursor(); final int[] location = new int[ src.numDimensions() ]; while ( c.hasNext() ) { final T t = c.next(); c.localize( location ); int this_offset = offset; for ( int i = 0; ( i < stride.length ) && ( i < location.length ); i++ ) { this_offset += location[ i ] * stride[ i ]; } dest[ this_offset ] = t.get(); } }
/** * @see ImgUtil#copy(Img, double[], int, int[]) */ public static < T extends BooleanType< T >> void copy( final Img< T > src, final boolean[] dest, final int offset, final int[] stride ) { final Cursor< T > c = src.localizingCursor(); final int[] location = new int[ src.numDimensions() ]; while ( c.hasNext() ) { final T t = c.next(); c.localize( location ); int this_offset = offset; for ( int i = 0; ( i < stride.length ) && ( i < location.length ); i++ ) { this_offset += location[ i ] * stride[ i ]; } dest[ this_offset ] = t.get(); } }
/** * Checks if an element is part of the outline of an object * * @param source the location of the element * @param coordinates coordinates of the element * @return true if element is foreground and has at least one background * neighbour */ private boolean isOutline( final ExtendedRandomAccessibleInterval<B, RandomAccessibleInterval<B>> source, final long[] coordinates) { final OutOfBounds<B> access = source.randomAccess(); access.setPosition(coordinates); if (!access.get().get()) { return false; } final IntervalView<B> neighbourhood = neighbourhoodInterval(source, coordinates); return isAnyBackground(neighbourhood); } // endregion
protected < T extends BooleanType< T > > void calculate( final RandomAccessible< T > source, final IterableInterval< T > target ) { final RandomAccessible< Neighborhood< T > > accessible = shape.neighborhoodsRandomAccessible( source ); final RandomAccess< Neighborhood< T > > randomAccess = accessible.randomAccess( target ); final Cursor< T > cursorTarget = target.cursor(); final boolean[] table = getTable(); while ( cursorTarget.hasNext() ) { final T targetVal = cursorTarget.next(); randomAccess.setPosition( cursorTarget ); final Neighborhood< T > neighborhood = randomAccess.get(); final Cursor< T > nc = neighborhood.cursor(); int idx = 0; // Assume that the neighborhood obtained is of FlatIterationOrder, // and assemble the index using bitwise operations. while ( nc.hasNext() ) { idx <<= 1; idx |= nc.next().get() ? 1 : 0; } targetVal.set( table[ idx ] ); } }