net.imglib2.view.Views.zeroMin()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(136)

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

Views.zeroMin介绍

[英]Translate the source such that the upper left corner is at the origin
[中]平移源,使左上角位于原点

代码示例

代码示例来源:origin: imagej/imagej-ops

  1. @Override
  2. public IntervalView<T> calculate(RandomAccessibleInterval<T> input) {
  3. return Views.zeroMin(input);
  4. }

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

  1. public SubsampleIntervalView( final RandomAccessibleInterval< T > source, final long... steps )
  2. {
  3. super( Views.zeroMin( source ), steps );
  4. dimensions = new long[ steps.length ];
  5. max = new long[ steps.length ];
  6. for ( int d = 0; d < steps.length; ++d )
  7. {
  8. this.steps[ d ] = steps[ d ];
  9. dimensions[ d ] = ( int )Math.ceil( ( double )source.dimension( d ) / steps[ d ]);
  10. max[ d ] = dimensions[ d ] - 1;
  11. }
  12. }

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

  1. public SubsampleIntervalView( final RandomAccessibleInterval< T > source, final long step )
  2. {
  3. super( Views.zeroMin( source ), step );
  4. dimensions = new long[ steps.length ];
  5. max = new long[ steps.length ];
  6. for ( int d = 0; d < steps.length; ++d )
  7. {
  8. steps[ d ] = step;
  9. dimensions[ d ] = ( int )Math.ceil( ( double )source.dimension( d ) / step );
  10. max[ d ] = dimensions[ d ] - 1;
  11. }
  12. }

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

  1. public SubsampleIntervalView( final RandomAccessibleInterval< T > source, final long... steps )
  2. {
  3. super( Views.zeroMin( source ), steps );
  4. dimensions = new long[ steps.length ];
  5. max = new long[ steps.length ];
  6. for ( int d = 0; d < steps.length; ++d )
  7. {
  8. this.steps[ d ] = steps[ d ];
  9. dimensions[ d ] = ( int )Math.ceil( ( double )source.dimension( d ) / steps[ d ]);
  10. max[ d ] = dimensions[ d ] - 1;
  11. }
  12. }

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

  1. public SubsampleIntervalView( final RandomAccessibleInterval< T > source, final long step )
  2. {
  3. super( Views.zeroMin( source ), step );
  4. dimensions = new long[ steps.length ];
  5. max = new long[ steps.length ];
  6. for ( int d = 0; d < steps.length; ++d )
  7. {
  8. steps[ d ] = step;
  9. dimensions[ d ] = ( int )Math.ceil( ( double )source.dimension( d ) / step );
  10. max[ d ] = dimensions[ d ] - 1;
  11. }
  12. }

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

  1. /** Flip one axis of an image; for example, flip the orientation of the x axis.
  2. * @param img
  3. * @param dimension The index of the dimension to flip; x=0, y=1, z=2, ...
  4. */
  5. public InvertAxis(final RandomAccessibleInterval<R> img, final int dimension) {
  6. super(Views.zeroMin(Views.invertAxis(img, dimension)));
  7. }
  8. }

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

  1. public ROI(final RandomAccessibleInterval<R> img, final long[] offset, final long[] dimensions) {
  2. super(Views.zeroMin(Views.interval(img, offset, asMax(offset, dimensions))));
  3. }

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

  1. public void run()
  2. {
  3. final long[] min1 = min.clone();
  4. final long[] max1 = max.clone();
  5. getInterval( min1, max1, 1 );
  6. if ( halfPixelOffset )
  7. split1 = SimulateMultiViewDataset.extractSlices(
  8. Views.zeroMin( Views.interval( conHalfPixel, min1, max1 ) ),
  9. lightsheetSpacing, snr, new Random( seed1 ) );
  10. else
  11. split1 = SimulateMultiViewDataset.extractSlices(
  12. Views.zeroMin( Views.interval( con, min1, max1 ) ),
  13. lightsheetSpacing, snr, new Random( seed1 ) );
  14. }
  15. } );

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

  1. static private final <R extends RealType<R>> IntervalView<R> process(final Img<R> img, final Mode mode) {
  2. IntervalView<R> iv;
  3. if (Mode.R90 == mode) {
  4. iv = Views.rotate(img, 0, 1);
  5. } else if (Mode.R270 == mode) {
  6. iv = Views.rotate(img, 1, 0);
  7. } else if (Mode.R180 == mode) {
  8. iv = Views.rotate(Views.rotate(img, 0, 1), 0, 1);
  9. } else {
  10. throw new IllegalArgumentException("Invalid Mode: " + mode);
  11. }
  12. return Views.zeroMin(iv);
  13. }
  14. }

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

  1. public void run()
  2. {
  3. final long[] min1 = min.clone();
  4. final long[] max1 = max.clone();
  5. getInterval( min1, max1, 0 );
  6. //System.out.println( new Date( System.currentTimeMillis() ) + ": extracting slices tile " + tile + " snr=" +snr );
  7. split0 = SimulateMultiViewDataset.extractSlices(
  8. Views.zeroMin( Views.interval( con, min1, max1 ) ),
  9. lightsheetSpacing,
  10. snr,
  11. new Random( seed0 ) );
  12. }
  13. } );

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

  1. /**
  2. * get the highest index in dimension dim where a hyperslice of img in that dimension contains nonzero values.
  3. * NB: the result is in local image coordinates (i.e. we zero-min the input)
  4. * @param img the input image
  5. * @param dim the dimension along which to check
  6. * @param <T> pixel type
  7. * @return the highest index with nonzero pixels
  8. */
  9. public static <T extends RealType< T >> long getMaxNonzero(RandomAccessibleInterval< T > img, int dim)
  10. {
  11. final RandomAccessibleInterval< T > imgLocal = Views.isZeroMin( img ) ? img :Views.zeroMin( img );
  12. long i = imgLocal.dimension( dim ) - 1;
  13. for (; i >= 0; i--)
  14. {
  15. if (isNonezero( Views.hyperSlice( imgLocal, dim, i ) ))
  16. return i;
  17. }
  18. return 0l;
  19. }

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

  1. @Override
  2. public boolean runInitialization(
  3. final Img< FloatType > psi,
  4. final List< DeconView > views,
  5. final ExecutorService service )
  6. {
  7. for ( int d = 0; d < psi.numDimensions(); ++d )
  8. if ( input.dimension( d ) != psi.dimension( d ) )
  9. {
  10. IOFunctions.println( "Image dimensions do not match: " + Util.printInterval( input ) + " != " + Util.printInterval( psi ) );
  11. return false;
  12. }
  13. FusionTools.copyImg( Views.zeroMin( input ), Views.zeroMin( psi ), service );
  14. IOFunctions.println( "RandomAccessibleInterval copied onto PSI for init, now approx computing of avg & max." );
  15. return init2.runInitialization( psi, views, service );
  16. }

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

  1. @Override
  2. public boolean runInitialization(
  3. final Img< FloatType > psi,
  4. final List< DeconView > views,
  5. final ExecutorService service )
  6. {
  7. try
  8. {
  9. final Img< FloatType > input = IOFunctions.openAs32Bit( psiStartFile, new CellImgFactory<>() );
  10. for ( int d = 0; d < psi.numDimensions(); ++d )
  11. if ( input.dimension( d ) != psi.dimension( d ) )
  12. {
  13. IOFunctions.println( "Image dimensions do not match: " + Util.printInterval( input ) + " != " + Util.printInterval( psi ) );
  14. return false;
  15. }
  16. FusionTools.copyImg( Views.zeroMin( input ), Views.zeroMin( psi ), service );
  17. IOFunctions.println( "File: " + psiStartFile.getAbsolutePath() + " copied onto PSI for init, now approx computing of avg & max." );
  18. return init2.runInitialization( psi, views, service );
  19. }
  20. catch ( RuntimeException e )
  21. {
  22. IOFunctions.println( "Cannot load init file: " + psiStartFile.getAbsolutePath() + ": " + e );
  23. return false;
  24. }
  25. }

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

  1. public static < T extends Type< T > > Img< T > copyImgNoTranslation(
  2. final RandomAccessibleInterval< T > input,
  3. final ImgFactory< T > factory,
  4. final T type,
  5. final ExecutorService service,
  6. final boolean showProgress )
  7. {
  8. final RandomAccessibleInterval< T > in;
  9. if ( Views.isZeroMin( input ) )
  10. in = input;
  11. else
  12. in = Views.zeroMin( input );
  13. final long[] dim = new long[ in.numDimensions() ];
  14. in.dimensions( dim );
  15. final Img< T > tImg = factory.create( dim, type );
  16. // copy the virtual construct into an actual image
  17. copyImg( in, tImg, service, showProgress );
  18. return tImg;
  19. }

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

  1. public void setMinMax ( final RandomAccessibleInterval< S > source, final Converter< S, FloatType > converter )
  2. {
  3. final RandomAccessibleIntervalCursor< S > cursor = new RandomAccessibleIntervalCursor< S >( Views.isZeroMin( source ) ? source : Views.zeroMin( source ) );
  4. final FloatType t = new FloatType();
  5. if ( cursor.hasNext() )
  6. {
  7. converter.convert( cursor.next(), t );
  8. float min = t.get();
  9. float max = min;
  10. while ( cursor.hasNext() )
  11. {
  12. converter.convert( cursor.next(), t );
  13. final float value = t.get();
  14. if ( value < min )
  15. min = value;
  16. if ( value > max )
  17. max = value;
  18. }
  19. System.out.println("fmax = " + max );
  20. System.out.println("fmin = " + min );
  21. imageProcessor.setMinAndMax( min, max );
  22. }
  23. }
  24. }

代码示例来源:origin: imagej/imagej-ops

  1. /**
  2. * Add 0s before axis minimum.
  3. *
  4. * @param input Input RAI
  5. * @return An extended and cropped version of input
  6. */
  7. private <T extends RealType<T>> RandomAccessibleInterval<T> addLeadingZeros(
  8. RandomAccessibleInterval<T> input)
  9. {
  10. final long[] min = Intervals.minAsLongArray(input);
  11. final long[] max = Intervals.maxAsLongArray(input);
  12. for (int i = 0; i < max.length; i++) {
  13. min[i]--;
  14. }
  15. final T realZero = Util.getTypeFromInterval(input).copy();
  16. realZero.setZero();
  17. final ExtendedRandomAccessibleInterval<T, RandomAccessibleInterval<T>> extendedImg = Views.extendValue(input,
  18. realZero);
  19. final IntervalView<T> offsetInterval = Views.interval(extendedImg,
  20. min, max);
  21. return Views.zeroMin(offsetInterval);
  22. }

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

  1. in = input;
  2. else
  3. in = Views.zeroMin( input );

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

  1. /** Copy img into iimg, offset by 1 in every dimension. */
  2. static private final <R extends NumericType<R>, T extends NumericType<T>> void transferN(
  3. final Img<R> img,
  4. final Img<T> iimg,
  5. final Converter<R, T> converter)
  6. {
  7. // Copy img to iimg, with an offset of 1 in every dimension
  8. final long[] min = new long[img.numDimensions()];
  9. final long[] max = new long[min.length];
  10. for (int i=0; i<min.length; ++i) {
  11. min[i] = 1;
  12. max[i] = img.dimension(i);
  13. }
  14. final Cursor<R> c1 = img.cursor();
  15. final RandomAccess<T> r = Views.zeroMin(Views.interval(iimg, min, max)).randomAccess();
  16. while (c1.hasNext()) {
  17. c1.fwd();
  18. r.setPosition(c1);
  19. converter.convert(c1.get(), r.get());
  20. }
  21. }

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

  1. final Cursor< T > psfCursor = Views.iterable( Views.zeroMin( psf ) ).localizingCursor();

代码示例来源:origin: imagej/imagej-ops

  1. @Test
  2. public void defaultZeroMinTest() {
  3. Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
  4. IntervalView<DoubleType> imgTranslated = Views.interval(
  5. Views.translate((RandomAccessible<DoubleType>) img, 2, 5), new long[] { 2, 5 }, new long[] { 12, 15 });
  6. IntervalView<DoubleType> il2 = Views.zeroMin(imgTranslated);
  7. IntervalView<DoubleType> opr = ops.transform().zeroMinView(imgTranslated);
  8. assertTrue(Views.isZeroMin(il2) == Views.isZeroMin(opr));
  9. }
  10. }

相关文章