@Override public void dimensions( final long[] dimensions ) { counts.dimensions( dimensions ); }
@Override public void dimensions(long[] dimensions) { img.dimensions(dimensions); }
public void setInputImage( final Img<T> image ) { this.input = image; if ( input != null ) image.dimensions( this.imgSize ); else this.imgSize = null; }
@Override public void dimensions( final long[] dimensions ) { counts.dimensions( dimensions ); }
@Override public void dimensions(final long[] dimensions) { img.dimensions(dimensions); }
@Override public void dimensions(final long[] dimensions) { img.dimensions(dimensions); }
@Override public void dimensions(final long[] dimensions) { img.dimensions(dimensions); }
/** * Check that all images have the same dimensions. */ private boolean dimensionsAreValid() { if ( image_map.size() == 1 ) { return true; } final Collection< Img< T > > images = image_map.values(); final Iterator< Img< T > > it = images.iterator(); Img< T > img = it.next(); long[] previous_dims = new long[ img.numDimensions() ]; img.dimensions( previous_dims ); long[] dims; while ( it.hasNext() ) { img = it.next(); dims = new long[ img.numDimensions() ]; img.dimensions( dims ); if ( previous_dims.length != dims.length ) { return false; } for ( int j = 0; j < dims.length; j++ ) { if ( dims[ j ] != previous_dims[ j ] ) { return false; } } previous_dims = dims; } return true; }
/** * Returns the bounding box so that all images can fit in there * or null if input is null or input.size is 0 * * @param images input images * @param <T> pixel type * @return largest size in every dimension or null */ public static < T extends Type< T > > long[] commonSize( final List< Img< T > > images ) { if ( images == null || images.size() == 0 ) return null; final long[] size = new long[ images.get( 0 ).numDimensions() ]; images.get( 0 ).dimensions( size ); for ( final Img< T > image : images ) for ( int d = 0; d < image.numDimensions(); ++d ) size[ d ] = Math.max( size[ d ], image.dimension( d ) ); return size; } }
private static long[] determineSharedExtents( Img< ? >... imgs ) { if ( imgs.length == 0 ) throw new IllegalArgumentException( "at least one image must be provided" ); int numDims = imgs[ 0 ].numDimensions(); long[] commonRegion = new long[ numDims ]; imgs[ 0 ].dimensions( commonRegion ); for ( int i = 1; i < imgs.length; i++ ) { if ( imgs[ i ].numDimensions() != numDims ) throw new IllegalArgumentException( "images do not have compatible dimensions" ); for ( int d = 0; d < numDims; d++ ) { commonRegion[d] = Math.min( imgs[i].dimension(d), commonRegion[d] ); } } return commonRegion; }
@SuppressWarnings("unchecked") public ArrayImg< FloatType, ? > getPSFCopyArrayImg() { final ArrayImg< FloatType, ? > arrayImg; if ( img == null ) { img = arrayImg = IOFunctions.openAs32BitArrayImg( new File( new File( xmlBasePath, subDir ), file ) ); } else if ( ArrayImg.class.isInstance( img ) ) { arrayImg = (ArrayImg< FloatType, ? >)img; } else { final long[] size = new long[ img.numDimensions() ]; img.dimensions( size ); arrayImg = new ArrayImgFactory< FloatType >().create( size, new FloatType() ); FusionTools.copyImg( img, arrayImg, null ); } return arrayImg; }
/** * Creates an output image by applying a UnaryOperation to an input image. * The size of the output image matches the size of the input image. * * @param op * The UnaryOperation used to generate the output image from the * input image. * @param input * The input Img. * @param imgFactory * The factory used to create the output image. * @param type * The type of the output image. * @return The computed pixel output image of specified type. */ public static < I extends RealType< I >, O extends RealType< O >> Img< O > applyOp( UnaryOperation< I, O > op, Img< I > input, ImgFactory< O > imgFactory, O type ) { long[] span = new long[ input.numDimensions() ]; input.dimensions( span ); Img< O > output = imgFactory.create( span, type ); unaryAssign( op, input, output, span ); return output; }
public DownSample( final Img<T> image, final long[] newSize, final float sourceSigma, final float targetSigma ) { this.input = image; this.newSize = newSize.clone(); setSourceSigma( sourceSigma ); setTargetSigma( targetSigma ); if ( input != null ) { this.imgSize = new long[ input.numDimensions() ]; image.dimensions( imgSize ); this.scaling = new float[ image.numDimensions() ]; for ( int d = 0; d < image.numDimensions(); ++d ) this.scaling[ d ] = (float)imgSize[ d ] / (float)newSize[ d ]; } else { this.imgSize = null; this.scaling = null; } setNumThreads(); this.processingTime = -1; }
/** Test basic properties of the op's output */ @Test public void testOutput() throws Exception { // SETUP final long[] inputDims = { 3, 3, 3 }; final Img<BitType> img = ArrayImgs.bits(inputDims); // EXECUTE final Img<BitType> result = (Img<BitType>) ops.morphology().outline(img, Boolean.TRUE); // VERIFY assertNotNull(result); final long[] outputDims = new long[result.numDimensions()]; result.dimensions(outputDims); assertArrayEquals(inputDims, outputDims); }
int[] getImgAsInts( final Img< IntType > img ) { final RandomAccess< IntType > a = img.randomAccess(); final int N = ( int ) img.size(); final int[] data = new int[ N ]; final long[] dim = new long[ img.numDimensions() ]; final long[] pos = new long[ img.numDimensions() ]; img.dimensions( dim ); for ( int i = 0; i < N; ++i ) { IntervalIndexer.indexToPosition( i, dim, pos ); a.setPosition( pos ); data[ i ] = a.get().get(); } return data; }
static int[] getImgAsInts( final Img< IntType > img ) { final RandomAccess< IntType > a = img.randomAccess(); final int N = ( int ) img.size(); final int[] data = new int[ N ]; final long[] dim = new long[ img.numDimensions() ]; final long[] pos = new long[ img.numDimensions() ]; img.dimensions( dim ); for ( int i = 0; i < N; ++i ) { IntervalIndexer.indexToPosition( i, dim, pos ); a.setPosition( pos ); data[ i ] = a.get().get(); } return data; }
int[] getImgAsInts( final Img< IntType > img ) { final RandomAccess< IntType > a = img.randomAccess(); final int N = ( int ) img.size(); final int[] data = new int[ N ]; final long[] dim = new long[ img.numDimensions() ]; final long[] pos = new long[ img.numDimensions() ]; img.dimensions( dim ); for ( int i = 0; i < N; ++i ) { IntervalIndexer.indexToPosition( i, dim, pos ); a.setPosition( pos ); data[ i ] = a.get().get(); } return data; }
int[] getImgAsInts( final Img< IntType > img ) { final RandomAccess< IntType > a = img.randomAccess(); final int N = ( int ) img.size(); final int[] data = new int[ N ]; final long[] dim = new long[ img.numDimensions() ]; final long[] pos = new long[ img.numDimensions() ]; img.dimensions( dim ); for ( int i = 0; i < N; ++i ) { IntervalIndexer.indexToPosition( i, dim, pos ); a.setPosition( pos ); data[ i ] = a.get().get(); } return data; }
img.dimensions( dimensions ); final float percentScaling = 0.2f; final double[] border = new double[ numDimensions ];
int[] getImgAsInts( final Img< IntType > img ) { final RandomAccess< IntType > a = img.randomAccess(); final int N = ( int ) img.size(); final int[] data = new int[ N ]; final long[] dim = new long[ img.numDimensions() ]; final long[] pos = new long[ img.numDimensions() ]; img.dimensions( dim ); for ( int i = 0; i < N; ++i ) { IntervalIndexer.indexToPosition( i, dim, pos ); a.setPosition( pos ); data[ i ] = a.get().get(); } return data; }