本文整理了Java中net.imglib2.view.Views.hyperSlice()
方法的一些代码示例,展示了Views.hyperSlice()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Views.hyperSlice()
方法的具体详情如下:
包路径:net.imglib2.view.Views
类名称:Views
方法名:hyperSlice
[英]take a (n-1)-dimensional slice of a n-dimensional view, fixing d-component of coordinates to pos.
[中]取一个n维视图的(n-1)维切片,将坐标的d分量固定到位置。
代码示例来源:origin: imagej/imagej-ops
@Override
public IntervalView<T> calculate(final RandomAccessibleInterval<T> input) {
return Views.hyperSlice(input, d, pos);
}
}
代码示例来源:origin: net.imglib2/imglib2-script
/**
* Perform a hyperslice, with img.numDimensions()-1 dimensions;
* this means for example a 2D slice for a 3D volume.
*
* @param img
* @param fixedDimension
* @param pos
* @throws Exception
*/
public OrthoSlice(final Img<R> img, final int fixedDimension, final long startingPosition) throws Exception {
super(Views.hyperSlice(img, fixedDimension, startingPosition));
}
}
代码示例来源:origin: imagej/imagej-ops
@Override
public MixedTransformView<T> calculate(RandomAccessible<T> input) {
return Views.hyperSlice(input, d, pos);
}
代码示例来源:origin: net.imglib2/imglib2-meta
private static <T extends Type<T>> Img<T> setUpSlice(
ImgPlus<T> sourceImgPlus, int d, long pos) {
return new ImgView<T>(Views.hyperSlice(sourceImgPlus, d, pos),
sourceImgPlus.factory());
}
代码示例来源:origin: net.imagej/imagej-deprecated
private static <T extends Type<T>> Img<T> setUpSlice(
ImgPlus<T> sourceImgPlus, int d, long pos) {
return new ImgView<T>(Views.hyperSlice(sourceImgPlus, d, pos),
sourceImgPlus.factory());
}
代码示例来源:origin: imglib/imglib2
/**
* Removes all unit dimensions (dimensions with size one) from the
* RandomAccessibleInterval
*
* @param source
* the source
* @return a RandomAccessibleInterval without dimensions of size one
*/
public static < T > RandomAccessibleInterval< T > dropSingletonDimensions( final RandomAccessibleInterval< T > source )
{
RandomAccessibleInterval< T > res = source;
for ( int d = source.numDimensions() - 1; d >= 0; --d )
if ( source.dimension( d ) == 1 )
res = Views.hyperSlice( res, d, source.min( d ) );
return res;
}
代码示例来源:origin: net.imglib2/imglib2
/**
* Removes all unit dimensions (dimensions with size one) from the
* RandomAccessibleInterval
*
* @param source
* the source
* @return a RandomAccessibleInterval without dimensions of size one
*/
public static < T > RandomAccessibleInterval< T > dropSingletonDimensions( final RandomAccessibleInterval< T > source )
{
RandomAccessibleInterval< T > res = source;
for ( int d = source.numDimensions() - 1; d >= 0; --d )
if ( source.dimension( d ) == 1 )
res = Views.hyperSlice( res, d, source.min( d ) );
return res;
}
代码示例来源: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: imagej/imagej-ops
@Override
public void run() {
// parse the spacing, and scales strings.
spacing = checkDimensions(spacingString, input.numDimensions(), "Spacings");
scales = Arrays.stream(scaleString.split(regex)).mapToInt(Integer::parseInt)
.toArray();
Dimensions resultDims = Views.addDimension(input, 0, scales.length - 1);
// create output image, potentially-filtered input
result = opService.create().img(resultDims, new FloatType());
for (int s = 0; s < scales.length; s++) {
// Determine whether or not the user would like to apply the gaussian
// beforehand and do it.
RandomAccessibleInterval<T> vesselnessInput = doGauss ? opService.filter()
.gauss(input, scales[s]) : input;
IntervalView<FloatType> scaleResult = Views.hyperSlice(result, result
.numDimensions() - 1, s);
opService.filter().frangiVesselness(scaleResult, vesselnessInput, spacing,
scales[s]);
}
}
}
代码示例来源:origin: net.preibisch/multiview-reconstruction
public static FloatProcessor getFloatProcessor( final RandomAccessible< FloatType > img, final int x, final int y, final int z, final int length )
{
final RandomAccessible< FloatType > s = Views.hyperSlice( img, 2, z );
final FloatProcessor fp = new FloatProcessor( length, length );
final int minX = x - length/2;
final int minY = y - length/2;
final Cursor< FloatType > c0 = Views.iterable( Views.interval( s, new long[]{ minX, minY }, new long[]{ x + length/2 - 1, y + length/2 - 1 } ) ).localizingCursor();
while ( c0.hasNext() )
{
iterate( c0, fp, minX, minY );
}
return fp;
}
代码示例来源:origin: net.preibisch/multiview-reconstruction
@Override
public Pair< double[], Integer > call() throws Exception
{
final RandomAccessibleInterval< FloatType > img = mvdecon.getImage();
// run threads and combine results
double min = Double.MAX_VALUE;
double max = -Double.MAX_VALUE;
final RealSum realSum = new RealSum( numPixels );
long numPixels = 0;
for ( int d = 0; d < img.numDimensions(); ++d )
{
final IterableInterval< FloatType > iterable = Views.iterable( Views.hyperSlice( img, 0, img.dimension( 0 ) / 2 ) );
numPixels += iterable.size();
for ( final FloatType t : iterable )
{
final double v = t.getRealDouble();
min = Math.min( min, v );
max = Math.max( max, v );
realSum.add( v );
}
}
return new ValuePair<>( new double[]{ min, max, realSum.getSum() / (double)numPixels }, listId );
}
}
代码示例来源:origin: net.imagej/imagej-common
@Override
public void run() {
RandomAccessibleInterval<?> img = getView().getData().getImgPlus();
if (isPlanar()) {
// assume x,y are first
for (int i=2; i<img.numDimensions(); i++) {
img = Views.hyperSlice(img, i, getView().getLongPosition(i));
}
}
run(img);
}
代码示例来源:origin: sc.fiji/bigdataviewer-vistools
private void loadTimepoint( final int timepointIndex )
{
currentTimePointIndex = timepointIndex;
if ( isPresent( timepointIndex ) )
{
final T zero = getType().createVariable();
zero.setZero();
currentSource = Views.hyperSlice( source, 3, timepointIndex );
for ( final Interpolation method : Interpolation.values() )
currentInterpolatedSources[ method.ordinal() ] = Views.interpolate( Views.extendValue( currentSource, zero ), interpolators.get( method ) );
}
else
{
currentSource = null;
Arrays.fill( currentInterpolatedSources, null );
}
}
代码示例来源:origin: sc.fiji/bigdataviewer-vistools
private void loadTimepoint( final int timepointIndex )
{
currentTimePointIndex = timepointIndex;
if ( isPresent( timepointIndex ) )
{
final T zero = getType().createVariable();
zero.setZero();
final RandomAccessible< T > slice = Views.hyperSlice( source, 3, timepointIndex );
currentSource = Views.interval( slice, timeSliceInterval );
for ( final Interpolation method : Interpolation.values() )
currentInterpolatedSources[ method.ordinal() ] = Views.interpolate( slice, interpolators.get( method ) );
}
else
{
currentSource = null;
Arrays.fill( currentInterpolatedSources, null );
}
}
代码示例来源:origin: net.preibisch/multiview-reconstruction
public static < T extends RealType< T > > RandomAccessibleInterval< FloatType > transformContentBased(
final RandomAccessibleInterval< T > inputImg,
final ImgFactory< ComplexFloatType > imgFactory,
final double[] sigma1,
final double[] sigma2,
final AffineTransform3D transform,
final Interval boundingBox )
{
if ( inputImg.dimension( 2 ) == 1 && inputImg.min( 2 ) == 0 )
{
final double[] sigma1_2d = new double[]{ sigma1[ 0 ], sigma1[ 1 ] };
final double[] sigma2_2d = new double[]{ sigma2[ 0 ], sigma2[ 1 ] };
final ContentBasedRealRandomAccessible< T > content = new ContentBasedRealRandomAccessible< T >( Views.hyperSlice( inputImg, 2, 0 ), imgFactory, sigma1_2d, sigma2_2d );
return transformWeight( RealViews.addDimension( content ), transform, boundingBox );
}
else
{
return transformWeight( new ContentBasedRealRandomAccessible< T >( inputImg, imgFactory, sigma1, sigma2 ), transform, boundingBox );
}
}
代码示例来源:origin: net.preibisch/multiview-reconstruction
public static Pair< FloatProcessor, FloatProcessor > getTwoImagesB( final Img< FloatType > img, final int z )
{
Random rnd = new Random( System.currentTimeMillis() );
final RandomAccessibleInterval< FloatType > s0 = Views.hyperSlice( img, 2, z );
final FloatProcessor fp0 = new FloatProcessor( (int)s0.dimension( 0 ), (int)s0.dimension( 1 ) );
final FloatProcessor fp1 = new FloatProcessor( (int)s0.dimension( 0 ), (int)s0.dimension( 1 ) );
final Cursor< FloatType > c0 = Views.iterable( s0 ).localizingCursor();
while ( c0.hasNext() )
{
c0.fwd();
final int x = c0.getIntPosition( 0 );
final int y = c0.getIntPosition( 1 );
if ( (x+y) % 2 == 0 )
//if ( rnd.nextInt() % 2 == 0 )
fp0.setf( x, y, c0.get().get() );
else
fp1.setf( x, y, c0.get().get() );
}
return new ValuePair< FloatProcessor, FloatProcessor >( fp0, fp1 );
}
}
代码示例来源:origin: net.preibisch/multiview-reconstruction
public static Pair< FloatProcessor, FloatProcessor > getTwoImagesA( final Img< FloatType > imgIn, final int z, final int dist )
{
final RandomAccessible< FloatType > r = Views.extendMirrorSingle( imgIn );
final RandomAccessibleInterval< FloatType > img = Views.interval( r, imgIn );
final RandomAccessibleInterval< FloatType > s0 = Views.hyperSlice( img, 2, z );
final RandomAccessibleInterval< FloatType > s1 = Views.hyperSlice( img, 2, z + dist );
final FloatProcessor fp0 = new FloatProcessor( (int)s0.dimension( 0 ), (int)s0.dimension( 1 ) );
final FloatProcessor fp1 = new FloatProcessor( (int)s0.dimension( 0 ), (int)s0.dimension( 1 ) );
final Cursor< FloatType > c0 = Views.iterable( s0 ).localizingCursor();
final Cursor< FloatType > c1 = Views.iterable( s1 ).localizingCursor();
while ( c0.hasNext() )
{
c0.fwd();
c1.fwd();
fp0.setf( c0.getIntPosition( 0 ), c0.getIntPosition( 1 ), c0.get().get() );
fp1.setf( c1.getIntPosition( 0 ), c1.getIntPosition( 1 ), c1.get().get() );
}
return new ValuePair< FloatProcessor, FloatProcessor >( fp0, fp1 );
}
代码示例来源:origin: imglib/imglib2
@Test
public void testFullSourceMapMixedAccess()
{
final long[] offset = new long[] { 1, 10, 0, -5 };
final long[] dim = new long[] { 10, 10, 10, 10 };
final RandomAccess< UnsignedByteType > a = Views.offsetInterval( Views.invertAxis( Views.hyperSlice( img, 2, 2 ), 3 ), offset, dim ).randomAccess();
assertTrue( FullSourceMapMixedRandomAccess.class.isInstance( a ) );
final long[] pos = new long[] { 28, 30, 2, 15 };
final long[] dist = new long[] { 2, 3, 4, 1 };
testlocalize( a, pos );
testfwd( a, pos );
testbck( a, pos );
testmove( a, pos, 3 );
testmove( a, pos, -2 );
testmove( a, pos, dist );
}
代码示例来源:origin: imagej/imagej-ops
@Test
public void defaultHyperSliceTest() {
final Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10, 10 },
new DoubleType());
final MixedTransformView<DoubleType> il2 = Views.hyperSlice((RandomAccessible<DoubleType>) img, 1, 8);
final MixedTransformView<DoubleType> opr = ops.transform().hyperSliceView(deinterval(img), 1, 8);
for (int i = 0; i < il2.getTransformToSource().getMatrix().length; i++) {
for (int j = 0; j < il2.getTransformToSource().getMatrix()[i].length; j++) {
assertEquals(il2.getTransformToSource().getMatrix()[i][j], opr.getTransformToSource().getMatrix()[i][j],
1e-10);
}
}
}
代码示例来源:origin: imagej/imagej-ops
@Test
public void IntervalHyperSliceTest() {
final Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10, 10 },
new DoubleType());
final IntervalView<DoubleType> il2 = Views.hyperSlice((RandomAccessibleInterval<DoubleType>) img, 1, 8);
final IntervalView<DoubleType> opr = ops.transform().hyperSliceView(img, 1, 8);
for (int i = 0; i < ((MixedTransformView<DoubleType>) il2.getSource()).getTransformToSource()
.getMatrix().length; i++) {
for (int j = 0; j < ((MixedTransformView<DoubleType>) il2.getSource()).getTransformToSource()
.getMatrix()[i].length; j++) {
assertEquals(
((MixedTransformView<DoubleType>) il2.getSource()).getTransformToSource().getMatrix()[i][j],
((MixedTransformView<DoubleType>) opr.getSource()).getTransformToSource().getMatrix()[i][j],
1e-10);
}
}
assertEquals(img.numDimensions() - 1, opr.numDimensions());
}
}
内容来源于网络,如有侵权,请联系作者删除!