本文整理了Java中net.imglib2.view.Views.zeroMin()
方法的一些代码示例,展示了Views.zeroMin()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Views.zeroMin()
方法的具体详情如下:
包路径:net.imglib2.view.Views
类名称:Views
方法名:zeroMin
[英]Translate the source such that the upper left corner is at the origin
[中]平移源,使左上角位于原点
代码示例来源:origin: imagej/imagej-ops
@Override
public IntervalView<T> calculate(RandomAccessibleInterval<T> input) {
return Views.zeroMin(input);
}
代码示例来源:origin: net.imglib2/imglib2
public SubsampleIntervalView( final RandomAccessibleInterval< T > source, final long... steps )
{
super( Views.zeroMin( source ), steps );
dimensions = new long[ steps.length ];
max = new long[ steps.length ];
for ( int d = 0; d < steps.length; ++d )
{
this.steps[ d ] = steps[ d ];
dimensions[ d ] = ( int )Math.ceil( ( double )source.dimension( d ) / steps[ d ]);
max[ d ] = dimensions[ d ] - 1;
}
}
代码示例来源:origin: net.imglib2/imglib2
public SubsampleIntervalView( final RandomAccessibleInterval< T > source, final long step )
{
super( Views.zeroMin( source ), step );
dimensions = new long[ steps.length ];
max = new long[ steps.length ];
for ( int d = 0; d < steps.length; ++d )
{
steps[ d ] = step;
dimensions[ d ] = ( int )Math.ceil( ( double )source.dimension( d ) / step );
max[ d ] = dimensions[ d ] - 1;
}
}
代码示例来源:origin: imglib/imglib2
public SubsampleIntervalView( final RandomAccessibleInterval< T > source, final long... steps )
{
super( Views.zeroMin( source ), steps );
dimensions = new long[ steps.length ];
max = new long[ steps.length ];
for ( int d = 0; d < steps.length; ++d )
{
this.steps[ d ] = steps[ d ];
dimensions[ d ] = ( int )Math.ceil( ( double )source.dimension( d ) / steps[ d ]);
max[ d ] = dimensions[ d ] - 1;
}
}
代码示例来源:origin: imglib/imglib2
public SubsampleIntervalView( final RandomAccessibleInterval< T > source, final long step )
{
super( Views.zeroMin( source ), step );
dimensions = new long[ steps.length ];
max = new long[ steps.length ];
for ( int d = 0; d < steps.length; ++d )
{
steps[ d ] = step;
dimensions[ d ] = ( int )Math.ceil( ( double )source.dimension( d ) / step );
max[ d ] = dimensions[ d ] - 1;
}
}
代码示例来源:origin: net.imglib2/imglib2-script
/** Flip one axis of an image; for example, flip the orientation of the x axis.
* @param img
* @param dimension The index of the dimension to flip; x=0, y=1, z=2, ...
*/
public InvertAxis(final RandomAccessibleInterval<R> img, final int dimension) {
super(Views.zeroMin(Views.invertAxis(img, dimension)));
}
}
代码示例来源:origin: net.imglib2/imglib2-script
public ROI(final RandomAccessibleInterval<R> img, final long[] offset, final long[] dimensions) {
super(Views.zeroMin(Views.interval(img, offset, asMax(offset, dimensions))));
}
代码示例来源:origin: net.preibisch/multiview-simulation
public void run()
{
final long[] min1 = min.clone();
final long[] max1 = max.clone();
getInterval( min1, max1, 1 );
if ( halfPixelOffset )
split1 = SimulateMultiViewDataset.extractSlices(
Views.zeroMin( Views.interval( conHalfPixel, min1, max1 ) ),
lightsheetSpacing, snr, new Random( seed1 ) );
else
split1 = SimulateMultiViewDataset.extractSlices(
Views.zeroMin( Views.interval( con, min1, max1 ) ),
lightsheetSpacing, snr, new Random( seed1 ) );
}
} );
代码示例来源:origin: net.imglib2/imglib2-script
static private final <R extends RealType<R>> IntervalView<R> process(final Img<R> img, final Mode mode) {
IntervalView<R> iv;
if (Mode.R90 == mode) {
iv = Views.rotate(img, 0, 1);
} else if (Mode.R270 == mode) {
iv = Views.rotate(img, 1, 0);
} else if (Mode.R180 == mode) {
iv = Views.rotate(Views.rotate(img, 0, 1), 0, 1);
} else {
throw new IllegalArgumentException("Invalid Mode: " + mode);
}
return Views.zeroMin(iv);
}
}
代码示例来源:origin: net.preibisch/multiview-simulation
public void run()
{
final long[] min1 = min.clone();
final long[] max1 = max.clone();
getInterval( min1, max1, 0 );
//System.out.println( new Date( System.currentTimeMillis() ) + ": extracting slices tile " + tile + " snr=" +snr );
split0 = SimulateMultiViewDataset.extractSlices(
Views.zeroMin( Views.interval( con, min1, max1 ) ),
lightsheetSpacing,
snr,
new Random( seed0 ) );
}
} );
代码示例来源:origin: net.preibisch/multiview-reconstruction
/**
* get the highest index in dimension dim where a hyperslice of img in that dimension contains nonzero values.
* NB: the result is in local image coordinates (i.e. we zero-min the input)
* @param img the input image
* @param dim the dimension along which to check
* @param <T> pixel type
* @return the highest index with nonzero pixels
*/
public static <T extends RealType< T >> long getMaxNonzero(RandomAccessibleInterval< T > img, int dim)
{
final RandomAccessibleInterval< T > imgLocal = Views.isZeroMin( img ) ? img :Views.zeroMin( img );
long i = imgLocal.dimension( dim ) - 1;
for (; i >= 0; i--)
{
if (isNonezero( Views.hyperSlice( imgLocal, dim, i ) ))
return i;
}
return 0l;
}
代码示例来源:origin: net.preibisch/multiview-reconstruction
@Override
public boolean runInitialization(
final Img< FloatType > psi,
final List< DeconView > views,
final ExecutorService service )
{
for ( int d = 0; d < psi.numDimensions(); ++d )
if ( input.dimension( d ) != psi.dimension( d ) )
{
IOFunctions.println( "Image dimensions do not match: " + Util.printInterval( input ) + " != " + Util.printInterval( psi ) );
return false;
}
FusionTools.copyImg( Views.zeroMin( input ), Views.zeroMin( psi ), service );
IOFunctions.println( "RandomAccessibleInterval copied onto PSI for init, now approx computing of avg & max." );
return init2.runInitialization( psi, views, service );
}
代码示例来源:origin: net.preibisch/multiview-reconstruction
@Override
public boolean runInitialization(
final Img< FloatType > psi,
final List< DeconView > views,
final ExecutorService service )
{
try
{
final Img< FloatType > input = IOFunctions.openAs32Bit( psiStartFile, new CellImgFactory<>() );
for ( int d = 0; d < psi.numDimensions(); ++d )
if ( input.dimension( d ) != psi.dimension( d ) )
{
IOFunctions.println( "Image dimensions do not match: " + Util.printInterval( input ) + " != " + Util.printInterval( psi ) );
return false;
}
FusionTools.copyImg( Views.zeroMin( input ), Views.zeroMin( psi ), service );
IOFunctions.println( "File: " + psiStartFile.getAbsolutePath() + " copied onto PSI for init, now approx computing of avg & max." );
return init2.runInitialization( psi, views, service );
}
catch ( RuntimeException e )
{
IOFunctions.println( "Cannot load init file: " + psiStartFile.getAbsolutePath() + ": " + e );
return false;
}
}
代码示例来源:origin: net.preibisch/multiview-reconstruction
public static < T extends Type< T > > Img< T > copyImgNoTranslation(
final RandomAccessibleInterval< T > input,
final ImgFactory< T > factory,
final T type,
final ExecutorService service,
final boolean showProgress )
{
final RandomAccessibleInterval< T > in;
if ( Views.isZeroMin( input ) )
in = input;
else
in = Views.zeroMin( input );
final long[] dim = new long[ in.numDimensions() ];
in.dimensions( dim );
final Img< T > tImg = factory.create( dim, type );
// copy the virtual construct into an actual image
copyImg( in, tImg, service, showProgress );
return tImg;
}
代码示例来源:origin: net.imglib2/imglib2-ij
public void setMinMax ( final RandomAccessibleInterval< S > source, final Converter< S, FloatType > converter )
{
final RandomAccessibleIntervalCursor< S > cursor = new RandomAccessibleIntervalCursor< S >( Views.isZeroMin( source ) ? source : Views.zeroMin( source ) );
final FloatType t = new FloatType();
if ( cursor.hasNext() )
{
converter.convert( cursor.next(), t );
float min = t.get();
float max = min;
while ( cursor.hasNext() )
{
converter.convert( cursor.next(), t );
final float value = t.get();
if ( value < min )
min = value;
if ( value > max )
max = value;
}
System.out.println("fmax = " + max );
System.out.println("fmin = " + min );
imageProcessor.setMinAndMax( min, max );
}
}
}
代码示例来源:origin: imagej/imagej-ops
/**
* Add 0s before axis minimum.
*
* @param input Input RAI
* @return An extended and cropped version of input
*/
private <T extends RealType<T>> RandomAccessibleInterval<T> addLeadingZeros(
RandomAccessibleInterval<T> input)
{
final long[] min = Intervals.minAsLongArray(input);
final long[] max = Intervals.maxAsLongArray(input);
for (int i = 0; i < max.length; i++) {
min[i]--;
}
final T realZero = Util.getTypeFromInterval(input).copy();
realZero.setZero();
final ExtendedRandomAccessibleInterval<T, RandomAccessibleInterval<T>> extendedImg = Views.extendValue(input,
realZero);
final IntervalView<T> offsetInterval = Views.interval(extendedImg,
min, max);
return Views.zeroMin(offsetInterval);
}
代码示例来源:origin: net.preibisch/multiview-reconstruction
in = input;
else
in = Views.zeroMin( input );
代码示例来源:origin: net.imglib2/imglib2-script
/** Copy img into iimg, offset by 1 in every dimension. */
static private final <R extends NumericType<R>, T extends NumericType<T>> void transferN(
final Img<R> img,
final Img<T> iimg,
final Converter<R, T> converter)
{
// Copy img to iimg, with an offset of 1 in every dimension
final long[] min = new long[img.numDimensions()];
final long[] max = new long[min.length];
for (int i=0; i<min.length; ++i) {
min[i] = 1;
max[i] = img.dimension(i);
}
final Cursor<R> c1 = img.cursor();
final RandomAccess<T> r = Views.zeroMin(Views.interval(iimg, min, max)).randomAccess();
while (c1.hasNext()) {
c1.fwd();
r.setPosition(c1);
converter.convert(c1.get(), r.get());
}
}
代码示例来源:origin: net.preibisch/multiview-reconstruction
final Cursor< T > psfCursor = Views.iterable( Views.zeroMin( psf ) ).localizingCursor();
代码示例来源:origin: imagej/imagej-ops
@Test
public void defaultZeroMinTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
IntervalView<DoubleType> imgTranslated = Views.interval(
Views.translate((RandomAccessible<DoubleType>) img, 2, 5), new long[] { 2, 5 }, new long[] { 12, 15 });
IntervalView<DoubleType> il2 = Views.zeroMin(imgTranslated);
IntervalView<DoubleType> opr = ops.transform().zeroMinView(imgTranslated);
assertTrue(Views.isZeroMin(il2) == Views.isZeroMin(opr));
}
}
内容来源于网络,如有侵权,请联系作者删除!