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

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

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

Views.extendZero介绍

[英]Extend a RandomAccessibleInterval with a constant-value out-of-bounds strategy where the constant value is the zero-element of the data type.
[中]使用常量值越界策略扩展RandomAccessibleInterval,其中常量值是数据类型的零元素。

代码示例

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

  1. @Override
  2. public ExtendedRandomAccessibleInterval<T, F> calculate(F input) {
  3. return Views.extendZero(input);
  4. }

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

  1. /**
  2. * Constructs a new 2x2x2 neighborhood
  3. *
  4. * <p>
  5. * <em>NB</em>: Copies reference
  6. * </p>
  7. *
  8. * @param interval Image space where the neighborhood is located
  9. */
  10. public Octant(final RandomAccessibleInterval<B> interval) {
  11. access = Views.extendZero(interval).randomAccess();
  12. }

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

  1. /**
  2. * Expand a RandomAccessibleInterval as specified by border. source will be
  3. * extended with the zero-element of that data type.
  4. *
  5. * @param source
  6. * the interval to expand.
  7. * @return Expansion of the {@link RandomAccessibleInterval} source as
  8. * specified by border.
  9. */
  10. public static < T extends NumericType< T > > IntervalView< T > expandZero( final RandomAccessibleInterval< T > source, final long... border )
  11. {
  12. return interval( extendZero( source ), Intervals.expand( source, border ) );
  13. }

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

  1. /**
  2. * Expand a RandomAccessibleInterval as specified by border. source will be
  3. * extended with the zero-element of that data type.
  4. *
  5. * @param source
  6. * the interval to expand.
  7. * @return Expansion of the {@link RandomAccessibleInterval} source as
  8. * specified by border.
  9. */
  10. public static < T extends NumericType< T > > IntervalView< T > expandZero( final RandomAccessibleInterval< T > source, final long... border )
  11. {
  12. return interval( extendZero( source ), Intervals.expand( source, border ) );
  13. }

代码示例来源:origin: sc.fiji/Image_Expression_Parser

  1. @Override
  2. public final < R extends RealType< R > > Img< FloatType > evaluate( final Img< R > img, final R alpha ) throws ParseException
  3. {
  4. RandomAccessibleInterval< FloatType > fimg = ImgLibUtils.copyToFloatTypeImage( img );
  5. try
  6. {
  7. Gauss3.gauss( alpha.getRealDouble(), Views.extendZero( fimg ), fimg );
  8. }
  9. catch ( IncompatibleTypeException e )
  10. {
  11. throw new RuntimeException( e );
  12. }
  13. return ( Img< FloatType > ) fimg;
  14. }

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

  1. @Override
  2. public RealRandomAccessible< T > getInterpolatedSource( final int t, final int level, final Interpolation method )
  3. {
  4. return Views.interpolate( Views.extendZero( getSource( t, level ) ), interpolators.get( method ) );
  5. }

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

  1. @Override
  2. public RealRandomAccess<FloatType> realRandomAccess( final RealInterval interval )
  3. {
  4. return Views.interpolate(
  5. Views.extendZero( this.contentBasedImg ),
  6. new NLinearInterpolatorFactory< FloatType >()
  7. ).realRandomAccess( interval );
  8. }

代码示例来源:origin: fiji/Stitching

  1. public ImageInterpolation( final Img< T > image, final InterpolatorFactory< T, RandomAccessible< T > > interpolatorFactory, final boolean mirror )
  2. {
  3. this.image = image;
  4. this.interpolatorFactory = interpolatorFactory;
  5. if ( mirror )
  6. this.interpolated = Views.interpolate( Views.extendMirrorSingle( image ), interpolatorFactory );
  7. else
  8. this.interpolated = Views.interpolate( Views.extendZero( image ), interpolatorFactory );
  9. }

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

  1. @Override
  2. public RealRandomAccess<FloatType> realRandomAccess()
  3. {
  4. return Views.interpolate(
  5. Views.extendZero( this.contentBasedImg ),
  6. new NLinearInterpolatorFactory< FloatType >()
  7. ).realRandomAccess();
  8. }

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

  1. public Traverser(RandomAccessibleInterval<B> interval) {
  2. xSize = interval.dimension(0);
  3. ySize = interval.dimension(1);
  4. zSize = interval.dimension(2);
  5. x1 = xSize - 1;
  6. y1 = ySize - 1;
  7. z1 = zSize - 1;
  8. access = Views.extendZero(interval).randomAccess();
  9. }
  10. }

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

  1. public void convolve1(
  2. final RandomAccessibleInterval< FloatType > image,
  3. final Img< FloatType > kernel,
  4. final Img< ComplexFloatType > kernelFFT,
  5. final Img< FloatType > result )
  6. {
  7. final FFTConvolution< FloatType > fftConvolution =
  8. new FFTConvolution< FloatType >(
  9. Views.extendMirrorSingle( image ),
  10. image,
  11. Views.extendZero( kernel ),
  12. kernel,
  13. result,
  14. fftFactory );
  15. fftConvolution.setExecutorService( service );
  16. fftConvolution.setKeepImgFFT( false );
  17. fftConvolution.setKernelFFT( kernelFFT );
  18. fftConvolution.convolve();
  19. }

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

  1. public void convolve1(
  2. final RandomAccessibleInterval< FloatType > image,
  3. final Img< FloatType > kernel,
  4. final Img< ComplexFloatType > kernelFFT,
  5. final Img< FloatType > result )
  6. {
  7. final FFTConvolution< FloatType > fftConvolution =
  8. new FFTConvolution< FloatType >(
  9. Views.extendMirrorSingle( image ),
  10. image,
  11. Views.extendZero( kernel ),
  12. kernel,
  13. result,
  14. fftFactory );
  15. fftConvolution.setExecutorService( service );
  16. fftConvolution.setKeepImgFFT( false );
  17. fftConvolution.setKernelFFT( kernelFFT );
  18. fftConvolution.convolve();
  19. }

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

  1. public RandomAccessibleInterval< FloatType > getRandomAccessibleInterval( final int numPoints, final double power )
  2. {
  3. final KNearestNeighborSearch< FloatType > search = new KNearestNeighborSearchOnKDTree<>( new KDTree<>( qualityList ), numPoints );
  4. final RealRandomAccessible< FloatType > realRandomAccessible = Views.interpolate( search, new InverseDistanceWeightingInterpolatorFactory< FloatType >( power ) );
  5. final RandomAccessible< FloatType > randomAccessible = Views.raster( realRandomAccessible );
  6. final RandomAccessibleInterval< FloatType > rai = Views.interval( randomAccessible, interval );
  7. return Views.interval( Views.extendZero( rai ), interval );
  8. }

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

  1. public RandomAccessibleInterval< FloatType > getRandomAccessibleInterval()
  2. {
  3. // InverseDistanceWeightingInterpolatorFactory
  4. final NearestNeighborSearch< FloatType > search = new NearestNeighborSearchOnKDTree<>( new KDTree<>( qualityList ) );
  5. final RealRandomAccessible< FloatType > realRandomAccessible = Views.interpolate( search, new NearestNeighborSearchInterpolatorFactory< FloatType >() );
  6. final RandomAccessible< FloatType > randomAccessible = Views.raster( realRandomAccessible );
  7. final RandomAccessibleInterval< FloatType > rai = Views.interval( randomAccessible, interval );
  8. return Views.interval( Views.extendZero( rai ), interval );
  9. }

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

  1. public void convolve2(
  2. final RandomAccessibleInterval< FloatType > image,
  3. final Img< FloatType > kernel,
  4. final Img< ComplexFloatType > kernelFFT,
  5. final Img< FloatType > result )
  6. {
  7. final FFTConvolution< FloatType > fftConvolution =
  8. new FFTConvolution< FloatType >(
  9. Views.extendValue( image, new FloatType( 1.0f ) ), // ratio outside of the deconvolved space (psi) is 1, shouldn't matter here though
  10. image,
  11. Views.extendZero( kernel ),
  12. kernel,
  13. result,
  14. fftFactory );
  15. fftConvolution.setExecutorService( service );
  16. fftConvolution.setKeepImgFFT( false );
  17. fftConvolution.setKernelFFT( kernelFFT );
  18. fftConvolution.convolve();
  19. }

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

  1. public void convolve2(
  2. final RandomAccessibleInterval< FloatType > image,
  3. final Img< FloatType > kernel,
  4. final Img< ComplexFloatType > kernelFFT,
  5. final Img< FloatType > result )
  6. {
  7. final FFTConvolution< FloatType > fftConvolution =
  8. new FFTConvolution< FloatType >(
  9. Views.extendValue( image, new FloatType( 1.0f ) ), // ratio outside of the deconvolved space (psi) is 1, shouldn't matter here though
  10. image,
  11. Views.extendZero( kernel ),
  12. kernel,
  13. result,
  14. fftFactory );
  15. fftConvolution.setExecutorService( service );
  16. fftConvolution.setKeepImgFFT( false );
  17. fftConvolution.setKernelFFT( kernelFFT );
  18. fftConvolution.convolve();
  19. }

代码示例来源:origin: sc.fiji/TrackMate_

  1. private void processSlice( final RandomAccessibleInterval< T > in, final IterableInterval< T > out )
  2. {
  3. final Cursor< T > cursor = out.localizingCursor();
  4. final RectangleShape shape = new RectangleShape( radius, false );
  5. final NeighborhoodsAccessible< T > nracessible = shape.neighborhoodsRandomAccessible( Views.extendZero( in ) );
  6. final RandomAccess< Neighborhood< T >> nra = nracessible.randomAccess( in );
  7. final int size = ( int ) nra.get().size();
  8. final double[] values = new double[ size ];
  9. // Fill buffer with median values.
  10. while ( cursor.hasNext() )
  11. {
  12. cursor.fwd();
  13. nra.setPosition( cursor );
  14. int index = 0;
  15. for ( final T pixel : nra.get() )
  16. {
  17. values[ index++ ] = pixel.getRealDouble();
  18. }
  19. Arrays.sort( values, 0, index );
  20. cursor.get().setReal( values[ ( index - 1 ) / 2 ] );
  21. }
  22. }

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

  1. @Test
  2. public void UnshearIntervalTest() {
  3. Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 2, 2 }, new DoubleType());
  4. Cursor<DoubleType> imgC = img.cursor();
  5. while (imgC.hasNext()) {
  6. imgC.next().set(1);
  7. }
  8. Cursor<DoubleType> il2 = Views
  9. .unshear(Views.shear(Views.extendZero(img), 0, 1), new FinalInterval(new long[] { 0, 0 }, new long[] { 3, 3 }), 0, 1)
  10. .cursor();
  11. RandomAccess<DoubleType> opr = ops.transform()
  12. .unshearView(Views.shear(Views.extendZero(img), 0, 1), new FinalInterval(new long[] { 0, 0 }, new long[] { 3, 3 }), 0, 1)
  13. .randomAccess();
  14. while (il2.hasNext()) {
  15. il2.next();
  16. opr.setPosition(il2);
  17. assertEquals(il2.get().get(), opr.get().get(), 1e-10);
  18. }
  19. }
  20. }

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

  1. @Test
  2. public void defaultUnshearTest() {
  3. Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 2, 2 }, new DoubleType());
  4. Cursor<DoubleType> imgC = img.cursor();
  5. while (imgC.hasNext()) {
  6. imgC.next().set(1);
  7. }
  8. TransformView<DoubleType> il2 = Views.unshear(Views.shear(Views.extendZero(img), 0, 1), 0, 1);
  9. TransformView<DoubleType> opr = ops.transform().unshearView(Views.shear(Views.extendZero(img), 0, 1), 0, 1);
  10. Cursor<DoubleType> il2C = Views.interval(il2, new FinalInterval(new long[] { 0, 0 }, new long[] { 3, 3 }))
  11. .cursor();
  12. RandomAccess<DoubleType> oprRA = Views
  13. .interval(opr, new FinalInterval(new long[] { 0, 0 }, new long[] { 3, 3 })).randomAccess();
  14. while (il2C.hasNext()) {
  15. il2C.next();
  16. oprRA.setPosition(il2C);
  17. assertEquals(il2C.get().get(), oprRA.get().get(), 1e-10);
  18. }
  19. }

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

  1. @Test
  2. public void extendZeroTest() {
  3. Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
  4. OutOfBounds<DoubleType> il2 = Views.extendZero(img).randomAccess();
  5. OutOfBounds<DoubleType> opr = ops.transform().extendZeroView(img).randomAccess();
  6. il2.setPosition(new int[] { -1, -1 });
  7. opr.setPosition(new int[] { -1, -1 });
  8. assertEquals(il2.get().get(), opr.get().get(), 1e-10);
  9. il2.setPosition(new int[] { 11, 11 });
  10. opr.setPosition(new int[] { 11, 11 });
  11. assertEquals(il2.get().get(), opr.get().get(), 1e-10);
  12. }

相关文章