/** * TODO Javadoc * * @param img * @param offset * @param size */ public AbstractArrayLocalizingCursor( final ArrayImg< T, ? > img, final int offset, final int size ) { super( img.numDimensions() ); this.img = img; this.offset = offset; this.size = size; this.type = img.createLinkedType(); this.lastIndex = offset + size - 1; max = new int[ n ]; for ( int d = 0; d < n; ++d ) max[ d ] = ( int ) img.max( d ); reset(); }
/** * TODO Javadoc * * @param img * @param offset * @param size */ public AbstractArrayLocalizingCursor( final ArrayImg< T, ? > img, final int offset, final int size ) { super( img.numDimensions() ); this.img = img; this.offset = offset; this.size = size; this.type = img.createLinkedType(); this.lastIndex = offset + size - 1; max = new int[ n ]; for ( int d = 0; d < n; ++d ) max[ d ] = ( int ) img.max( d ); reset(); }
@Test public void testStacking() { // lets create a stack with every second plane of the input image, // works! final List< RandomAccessibleInterval< UnsignedByteType >> intervals = new ArrayList< RandomAccessibleInterval< UnsignedByteType > >(); for ( int d = 0; d < img.dimension( 2 ); d++ ) { if ( d % 2 == 0 ) intervals.add( Views.dropSingletonDimensions( Views.interval( img, new FinalInterval( new long[] { img.min( 0 ), img.min( 1 ), d }, new long[] { img.max( 0 ), img.max( 1 ), d } ) ) ) ); } // stack it! final RandomAccessibleInterval< UnsignedByteType > stack = Views.stack( intervals ); assertTrue( stack.numDimensions() == 3 ); assertTrue( intervals.size() == stack.dimension( 2 ) ); final Cursor< UnsignedByteType > stackC = Views.iterable( stack ).cursor(); while ( stackC.hasNext() ) { assertTrue( stackC.next().get() % 2 == 0 ); } } }