@Override public void setValue( final T value ) { this.value.set( value ); }
public RealRandomAccessibleSource( final RealRandomAccessible< T > accessible, final T type, final String name, final VoxelDimensions voxelDimensions ) { this.accessible = accessible; this.type = type.createVariable(); this.name = name; this.voxelDimensions = voxelDimensions; }
public ConvertedRealRandomAccessible( final RealRandomAccessible< A > source, final Converter< ? super A, ? super B > converter, final B b ) { super( source ); this.converter = converter; this.converted = b.copy(); }
private static < A extends Type< A > > ListImg< A > copyWithType( final ListImg< A > img ) { final ListImg< A > copy = new ListImg< A >( img.dimension, img.firstElement().createVariable() ); final ListCursor< A > source = img.cursor(); final ListCursor< A > target = copy.cursor(); while ( source.hasNext() ) target.next().set( source.next() ); return copy; }
@Override public void initialize(final IterableInterval<T> interval) { image = interval; min = image.firstElement().createVariable(); max = min.copy(); init(); }
@Override public boolean accept(Pair<T, T> t, Pair<T, T> u) { return !t.getB().valueEquals(u.getB()) && t.getA().valueEquals(u.getA()); } });
private static < A extends Type< A > > ListImg< A > copyWithType( final ListImg< A > img ) { final ListImg< A > copy = new ListImg< A >( img.dimension, img.firstElement().createVariable() ); final ListCursor< A > source = img.cursor(); final ListCursor< A > target = copy.cursor(); while ( source.hasNext() ) target.next().set( source.next() ); return copy; }
public ComputeMinMax( final IterableInterval< T > interval ) { setNumThreads(); this.image = interval; this.min = image.firstElement().createVariable(); this.max = this.min.copy(); }
private static < T extends Type< T > > void testValueExtended( final RandomAccessible<T> accessible, final Interval inside, final Interval total, final T insideValue, final T outsideValue ) { final Cursor< T > cursor = Views.interval( accessible, total ).cursor(); while ( cursor.hasNext() ) { final T value = cursor.next(); assertTrue( value.valueEquals( Intervals.contains( inside, cursor ) ? insideValue : outsideValue ) ); } } }
@Override public void setValue( final T value ) { this.value.set( value ); }
@Override public RandomAccessibleInterval< V > compute( RandomAccessibleInterval< T > input, RandomAccessibleInterval< V > output ) { setUpNeighbours( input.numDimensions() ); // OutOfBounds for marker V zeroV = output.randomAccess().get().createVariable(); zeroV.set( getVMinValue( zeroV ) ); OutOfBounds< V > marker = new OutOfBoundsConstantValueFactory< V, RandomAccessibleInterval< V >>( zeroV ).create( output ); Cursor< V > cur = new Cursor< V >( output ); // OutOfBounds for mask T zeroT = input.randomAccess().get().createVariable(); zeroT.set( getTMinValue( zeroT ) ); OutOfBounds< T > mask = new OutOfBoundsConstantValueFactory< T, RandomAccessibleInterval< T >>( zeroT ).create( input ); scanInRasterOrder( cur, marker, mask ); scanInAntiRasterOrder( cur, marker, mask ); propagate( marker, mask, m_neighbours ); return output; }
public ConvertedRealRandomAccessibleRealInterval( final RealRandomAccessibleRealInterval< A > source, final Converter< ? super A, ? super B > converter, final B b ) { super( source ); this.converter = converter; this.converted = b.copy(); }
@Override public T createVariable() { return type.createVariable(); }
@SuppressWarnings("unchecked") public BufferedRectangularNeighborhoodCursor( BufferedRectangularNeighborhood<T> neighborhood) { super(neighborhood); n = neighborhood.numDimensions(); currentPos = neighborhood.center.clone(); max = new long[n]; min = new long[n]; bufferElements = new long[n]; bck = new long[n]; Arrays.fill(bufferElements, 1); int tmp = 1; for (int d = 0; d < neighborhood.span.length; d++) { tmp *= (neighborhood.span[d] * 2) + 1; bck[d] = (-2 * neighborhood.span[d]); for (int dd = 0; dd < n; dd++) if (dd != d) bufferElements[d] *= (neighborhood.span[d] * 2) + 1; } T type = ra.get().createVariable(); maxCount = tmp; buffer = (T[]) Array.newInstance(type.getClass(), maxCount); for (int t = 0; t < buffer.length; t++) { buffer[t] = type.copy(); } }
@Override public void convert( final T input, final T output ) { output.set( input ); } }
@Override public MARKER compute( MASK input, MARKER output ) { setUpNeighbours( input.numDimensions() ); // OutOfBounds for marker V zeroV = output.randomAccess().get().createVariable(); zeroV.set( getVMinValue( zeroV ) ); OutOfBounds< V > marker = new OutOfBoundsConstantValueFactory< V, RandomAccessibleInterval< V >>( zeroV ).create( output ); Cursor< V > cur = new Cursor< V >( output ); // OutOfBounds for mask T zeroT = input.randomAccess().get().createVariable(); zeroT.set( getTMinValue( zeroT ) ); OutOfBounds< T > mask = new OutOfBoundsConstantValueFactory< T, RandomAccessibleInterval< T >>( zeroT ).create( input ); scanInRasterOrder( cur, marker, mask ); scanInAntiRasterOrder( cur, marker, mask ); propagate( marker, mask, m_neighbours ); return output; }
/** * @return an instance of the destination {@link Type}. */ public B getDestinationType() { return converted.copy(); }
@Override public T createVariable() { return type.createVariable(); }
@SuppressWarnings("unchecked") public BufferedRectangularNeighborhoodCursor( BufferedRectangularNeighborhood<T, ? extends RandomAccessibleInterval<T>> neighborhood) { super(neighborhood); n = neighborhood.numDimensions(); currentPos = neighborhood.center.clone(); max = new long[n]; min = new long[n]; bufferElements = new long[n]; bck = new long[n]; Arrays.fill(bufferElements, 1); int tmp = 1; for (int d = 0; d < neighborhood.span.length; d++) { tmp *= (neighborhood.span[d] * 2) + 1; bck[d] = (-2 * neighborhood.span[d]); for (int dd = 0; dd < n; dd++) if (dd != d) bufferElements[d] *= (neighborhood.span[d] * 2) + 1; } T type = ra.get().createVariable(); maxCount = tmp; buffer = (T[]) Array.newInstance(type.getClass(), maxCount); for (int t = 0; t < buffer.length; t++) { buffer[t] = type.copy(); } }
@Override public void convert( final T input, final T output ) { output.set( input ); } }