当前位置: 首页>>代码示例>>Java>>正文


Java Intervals.numElements方法代码示例

本文整理汇总了Java中net.imglib2.util.Intervals.numElements方法的典型用法代码示例。如果您正苦于以下问题:Java Intervals.numElements方法的具体用法?Java Intervals.numElements怎么用?Java Intervals.numElements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.imglib2.util.Intervals的用法示例。


在下文中一共展示了Intervals.numElements方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mean

import net.imglib2.util.Intervals; //导入方法依赖的package包/类
/**
 * Apply mean filter with given size of reactangle shape
 * 
 * @param input
 *            Input image
 * @param i
 *            Size of rectangle shape
 * @return Filered mean image
 */
@SuppressWarnings("unchecked")
private Img<I> mean(final RandomAccessibleInterval<I> input, final int i) {

	long[] dims = new long[input.numDimensions()];
	input.dimensions(dims);

	final byte[] array = new byte[(int) Intervals.numElements(new FinalInterval(dims))];
	Img<I> meanImg = (Img<I>) ArrayImgs.unsignedBytes(array, dims);

	OutOfBoundsMirrorFactory<ByteType, Img<ByteType>> oobFactory = new OutOfBoundsMirrorFactory<>(
			Boundary.SINGLE);

	ops().run(MeanFilterOp.class, meanImg, input, new RectangleShape(i, true), oobFactory);

	return meanImg;
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:26,代码来源:DefaultCoarsenessFeature.java

示例2: generateUnsignedByteImg

import net.imglib2.util.Intervals; //导入方法依赖的package包/类
private static Img<UnsignedByteType> generateUnsignedByteImg(
	final byte[] values)
{

	final byte[] array =
		new byte[(int) Intervals.numElements(new FinalInterval(dims))];

	if (array.length != values.length) {
		throw new RuntimeException("Number of values doesn't match dimmensions");
	}

	for (int i = 0; i < array.length; i++) {
		array[i] = values[i];
	}

	return ArrayImgs.unsignedBytes(array, dims);
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:18,代码来源:ConvertMapTest.java

示例3: computeAvgImageSize

import net.imglib2.util.Intervals; //导入方法依赖的package包/类
protected long computeAvgImageSize()
{
	long avgSize = 0;
	int countImgs = 0;

	for ( final ViewId viewId : viewIdsToProcess  )
	{
		final ViewDescription desc = spimData.getSequenceDescription().getViewDescription( viewId );

		if ( desc.isPresent() )
		{
			final ViewSetup viewSetup = desc.getViewSetup();
			final long numPixel = Intervals.numElements( ViewSetupUtils.getSizeOrLoad( viewSetup, desc.getTimePoint(), spimData.getSequenceDescription().getImgLoader() ) );

			avgSize += numPixel;
			++countImgs;
		}
	}
	
	return avgSize / countImgs;
}
 
开发者ID:fiji,项目名称:SPIM_Registration,代码行数:22,代码来源:Fusion.java

示例4: downscale

import net.imglib2.util.Intervals; //导入方法依赖的package包/类
/**
 *
 * @param input
 * @param factors
 *            downsampling factors of output block relative to input.
 * @param dimensions
 *            dimensions of the output block (in output resolution)
 * @param min
 *            minimum coordinate of output block (in output resolution).
 *            Corresponding input coordinates are <em>min * factors</em>.
 * @param filename
 * @return
 * @throws InterruptedException
 */
public static VolatileLabelMultisetArray downscale(
		final RandomAccessibleInterval< LabelMultisetType > input,
		final long[] factors,
		final long[] dimensions,
		final long[] min )
{
	final int numElements = ( int ) Intervals.numElements( dimensions ); // num elements in output block
	final int[] data = new int[ numElements ];
	final LongMappedAccessData listData = LongMappedAccessData.factory.createStorage( 32 );

	final Cursor< Neighborhood< LabelMultisetType > > inNeighborhoods = Views.offsetInterval(
			Views.subsample(
					new RectangleShape.NeighborhoodsAccessible< LabelMultisetType >(
							input, new FinalInterval( factors ), RectangleNeighborhoodUnsafe.factory() ),
					factors ),
			min, dimensions ).cursor();

	final Cursor< IntType > outData = ArrayImgs.ints( data, dimensions ).cursor();

	final LabelMultisetEntryList list = new LabelMultisetEntryList( listData, 0 );
	final LabelMultisetEntryListIndex lists = new LabelMultisetEntryListIndex( listData );
	int nextListOffset = 0;
	while ( outData.hasNext() )
	{
		list.createListAt( listData, nextListOffset );
		for ( final LabelMultisetType ms : inNeighborhoods.next() )
			list.mergeWith(	ms );

		int offset = lists.putIfAbsent( list );
		if ( offset == -1 )
		{
			offset = nextListOffset;
			nextListOffset += list.getSizeInBytes();
		}
		outData.next().set( offset );
	}

	return new VolatileLabelMultisetArray( data, listData, nextListOffset, true );
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:54,代码来源:Downscale.java

示例5: generateFloatImg

import net.imglib2.util.Intervals; //导入方法依赖的package包/类
private static Img<FloatType> generateFloatImg(final float[] values) {

		final float[] array =
			new float[(int) Intervals.numElements(new FinalInterval(dims))];

		if (array.length != values.length) {
			throw new RuntimeException("Number of values doesn't match dimmensions");
		}

		for (int i = 0; i < array.length; i++) {
			array[i] = values[i];
		}

		return ArrayImgs.floats(array, dims);
	}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:16,代码来源:ConvertMapTest.java

示例6: generateByteArrayTestImg

import net.imglib2.util.Intervals; //导入方法依赖的package包/类
public ArrayImg<ByteType, ByteArray> generateByteArrayTestImg(
	final boolean fill, final long... dims)
{
	final byte[] array = new byte[(int) Intervals.numElements(new FinalInterval(
		dims))];

	if (fill) {
		seed = 17;
		for (int i = 0; i < array.length; i++) {
			array[i] = (byte) pseudoRandom();
		}
	}

	return ArrayImgs.bytes(array, dims);
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:16,代码来源:AbstractOpTest.java

示例7: generateUnsignedByteArrayTestImg

import net.imglib2.util.Intervals; //导入方法依赖的package包/类
public ArrayImg<UnsignedByteType, ByteArray> generateUnsignedByteArrayTestImg(
	final boolean fill, final long... dims)
{
	final byte[] array = new byte[(int) Intervals.numElements(new FinalInterval(
		dims))];

	if (fill) {
		seed = 17;
		for (int i = 0; i < array.length; i++) {
			array[i] = (byte) pseudoRandom();
		}
	}

	return ArrayImgs.unsignedBytes(array, dims);
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:16,代码来源:AbstractOpTest.java

示例8: generateFloatArrayTestImg

import net.imglib2.util.Intervals; //导入方法依赖的package包/类
public ArrayImg<FloatType, FloatArray> generateFloatArrayTestImg(
	final boolean fill, final long... dims)
{
	final float[] array = new float[(int) Intervals.numElements(
		new FinalInterval(dims))];

	if (fill) {
		seed = 17;
		for (int i = 0; i < array.length; i++) {
			array[i] = (float) pseudoRandom() / (float) Integer.MAX_VALUE;
		}
	}

	return ArrayImgs.floats(array, dims);
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:16,代码来源:AbstractOpTest.java

示例9: getPARegions

import net.imglib2.util.Intervals; //导入方法依赖的package包/类
/**
 *  Build an image compatible with particle analyzer (8-connected binary region )
 * @param input is a label image
 * @return is a binary image
 */
public static <T extends RealType<T> & NativeType<T>> Img<IntType> getPARegions(RandomAccessibleInterval<T> input)
{
	int nDim = input.numDimensions();
	long[] dims = new long[nDim];
	input.dimensions(dims);
	ImgFactory<IntType> imgFactory = Util.getArrayOrCellImgFactory( input ,  new IntType(0) );
	Img<IntType> output = imgFactory.create(  input, new IntType()  );
			
	
	Connectivity connectivity = Connectivity.FULL; 
	RandomAccess<T> raIn = Views.extendMirrorSingle(input).randomAccess();
	
	// random accessible on the ouput
	RandomAccess<IntType> raOut = output.randomAccess();
	
	// define the connectivity
	long[][] neigh = ImageConnectivity.getConnectivityPos(nDim, connectivity.getConn() );
	int[] n_offset = ImageConnectivity.getIdxOffsetToCenterPix(neigh, dims);
	long[][] dPosList = ImageConnectivity.getSuccessiveMove(neigh);
	int nNeigh = n_offset.length;
	
	long nElements = Intervals.numElements( input );
	
	// browse through the image
	for(long idx=0; idx<nElements; idx++){
		
		final long[] pos = new long[nDim];
		getPosFromIdx( idx, pos, dims);
		raIn.setPosition(pos);
		float pVal = raIn.get().getRealFloat();
		
		if( pVal > 0 ){
			
			// loop on neighbors
			raOut.setPosition(pos);
			raOut.get().setInteger(255);
		
			for( int i =0; i<nNeigh; i++){
				
				raIn.move(dPosList[i]);
				float nVal = raIn.get().getRealFloat();
				
				// if p is strictly inferior to n then p it is a border between two label, its value is set to 0
				if ( pVal < nVal ) {
					raOut.get().setInteger( 0 );
					break;
				}
			}
			
		}
	}
	return output;
}
 
开发者ID:mpicbg-scicomp,项目名称:Interactive-H-Watershed,代码行数:59,代码来源:Utils.java

示例10: size

import net.imglib2.util.Intervals; //导入方法依赖的package包/类
@Override
public long size() {
	return Intervals.numElements(this);
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:5,代码来源:SlicesII.java

示例11: calculate

import net.imglib2.util.Intervals; //导入方法依赖的package包/类
@Override
public ImgFactory<T> calculate() {
	return (dims == null || Intervals.numElements(dims) <= Integer.MAX_VALUE)
		? new ArrayImgFactory<>() : new CellImgFactory<>();
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:6,代码来源:DefaultCreateImgFactory.java

示例12: compute

import net.imglib2.util.Intervals; //导入方法依赖的package包/类
@Override
public void compute(final RectangleNeighborhood<Composite<I>> input,
	final DoubleType output)
{
	// computation according to
	// https://en.wikipedia.org/wiki/Summed_area_table
	final IntegralCursor<Composite<I>> cursorS1 = new IntegralCursor<>(input);
	final int dimensions = input.numDimensions();

	// Compute \sum (-1)^{dim - ||cornerVector||_{1}} * I(x^{cornerVector})
	final DoubleType sum1 = new DoubleType();
	sum1.setZero();

	// Convert from input to return type
	final Converter<I, DoubleType> conv = new RealDoubleConverter<>();

	// Compute \sum (-1)^{dim - ||cornerVector||_{1}} * I(x^{cornerVector})
	final DoubleType sum2 = new DoubleType();
	sum2.setZero();

	final DoubleType valueAsDoubleType = new DoubleType();

	while (cursorS1.hasNext()) {
		final Composite<I> compositeValue = cursorS1.next();
		final I value1 = compositeValue.get(0).copy();
		conv.convert(value1, valueAsDoubleType);

		// Obtain the cursor position encoded as corner vector
		final int cornerInteger1 = cursorS1.getCornerRepresentation();

		// Determine if the value has to be added (factor==1) or subtracted
		// (factor==-1)
		final DoubleType factor = new DoubleType(Math.pow(-1.0d, dimensions -
			IntegralMean.norm(cornerInteger1)));
		valueAsDoubleType.mul(factor);

		sum1.add(valueAsDoubleType);

		final I value2 = compositeValue.get(1).copy();
		conv.convert(value2, valueAsDoubleType);

		// Determine if the value has to be added (factor==1) or subtracted
		// (factor==-1)
		valueAsDoubleType.mul(factor);

		sum2.add(valueAsDoubleType);
	}

	final int area = (int) Intervals.numElements(Intervals.expand(input, -1l));

	valueAsDoubleType.set(area); // NB: Reuse available DoubleType
	sum1.mul(sum1);
	sum1.div(valueAsDoubleType); // NB

	sum2.sub(sum1);
	valueAsDoubleType.sub(new DoubleType(1)); // NB
	sum2.div(valueAsDoubleType); // NB

	output.set(sum2);
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:61,代码来源:IntegralVariance.java

示例13: compute

import net.imglib2.util.Intervals; //导入方法依赖的package包/类
@Override
public void compute(final RectangleNeighborhood<Composite<I>> input,
	final DoubleType output)
{
	// computation according to
	// https://en.wikipedia.org/wiki/Summed_area_table
	final IntegralCursor<Composite<I>> cursor = new IntegralCursor<>(input);
	final int dimensions = input.numDimensions();

	// Compute \sum (-1)^{dim - ||cornerVector||_{1}} * I(x^{cornerVector})
	final DoubleType sum = new DoubleType();
	sum.setZero();

	// Convert from input to return type
	final Converter<I, DoubleType> conv = new RealDoubleConverter<>();
	final DoubleType valueAsDoubleType = new DoubleType();

	while (cursor.hasNext()) {
		final I value = cursor.next().get(0).copy();
		conv.convert(value, valueAsDoubleType);

		// Obtain the cursor position encoded as corner vector
		final int cornerInteger = cursor.getCornerRepresentation();

		// Determine if the value has to be added (factor==1) or subtracted
		// (factor==-1)
		final DoubleType factor = new DoubleType(Math.pow(-1.0d, dimensions -
			IntegralMean.norm(cornerInteger)));
		valueAsDoubleType.mul(factor);

		sum.add(valueAsDoubleType);
	}

	final int area = (int) Intervals.numElements(Intervals.expand(input, -1l));

	// Compute mean by dividing the sum divided by the number of elements
	valueAsDoubleType.set(area); // NB: Reuse DoubleType
	sum.div(valueAsDoubleType);

	output.set(sum);
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:42,代码来源:IntegralMean.java

示例14: conforms

import net.imglib2.util.Intervals; //导入方法依赖的package包/类
@Override
public boolean conforms() {
	// conforms only if the kernel is sufficiently small
	return Intervals.numElements(in2()) <= 9;
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:6,代码来源:ConvolveNaiveF.java

示例15: conforms

import net.imglib2.util.Intervals; //导入方法依赖的package包/类
@Override
public boolean conforms() {
	// conforms only if the kernel is sufficiently small
	return Intervals.numElements(kernel) <= 9;
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:6,代码来源:ConvolveNaiveC.java


注:本文中的net.imglib2.util.Intervals.numElements方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。