@Override public long size() { return counts.size(); }
@Override public long size() { return counts.size(); }
@Override public long size() { return img.size(); }
@Override public long size() { return img.size(); }
public RegionMean(Img<T> img, RandomAccess<T> ra, long span) { super(img, ra, span); this.size = img.size(); }
@Override public long size() { return img.size(); }
@Override public long size() { return img.size(); }
static private final int computeBits(final Img<?> img) { // What bit depth is necessary to represent the count of pixels in img? double nBits = Math.log10(img.size()) / Math.log10(2); if (0 != nBits % 2) nBits += 1; return (int) nBits; }
/** * Set all pixels in target to 100% transparent zero, and mask to all * Integer.MAX_VALUE. */ public void clearMask() { Arrays.fill( maskArray, 0, ( int ) mask.size(), Byte.MAX_VALUE ); numInvalidLevels = sources.size(); }
protected long numPixels() { if ( accurate ) { long size = 1; for ( int d = 0; d < img.numDimensions(); ++d ) size *= img.dimension( d ) + Util.createGaussianKernel1DDouble( sigma[ d ], false ).length - 1; return size; } else { return img.size(); } } }
protected static ImgFactory< ComplexFloatType > getFFTFactory( final Img< ? extends RealType< ? > > img ) { try { return img.factory().imgFactory( new ComplexFloatType() ); } catch ( final IncompatibleTypeException e ) { if ( img.size() > Integer.MAX_VALUE / 2 ) return new CellImgFactory< ComplexFloatType >( 1024 ); return new ArrayImgFactory< ComplexFloatType >(); } }
protected static ImgFactory< ComplexFloatType > getFFTFactory( final Img< ? extends RealType< ? > > img ) { try { return img.factory().imgFactory( new ComplexFloatType() ); } catch (IncompatibleTypeException e) { if ( img.size() > Integer.MAX_VALUE / 2 ) return new CellImgFactory<ComplexFloatType>( 1024 ); return new ArrayImgFactory< ComplexFloatType >(); } } }
/** * Determine the smallest type that will correctly store the sums. * For {@link Img} whose type has integer precision, the largest type is {@link LongType}. * For {@link Img} whose type has floating-point precision, the largest type is {@link DoubleType}. * * @param img The input {@link Img}. * @return */ static public final <R extends RealType<R>, T extends NativeType<T> & NumericType<T>> T computeSmallestType(final Img<R> img) { final R type = img.firstElement(); final long maxSum = (long) (img.size() * (Math.pow(2, type.getBitsPerPixel()) -1)); T smallest = chooseSmallestType(type, maxSum); if (null != smallest) return smallest; // Else, slow way: sum all values and determine the smallest type final RealSum sum = new RealSum(); for (final R r : img) sum.add(r.getRealDouble()); smallest = chooseSmallestType(type, sum.getSum()); if (null != smallest) return smallest; throw new UnsupportedOperationException("Target image is too large!"); }
private static float[] createReference( final Img< FloatType > img ) { // use a random number generator final Random rnd = new Random( 1241234 ); // create reference array final float[] reference = new float[ ( int ) img.size() ]; // iterate over image and reference array and fill with data final Cursor< FloatType > cursor = img.cursor(); int i = 0; while ( cursor.hasNext() ) { cursor.fwd(); final float value = rnd.nextFloat(); reference[ i++ ] = value; cursor.get().set( value ); } return reference; }
protected static ImgFactory< ComplexFloatType > getFFTFactory( final Img< ? extends RealType< ? > > img ) { try { return img.factory().imgFactory( new ComplexFloatType() ); } catch ( final IncompatibleTypeException e ) { if ( img.size() > Integer.MAX_VALUE / 2 ) return new CellImgFactory<>( new ComplexFloatType(), 1024 ); return new ArrayImgFactory<>( new ComplexFloatType() ); } }
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; }
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; }