本文整理汇总了Java中net.imglib2.Interval.dimension方法的典型用法代码示例。如果您正苦于以下问题:Java Interval.dimension方法的具体用法?Java Interval.dimension怎么用?Java Interval.dimension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.imglib2.Interval
的用法示例。
在下文中一共展示了Interval.dimension方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculate
import net.imglib2.Interval; //导入方法依赖的package包/类
@Override
public RandomAccessibleInterval<T> calculate(final RandomAccessibleInterval<T> input, final Interval interval) {
boolean oneSizedDims = false;
if (dropSingleDimensions) {
for (int d = 0; d < interval.numDimensions(); d++) {
if (interval.dimension(d) == 1) {
oneSizedDims = true;
break;
}
}
}
if (Intervals.equals(input, interval) && !oneSizedDims)
return input;
if (!Intervals.contains(input, interval))
throw new RuntimeException("Intervals don't match!");
IntervalView<T> res = Views.offsetInterval(input, interval);
return oneSizedDims ? Views.dropSingletonDimensions(res) : res;
}
示例2: computeMinSize
import net.imglib2.Interval; //导入方法依赖的package包/类
/**
* Computes the min coordinate and the size of an {@link Interval} after
* padding with a list of {@link Shape}s in a series morphology operations.
*
* @param source the interval to be applied with some morphology operation
* @param shapes the list of Shapes for padding
* @return a size-2 array storing the min coordinate and the size of the
* padded interval
*/
public static final long[][] computeMinSize(final Interval source,
final List<Shape> shapes)
{
final int numDims = source.numDimensions();
final long[] min = new long[numDims];
final long[] size = new long[numDims];
for (int i = 0; i < numDims; i++) {
min[i] = source.min(i);
size[i] = source.dimension(i);
}
for (final Shape shape : shapes) {
final Neighborhood<BitType> nh = MorphologyUtils.getNeighborhood(shape,
source);
for (int i = 0; i < numDims; i++) {
min[i] += nh.min(i);
size[i] += nh.dimension(i) - 1;
}
}
return new long[][] { min, size };
}
示例3: copyTypedSpace
import net.imglib2.Interval; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static <C extends CalibratedAxis> void copyTypedSpace(
final Interval inInterval, final CalibratedSpace<C> in,
final CalibratedSpace<C> out)
{
int offset = 0;
for (int d = 0; d < in.numDimensions(); d++) {
if (inInterval != null && inInterval.dimension(d) == 1) {
offset++;
}
else {
out.setAxis((C) in.axis(d).copy(), d - offset);
}
}
}
示例4: calculate
import net.imglib2.Interval; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public O calculate(final I input, final Interval centeredInterval) {
int numDimensions = input.numDimensions();
// compute where to place the final Interval for the input so that the
// coordinate in the center
// of the input is at position (0,0).
final long[] min = new long[numDimensions];
final long[] max = new long[numDimensions];
for (int d = 0; d < numDimensions; ++d) {
min[d] = input.min(d) + input.dimension(d) / 2;
max[d] = min[d] + centeredInterval.dimension(d) - 1;
}
return (O) new FinalInterval(min, max);
}
示例5: TransformWeights
import net.imglib2.Interval; //导入方法依赖的package包/类
public TransformWeights(
final ImagePortion portion,
final Interval imgInterval,
final Blending blending,
final AffineTransform3D transform,
final RandomAccessibleInterval< FloatType > overlapImg,
final RandomAccessibleInterval< FloatType > blendingImg,
final long[] offset )
{
this.portion = portion;
this.blendingImg = blendingImg;
this.transform = transform;
this.overlapImg = overlapImg;
this.blending = blending;
this.offsetX = (int)offset[ 0 ];
this.offsetY = (int)offset[ 1 ];
this.offsetZ = (int)offset[ 2 ];
this.imgSizeX = (int)imgInterval.dimension( 0 );
this.imgSizeY = (int)imgInterval.dimension( 1 );
this.imgSizeZ = (int)imgInterval.dimension( 2 );
}
示例6: splitAlongLargestDimension
import net.imglib2.Interval; //导入方法依赖的package包/类
/**
* split the given Interval into nSplits intervals along the largest dimension
* @param interval input interval
* @param nSplits how may splits
* @return list of intervals input was split into
*/
public static List<Interval> splitAlongLargestDimension(Interval interval, long nSplits){
List<Interval> res = new ArrayList<Interval>();
long[] min = new long[interval.numDimensions()];
long[] max = new long[interval.numDimensions()];
interval.min(min);
interval.max(max);
int splitDim = 0;
for (int i = 0; i< interval.numDimensions(); i++){
if (interval.dimension(i) > interval.dimension(splitDim)) splitDim = i;
}
// there could be more splits than actual dimension entries
nSplits = Math.min( nSplits, interval.dimension(splitDim) );
long chunkSize = interval.dimension(splitDim) / nSplits;
long maxSplitDim = max[splitDim];
for (int i = 0; i<nSplits; i++){
if (i != 0){
min[splitDim] += chunkSize;
}
max[splitDim] = min[splitDim] + chunkSize - 1;
if (i == nSplits -1){
max[splitDim] = maxSplitDim;
}
res.add(new FinalInterval(min, max));
}
return res;
}
示例7: integrateRows
import net.imglib2.Interval; //导入方法依赖的package包/类
static private final <T extends NumericType<T>> void integrateRows(
final int rowDimension,
final Interval iimg,
final RandomAccess<T> r2,
final T sum,
final int[] rowDims) {
long nRows = 1;
for (int i=0; i<rowDims.length; ++i) nRows *= iimg.dimension(rowDims[i]) -1;
while (0 != nRows) {
// Integrate an interval over rowDimension
integrateRow(rowDimension, iimg, r2, sum);
--nRows;
for (int i=0; i<rowDims.length; ++i) {
// Advance to the next interval to integrate
r2.fwd(rowDims[i]);
// If beyond bounds in the d dimension
if (r2.getLongPosition(rowDims[i]) == iimg.dimension(rowDims[i])) {
// Reset the d dimension
r2.setPosition(1L, rowDims[i]);
// Advance the next dimension
continue;
}
// Else integrate the next interval
break;
}
}
}
示例8: integrateRow
import net.imglib2.Interval; //导入方法依赖的package包/类
static private final <T extends NumericType<T>> void integrateRow(
final int rowDimension,
final Interval iimg,
final RandomAccess<T> r2,
final T sum) {
sum.setZero();
r2.setPosition(1L, rowDimension);
for (long i = 1; i < iimg.dimension(rowDimension); ++i) {
sum.add(r2.get());
r2.get().set(sum);
r2.fwd(rowDimension);
}
}
示例9: getImgSize
import net.imglib2.Interval; //导入方法依赖的package包/类
public static long[] getImgSize( final Interval img )
{
final long[] dim = new long[ img.numDimensions() ];
for ( int d = 0; d < img.numDimensions(); ++d )
dim[ d ] = img.dimension( d );
return dim;
}
示例10: getImgSizeInt
import net.imglib2.Interval; //导入方法依赖的package包/类
public static int[] getImgSizeInt( final Interval img )
{
final int[] dim = new int[ img.numDimensions() ];
for ( int d = 0; d < img.numDimensions(); ++d )
dim[ d ] = (int)img.dimension( d );
return dim;
}
示例11: paint
import net.imglib2.Interval; //导入方法依赖的package包/类
/**
* This paints the box overlay with perspective and scale set such that it
* fits approximately into the specified screen area.
*
* @param graphics
* graphics context to paint to.
* @param sources
* source intervals (3D boxes) to be shown.
* @param targetInterval
* target interval (2D box) into which a slice of sourceInterval
* is projected.
* @param boxScreen
* (approximate) area of the screen which to fill with the box
* visualisation.
*/
public < I extends IntervalAndTransform > void paint( final Graphics2D graphics, final List< I > sources, final Interval targetInterval, final Interval boxScreen )
{
assert ( targetInterval.numDimensions() >= 2 );
if ( sources.isEmpty() )
return;
final double perspective = 3;
final double screenBoxRatio = 0.75;
long maxSourceSize = 0;
for ( final IntervalAndTransform source : sources )
maxSourceSize = Math.max( maxSourceSize, Math.max( Math.max( source.getSourceInterval().dimension( 0 ), source.getSourceInterval().dimension( 1 ) ), source.getSourceInterval().dimension( 2 ) ) );
final long sourceSize = maxSourceSize;
final long targetSize = Math.max( targetInterval.dimension( 0 ), targetInterval.dimension( 1 ) );
final AffineTransform3D transform = sources.get( 0 ).getSourceToViewer();
final double vx = transform.get( 0, 0 );
final double vy = transform.get( 1, 0 );
final double vz = transform.get( 2, 0 );
final double transformScale = Math.sqrt( vx*vx + vy*vy + vz*vz );
renderBoxHelper.setDepth( perspective * sourceSize * transformScale );
final double bw = screenBoxRatio * boxScreen.dimension( 0 );
final double bh = screenBoxRatio * boxScreen.dimension( 1 );
double scale = Math.min( bw / targetInterval.dimension( 0 ), bh / targetInterval.dimension( 1 ) );
final double tsScale = transformScale * sourceSize / targetSize;
if ( tsScale > 1.0 )
scale /= tsScale;
renderBoxHelper.setScale( scale );
final long x = boxScreen.min( 0 ) + boxScreen.dimension( 0 ) / 2;
final long y = boxScreen.min( 1 ) + boxScreen.dimension( 1 ) / 2;
final AffineTransform t = graphics.getTransform();
final AffineTransform translate = new AffineTransform( 1, 0, 0, 1, x, y );
translate.preConcatenate( t );
graphics.setTransform( translate );
paint( graphics, sources, targetInterval );
graphics.setTransform( t );
}
示例12: copyToImageStack
import net.imglib2.Interval; //导入方法依赖的package包/类
public static < T extends NumericType< T > & NativeType< T > > ImagePlus copyToImageStack( final RandomAccessible< T > rai, final Interval itvl )
{
// A bit of hacking to make slices the 4th dimension and channels the 3rd
// since that's how ImagePlusImgFactory does it
RandomAccessible< T > raip;
if ( rai.numDimensions() > 3 )
raip = Views.permute( rai, 2, 3 );
else
raip = rai;
final long[] dimensions = new long[ itvl.numDimensions() ];
for( int d = 0; d < itvl.numDimensions(); d++ )
{
if ( d == 2 && itvl.numDimensions() > 3 )
dimensions[ d ] = itvl.dimension( 3 );
else if ( d == 3 && itvl.numDimensions() > 3 )
dimensions[ d ] = itvl.dimension( 2 );
else
dimensions[ d ] = itvl.dimension( d );
}
// create the image plus image
final T t = rai.randomAccess().get();
final ImagePlusImgFactory< T > factory = new ImagePlusImgFactory< T >();
final ImagePlusImg< T, ? > target = factory.create( dimensions, t );
long[] dims = new long[ target.numDimensions() ];
target.dimensions( dims );
double k = 0;
long N = 1;
for ( int i = 0; i < itvl.numDimensions(); i++ )
N *= dimensions[ i ];
final Cursor< T > c = target.cursor();
final RandomAccess< T > ra = raip.randomAccess();
while ( c.hasNext() )
{
c.fwd();
ra.setPosition( c );
c.get().set( ra.get() );
if ( k % 10000 == 0 )
{
IJ.showProgress( k / N );
}
k++;
}
IJ.showProgress( 1.1 );
try
{
return target.getImagePlus();
}
catch ( final ImgLibException e )
{
e.printStackTrace();
}
return null;
}
示例13: copyToImageStack
import net.imglib2.Interval; //导入方法依赖的package包/类
public static ImagePlus copyToImageStack( final RandomAccessible< ARGBType > rai, final Interval itvl )
{
// A bit of hacking to make slices the 4th dimension and channels the 3rd
// since that's how ImagePlusImgFactory does it
MixedTransformView< ARGBType > raip = Views.permute( rai, 2, 3 );
final long[] dimensions = new long[ itvl.numDimensions() ];
for( int d = 0; d < itvl.numDimensions(); d++ )
{
if( d == 2 )
dimensions[ d ] = itvl.dimension( 3 );
else if( d == 3 )
dimensions[ d ] = itvl.dimension( 2 );
else
dimensions[ d ] = itvl.dimension( d );
}
// create the image plus image
final ImagePlusImgFactory< ARGBType > factory = new ImagePlusImgFactory< ARGBType >();
final ImagePlusImg< ARGBType, ? > target = factory.create( dimensions, new ARGBType() );
long[] dims = new long[ target.numDimensions() ];
target.dimensions( dims );
double k = 0;
long N = 1;
for ( int i = 0; i < itvl.numDimensions(); i++ )
N *= dimensions[ i ];
final net.imglib2.Cursor< ARGBType > c = target.cursor();
final RandomAccess< ARGBType > ra = raip.randomAccess();
while ( c.hasNext() )
{
c.fwd();
ra.setPosition( c );
c.get().set( ra.get() );
if ( k % 10000 == 0 )
{
IJ.showProgress( k / N );
}
k++;
}
IJ.showProgress( 1.1 );
try
{
return target.getImagePlus();
}
catch ( final ImgLibException e )
{
e.printStackTrace();
}
return null;
}