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


Java Cursor.next方法代码示例

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


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

示例1: compute

import net.imglib2.Cursor; //导入方法依赖的package包/类
@Override
public void compute(final IterableInterval<I> input,
	final IterableInterval<I> output)
{

	final Cursor<I> inputCursor = input.cursor();
	final Cursor<I> outputCursor = output.cursor();

	double tmp = 0.0d;
	while (outputCursor.hasNext()) {

		final I inputValue = inputCursor.next();
		final I outputValue = outputCursor.next();

		tmp += inputValue.getRealDouble();

		outputValue.setReal(tmp);
	}
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:20,代码来源:IntegralAdd.java

示例2: getIntIntImgLabellingFromLabelMapImagePlus

import net.imglib2.Cursor; //导入方法依赖的package包/类
public static ImgLabeling< Integer, IntType > getIntIntImgLabellingFromLabelMapImagePlus( final ImagePlus labelMap )
{
	final Img< FloatType > img2 = ImageJFunctions.convertFloat( labelMap );

	final Dimensions dims = img2;
	final IntType t = new IntType();
	final RandomAccessibleInterval< IntType > img = Util.getArrayOrCellImgFactory( dims, t ).create( dims, t );
	final ImgLabeling< Integer, IntType > labeling = new ImgLabeling<>( img );

	final Cursor< LabelingType< Integer > > labelCursor = Views.flatIterable( labeling ).cursor();
	for ( final UnsignedByteType input : Views.flatIterable( ImageJFunctions.wrapByte( labelMap ) ) )
	{
		final LabelingType< Integer > element = labelCursor.next();
		if ( input.get() != 0 )
			element.add( input.get() );
	}

	return labeling;
}
 
开发者ID:imglib,项目名称:imglib2-tests,代码行数:20,代码来源:LabelingExample.java

示例3: testIntervalSubsampleSteps

import net.imglib2.Cursor; //导入方法依赖的package包/类
@Test
public void testIntervalSubsampleSteps() {
	Img<DoubleType> img = ArrayImgs.doubles(10,10);
	Random r = new Random();
	for (DoubleType d : img) {
		d.set(r.nextDouble());
	}

	SubsampleIntervalView<DoubleType> expected = Views.subsample((RandomAccessibleInterval<DoubleType>) img, 2, 1);
	SubsampleIntervalView<DoubleType> actual = (SubsampleIntervalView<DoubleType>) ops.transform().subsampleView((RandomAccessibleInterval<DoubleType>)img, 2, 1);

	Cursor<DoubleType> il2C = Views.interval(expected, new long[] { 0, 0 }, new long[] { 4, 9 }).localizingCursor();
	RandomAccess<DoubleType> oprRA = actual.randomAccess();

	while (il2C.hasNext()) {
		il2C.next();
		oprRA.setPosition(il2C);
		assertEquals(il2C.get().get(), oprRA.get().get(), 1e-10);
	}
	
	assertTrue(Intervals.equals(expected, actual));
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:23,代码来源:SubsampleViewTest.java

示例4: testNonZeroMinimumInterval

import net.imglib2.Cursor; //导入方法依赖的package包/类
@Test
public void testNonZeroMinimumInterval() {

	Img<ByteType> img3D = ArrayImgs.bytes(50, 50, 3);
	IntervalView<ByteType> interval2D = Views.interval(img3D,
			new FinalInterval(new long[] { 25, 25, 2 }, new long[] { 35, 35, 2 }));
	final int[] xyAxis = new int[] { 0, 1 };

	// iterate through every slice, should return a single
	// RandomAccessibleInterval<?> from 25, 25, 2 to 35, 35, 2

	final SlicesII<ByteType> hyperSlices = new SlicesII<>(interval2D, xyAxis, true);
	final Cursor<RandomAccessibleInterval<ByteType>> c = hyperSlices.cursor();
	int i = 0;
	while (c.hasNext()) {
		c.next();
		i++;
	}

	assertEquals(1, i);
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:22,代码来源:SliceTest.java

示例5: testIntervalPermuteCoordinates

import net.imglib2.Cursor; //导入方法依赖的package包/类
@Test
public void testIntervalPermuteCoordinates() {
	Img<DoubleType> img = ArrayImgs.doubles(2, 2);
	Cursor<DoubleType> c = img.cursor();
	Random r = new Random();
	while (c.hasNext()) {
		c.next().set(r.nextDouble());
	}
	IntervalView<DoubleType> expected = Views.permuteCoordinates(img, new int[]{0, 1});
	Cursor<DoubleType> e = expected.cursor();
	RandomAccessibleInterval<DoubleType> actual = ops.transform().permuteCoordinatesView(img, new int[]{0, 1});
	RandomAccess<DoubleType> actualRA = actual.randomAccess();
	
	while (e.hasNext()) {
		e.next();
		actualRA.setPosition(e);
		assertEquals(e.get().get(), actualRA.get().get(), 1e-10);
	}
	
	assertTrue(Intervals.equals(expected, actual));
	
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:23,代码来源:PermuteViewTest.java

示例6: moment2

import net.imglib2.Cursor; //导入方法依赖的package包/类
public static <T extends RealType<T>> double[] moment2( IterableInterval<T> img ){
	logger.debug("moments 2 all ");

	int nd = img.numDimensions();
	double[] mom = new double[nd*nd]; 

	double[] loc = new double[nd];
	Cursor<T> lc = img.localizingCursor();
	while(lc.hasNext()){
		lc.next();
		lc.localize(loc);	
		int k = 0;
		for(int i=0; i<nd; i++)for(int j=0; j<nd; j++){
			mom[k++] +=  loc[i] * loc[j] * lc.get().getRealDouble();
		}
	}

	logger.debug("result: " + ArrayUtil.printArray(mom));

	return mom;
}
 
开发者ID:bogovicj,项目名称:hhmi-exp,代码行数:22,代码来源:ImgMoment.java

示例7: defaultShearTest

import net.imglib2.Cursor; //导入方法依赖的package包/类
/** Tests {@link DefaultShearView}. */
@Test
public void defaultShearTest() {
	Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 2, 2 }, new DoubleType());
	Cursor<DoubleType> imgC = img.cursor();
	while (imgC.hasNext()) {
		imgC.next().set(1);
	}

	TransformView<DoubleType> il2 = Views.shear(Views.extendZero(img), 0, 1);
	TransformView<DoubleType> opr = ops.transform().shearView(Views.extendZero(img), 0, 1);
	Cursor<DoubleType> il2C = Views.interval(il2, new FinalInterval(new long[] { 0, 0 }, new long[] { 3, 3 }))
			.cursor();
	RandomAccess<DoubleType> oprRA = Views
			.interval(opr, new FinalInterval(new long[] { 0, 0 }, new long[] { 3, 3 })).randomAccess();

	while (il2C.hasNext()) {
		il2C.next();
		oprRA.setPosition(il2C);
		assertEquals(il2C.get().get(), oprRA.get().get(), 1e-10);
	}
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:23,代码来源:ShearViewTest.java

示例8: defaultSubsampleTest

import net.imglib2.Cursor; //导入方法依赖的package包/类
@Test
public void defaultSubsampleTest() {
	Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
	Random r = new Random();
	for (DoubleType d : img) {
		d.set(r.nextDouble());
	}

	SubsampleView<DoubleType> il2 = Views.subsample((RandomAccessible<DoubleType>) img, 2);
	SubsampleView<DoubleType> opr = ops.transform().subsampleView(img, 2);

	Cursor<DoubleType> il2C = Views.interval(il2, new long[] { 0, 0 }, new long[] { 4, 4 }).localizingCursor();
	RandomAccess<DoubleType> oprRA = opr.randomAccess();

	while (il2C.hasNext()) {
		il2C.next();
		oprRA.setPosition(il2C);
		assertEquals(il2C.get().get(), oprRA.get().get(), 1e-10);
	}
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:21,代码来源:SubsampleViewTest.java

示例9: fillLabelMap2

import net.imglib2.Cursor; //导入方法依赖的package包/类
protected Img<IntType> fillLabelMap2( float hMin, float threshold, float percentFlooding, boolean keepOrphanPeak ){
	
	
	int nNodes = segmentTree0.getNumNodes();
	int[] nodeIdToLabel = new int[nNodes];
	int[] nodeIdToLabelRoot = new int[nNodes];
	double[] peakThresholds = new double[nNodes];
	
	this.nLabels = treeLabeler.getLabeling(hMin, threshold, percentFlooding, keepOrphanPeak, nodeIdToLabel, nodeIdToLabelRoot, peakThresholds);
	
	Cursor<IntType> cursor = segmentMap.cursor();
	Cursor<T> cursorImg = intensity.cursor();
	while( cursor.hasNext() )
	{
		T imgPixel = cursorImg.next();
		float val =imgPixel.getRealFloat();
		
		IntType pixel = cursor.next();
		if(  val >= threshold )
		{
			final int nodeId = (int)pixel.getRealFloat();
			final int labelRoot = nodeIdToLabelRoot[nodeId];
			if(  val >= peakThresholds[labelRoot]  )
			{	
				final int label = nodeIdToLabel[nodeId];
				pixel.setReal( (float)label );
			}
			else
				pixel.setReal( 0.0 );
		}
		else
			pixel.setReal( 0.0 );
	}
	return segmentMap;
	
}
 
开发者ID:mpicbg-scicomp,项目名称:Interactive-H-Watershed,代码行数:37,代码来源:SegmentHierarchyToLabelMap.java

示例10: createProbabilityImage

import net.imglib2.Cursor; //导入方法依赖的package包/类
private void createProbabilityImage(final int classCount,
	final float[][] probValues, final int patchHeight, final int patchWidth)
{
	final int patchesInX = (int) originalImage.dimension(0) / patchWidth;
	final int patchesInY = (int) originalImage.dimension(1) / patchHeight;

	// Create probability image.
	final long width = patchWidth * patchesInX;
	final long height = patchHeight * patchesInY;
	final long[] dims = { width, height, classCount };
	final AxisType[] axes = { Axes.X, Axes.Y, Axes.CHANNEL };
	final FloatType type = new FloatType();
	probDataset = datasetService.create(type, dims, "Probabilities", axes,
		false);

	// Set the probability image to grayscale.
	probDataset.initializeColorTables(classCount);
	for (int c = 0; c < classCount; c++) {
		probDataset.setColorTable(ColorTables.GRAYS, c);
	}

	// Populate the probability image's sample values.
	final ImgPlus<FloatType> probImg = probDataset.typedImg(type);
	final Cursor<FloatType> cursor = probImg.localizingCursor();
	final int[] pos = new int[dims.length];
	while (cursor.hasNext()) {
		cursor.next();
		cursor.localize(pos);
		final int x = pos[0], y = pos[1], c = pos[2];
		final int patchIndexX = x / patchWidth, patchIndexY = y / patchHeight;
		final int p = patchesInX * patchIndexY + patchIndexX;
		cursor.get().set(probValues[p][c]);
	}
}
 
开发者ID:fiji,项目名称:microscope-image-quality,代码行数:35,代码来源:MicroscopeImageFocusQualityClassifier.java

示例11: run

import net.imglib2.Cursor; //导入方法依赖的package包/类
@Override
public  void run() {

    // interpret the current image as a label image and convert it to ImgLabeling

    Img<T> labelMap = (Img<T>) currentImage.getImgPlus();

    final Dimensions dims = labelMap;
    final IntType t = new IntType();
    final RandomAccessibleInterval<IntType> img = Util.getArrayOrCellImgFactory(dims, t).create(dims, t);
    ImgLabeling<Integer, IntType> labeling = new ImgLabeling<Integer, IntType>(img);

    final Cursor<LabelingType<Integer>> labelCursor = Views.flatIterable(labeling).cursor();

    for (final T input : Views.flatIterable(labelMap)) {
        final LabelingType<Integer> element = labelCursor.next();
        if (input.getRealFloat() != 0)
        {
            element.add((int) input.getRealFloat());
        }
    }

    // take the regions, process them to meshes and put it in the viewer
    LabelRegions<Integer> labelRegions = new LabelRegions<Integer>(labeling);

    ArrayList<RandomAccessibleInterval<BoolType>> regions = new ArrayList<RandomAccessibleInterval<BoolType>>();
    Object[] regionsArr = labelRegions.getExistingLabels().toArray();
    for (int i = 0; i < labelRegions.getExistingLabels().size(); i++)
    {
        LabelRegion<Integer> lr = labelRegions.getLabelRegion((Integer)regionsArr[i]);

        Mesh mesh = ops.geom().marchingCubes(lr);
        sceneryService.getActiveSciView().addMesh(mesh, logService);
    }
}
 
开发者ID:scenerygraphics,项目名称:SciView,代码行数:36,代码来源:AddLabelImage.java

示例12: createNewStoreAndCopyOldContents

import net.imglib2.Cursor; //导入方法依赖的package包/类
private synchronized void createNewStoreAndCopyOldContents()
{
	RandomAccessibleInterval< T > newStore = this.factory.createStore( this.min, this.max, t );
	Cursor< T > cursor = Views.iterable( this.store ).cursor();
	RandomAccess< T > access = newStore.randomAccess();
	while ( cursor.hasNext() )
	{
		T val = cursor.next();
		access.setPosition( cursor );
		access.get().set( val );
	}
	this.store = newStore;
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:14,代码来源:GrowingStoreRandomAccessible.java

示例13: createNewStoreAndCopyOldContents

import net.imglib2.Cursor; //导入方法依赖的package包/类
private void createNewStoreAndCopyOldContents()
{
	RandomAccessibleInterval< T > newStore = this.factory.createStore( this.min, this.max, t );
	Cursor< T > cursor = Views.iterable( this.store ).cursor();
	RandomAccess< T > access = newStore.randomAccess();
	while ( cursor.hasNext() )
	{
		T val = cursor.next();
		access.setPosition( cursor );
		access.get().set( val );
	}
	this.store = newStore;
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:14,代码来源:GrowingStoreRandomAccessibleSingletonAccess.java

示例14: downscale

import net.imglib2.Cursor; //导入方法依赖的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

示例15: createRandomImage

import net.imglib2.Cursor; //导入方法依赖的package包/类
public static <T extends NativeType<T> & RealType<T>> Img<T> createRandomImage( int[] sz, T t){
   ArrayImgFactory<T> factory = new ArrayImgFactory<T>();
   Img<T> out = factory.create( sz, t);
   
   Cursor<T> c = out.localizingCursor();
   while(c.hasNext()){
      T val = c.next();
      val.setReal( Math.random() );
   }
   
   return out;
}
 
开发者ID:bogovicj,项目名称:hhmi-exp,代码行数:13,代码来源:ImgOps.java


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