net.imglib2.img.Img.size()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(261)

本文整理了Java中net.imglib2.img.Img.size()方法的一些代码示例,展示了Img.size()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Img.size()方法的具体详情如下:
包路径:net.imglib2.img.Img
类名称:Img
方法名:size

Img.size介绍

暂无

代码示例

代码示例来源:origin: net.imglib2/imglib2

  1. @Override
  2. public long size()
  3. {
  4. return counts.size();
  5. }

代码示例来源:origin: imglib/imglib2

  1. @Override
  2. public long size()
  3. {
  4. return counts.size();
  5. }

代码示例来源:origin: net.imglib2/imglib2-meta

  1. @Override
  2. public long size() {
  3. return img.size();
  4. }

代码示例来源:origin: net.imagej/imagej-common

  1. @Override
  2. public long size() {
  3. return img.size();
  4. }

代码示例来源:origin: net.imglib2/imglib2-script

  1. public RegionMean(Img<T> img, RandomAccess<T> ra, long span) {
  2. super(img, ra, span);
  3. this.size = img.size();
  4. }

代码示例来源:origin: net.imglib2/imglib2-script

  1. @Override
  2. public long size() {
  3. return img.size();
  4. }

代码示例来源:origin: net.imagej/imagej-deprecated

  1. @Override
  2. public long size() {
  3. return img.size();
  4. }

代码示例来源:origin: net.imglib2/imglib2-script

  1. static private final int computeBits(final Img<?> img) {
  2. // What bit depth is necessary to represent the count of pixels in img?
  3. double nBits = Math.log10(img.size()) / Math.log10(2);
  4. if (0 != nBits % 2) nBits += 1;
  5. return (int) nBits;
  6. }

代码示例来源:origin: sc.fiji/bigdataviewer-core

  1. /**
  2. * Set all pixels in target to 100% transparent zero, and mask to all
  3. * Integer.MAX_VALUE.
  4. */
  5. public void clearMask()
  6. {
  7. Arrays.fill( maskArray, 0, ( int ) mask.size(), Byte.MAX_VALUE );
  8. numInvalidLevels = sources.size();
  9. }

代码示例来源:origin: net.preibisch/multiview-reconstruction

  1. protected long numPixels()
  2. {
  3. if ( accurate )
  4. {
  5. long size = 1;
  6. for ( int d = 0; d < img.numDimensions(); ++d )
  7. size *= img.dimension( d ) + Util.createGaussianKernel1DDouble( sigma[ d ], false ).length - 1;
  8. return size;
  9. }
  10. else
  11. {
  12. return img.size();
  13. }
  14. }
  15. }

代码示例来源:origin: net.preibisch/multiview-reconstruction

  1. protected static ImgFactory< ComplexFloatType > getFFTFactory( final Img< ? extends RealType< ? > > img )
  2. {
  3. try
  4. {
  5. return img.factory().imgFactory( new ComplexFloatType() );
  6. }
  7. catch ( final IncompatibleTypeException e )
  8. {
  9. if ( img.size() > Integer.MAX_VALUE / 2 )
  10. return new CellImgFactory< ComplexFloatType >( 1024 );
  11. return new ArrayImgFactory< ComplexFloatType >();
  12. }
  13. }

代码示例来源:origin: net.imglib2/imglib2-algorithms-gpl

  1. protected static ImgFactory< ComplexFloatType > getFFTFactory( final Img< ? extends RealType< ? > > img )
  2. {
  3. try
  4. {
  5. return img.factory().imgFactory( new ComplexFloatType() );
  6. }
  7. catch (IncompatibleTypeException e)
  8. {
  9. if ( img.size() > Integer.MAX_VALUE / 2 )
  10. return new CellImgFactory<ComplexFloatType>( 1024 );
  11. return new ArrayImgFactory< ComplexFloatType >();
  12. }
  13. }
  14. }

代码示例来源:origin: net.imglib2/imglib2-script

  1. /**
  2. * Determine the smallest type that will correctly store the sums.
  3. * For {@link Img} whose type has integer precision, the largest type is {@link LongType}.
  4. * For {@link Img} whose type has floating-point precision, the largest type is {@link DoubleType}.
  5. *
  6. * @param img The input {@link Img}.
  7. * @return
  8. */
  9. static public final <R extends RealType<R>, T extends NativeType<T> & NumericType<T>> T computeSmallestType(final Img<R> img) {
  10. final R type = img.firstElement();
  11. final long maxSum = (long) (img.size() * (Math.pow(2, type.getBitsPerPixel()) -1));
  12. T smallest = chooseSmallestType(type, maxSum);
  13. if (null != smallest) return smallest;
  14. // Else, slow way: sum all values and determine the smallest type
  15. final RealSum sum = new RealSum();
  16. for (final R r : img) sum.add(r.getRealDouble());
  17. smallest = chooseSmallestType(type, sum.getSum());
  18. if (null != smallest) return smallest;
  19. throw new UnsupportedOperationException("Target image is too large!");
  20. }

代码示例来源:origin: imglib/imglib2

  1. private static float[] createReference( final Img< FloatType > img )
  2. {
  3. // use a random number generator
  4. final Random rnd = new Random( 1241234 );
  5. // create reference array
  6. final float[] reference = new float[ ( int ) img.size() ];
  7. // iterate over image and reference array and fill with data
  8. final Cursor< FloatType > cursor = img.cursor();
  9. int i = 0;
  10. while ( cursor.hasNext() )
  11. {
  12. cursor.fwd();
  13. final float value = rnd.nextFloat();
  14. reference[ i++ ] = value;
  15. cursor.get().set( value );
  16. }
  17. return reference;
  18. }

代码示例来源:origin: net.imglib2/imglib2-algorithm-gpl

  1. protected static ImgFactory< ComplexFloatType > getFFTFactory( final Img< ? extends RealType< ? > > img )
  2. {
  3. try
  4. {
  5. return img.factory().imgFactory( new ComplexFloatType() );
  6. }
  7. catch ( final IncompatibleTypeException e )
  8. {
  9. if ( img.size() > Integer.MAX_VALUE / 2 )
  10. return new CellImgFactory<>( new ComplexFloatType(), 1024 );
  11. return new ArrayImgFactory<>( new ComplexFloatType() );
  12. }
  13. }

代码示例来源:origin: imglib/imglib2

  1. int[] getImgAsInts( final Img< IntType > img )
  2. {
  3. final RandomAccess< IntType > a = img.randomAccess();
  4. final int N = ( int ) img.size();
  5. final int[] data = new int[ N ];
  6. final long[] dim = new long[ img.numDimensions() ];
  7. final long[] pos = new long[ img.numDimensions() ];
  8. img.dimensions( dim );
  9. for ( int i = 0; i < N; ++i )
  10. {
  11. IntervalIndexer.indexToPosition( i, dim, pos );
  12. a.setPosition( pos );
  13. data[ i ] = a.get().get();
  14. }
  15. return data;
  16. }

代码示例来源:origin: imglib/imglib2

  1. static int[] getImgAsInts( final Img< IntType > img )
  2. {
  3. final RandomAccess< IntType > a = img.randomAccess();
  4. final int N = ( int ) img.size();
  5. final int[] data = new int[ N ];
  6. final long[] dim = new long[ img.numDimensions() ];
  7. final long[] pos = new long[ img.numDimensions() ];
  8. img.dimensions( dim );
  9. for ( int i = 0; i < N; ++i )
  10. {
  11. IntervalIndexer.indexToPosition( i, dim, pos );
  12. a.setPosition( pos );
  13. data[ i ] = a.get().get();
  14. }
  15. return data;
  16. }

代码示例来源:origin: imglib/imglib2

  1. int[] getImgAsInts( final Img< IntType > img )
  2. {
  3. final RandomAccess< IntType > a = img.randomAccess();
  4. final int N = ( int ) img.size();
  5. final int[] data = new int[ N ];
  6. final long[] dim = new long[ img.numDimensions() ];
  7. final long[] pos = new long[ img.numDimensions() ];
  8. img.dimensions( dim );
  9. for ( int i = 0; i < N; ++i )
  10. {
  11. IntervalIndexer.indexToPosition( i, dim, pos );
  12. a.setPosition( pos );
  13. data[ i ] = a.get().get();
  14. }
  15. return data;
  16. }

代码示例来源:origin: imglib/imglib2

  1. int[] getImgAsInts( final Img< IntType > img )
  2. {
  3. final RandomAccess< IntType > a = img.randomAccess();
  4. final int N = ( int ) img.size();
  5. final int[] data = new int[ N ];
  6. final long[] dim = new long[ img.numDimensions() ];
  7. final long[] pos = new long[ img.numDimensions() ];
  8. img.dimensions( dim );
  9. for ( int i = 0; i < N; ++i )
  10. {
  11. IntervalIndexer.indexToPosition( i, dim, pos );
  12. a.setPosition( pos );
  13. data[ i ] = a.get().get();
  14. }
  15. return data;
  16. }

代码示例来源:origin: imglib/imglib2

  1. int[] getImgAsInts( final Img< IntType > img )
  2. {
  3. final RandomAccess< IntType > a = img.randomAccess();
  4. final int N = ( int ) img.size();
  5. final int[] data = new int[ N ];
  6. final long[] dim = new long[ img.numDimensions() ];
  7. final long[] pos = new long[ img.numDimensions() ];
  8. img.dimensions( dim );
  9. for ( int i = 0; i < N; ++i )
  10. {
  11. IntervalIndexer.indexToPosition( i, dim, pos );
  12. a.setPosition( pos );
  13. data[ i ] = a.get().get();
  14. }
  15. return data;
  16. }

相关文章