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


Java Img.localizingCursor方法代码示例

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


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

示例1: main

import net.imglib2.img.Img; //导入方法依赖的package包/类
public static void main( String[] args )
{
	new ImageJ();
	
	Img< FloatType > img = ArrayImgs.floats( 500, 500 );
	BlendingRealRandomAccess blend = new BlendingRealRandomAccess(
			img,
			new float[]{ 100, 0 },
			new float[]{ 12, 150 } );
	
	Cursor< FloatType > c = img.localizingCursor();
	
	while ( c.hasNext() )
	{
		c.fwd();
		blend.setPosition( c );
		c.get().setReal( blend.get().getRealFloat() );
	}
	
	ImageJFunctions.show( img );
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:22,代码来源:BlendingRealRandomAccess.java

示例2: createGaussianEllipseImg

import net.imglib2.img.Img; //导入方法依赖的package包/类
public static <T extends NativeType<T> & RealType<T>> Img<T> createGaussianEllipseImg(ImgFactory<T> factory, int[] size, double[] ctr, double[] sigmas, double min, double max, T t){
   
   Img<T> out = factory.create(size, t);
   
   Cursor<T> c = out.localizingCursor();
   double[] pos = new double[3];
   
   while(c.hasNext())
   {
 	 c.fwd();
      c.localize(pos);
      
      double res = 0;
      for(int d=0; d<size.length; d++)
      {
     	 res +=  (pos[d] - ctr[d]) * (pos[d] - ctr[d]) / sigmas[d];
      }
      res = 1/(1 + res);
      
      if( res > min && res < max)  c.get().setReal(res);
      
   }
   return out;
}
 
开发者ID:bogovicj,项目名称:hhmi-exp,代码行数:25,代码来源:ImgOps.java

示例3: main

import net.imglib2.img.Img; //导入方法依赖的package包/类
public static void main( String[] args )
{
	final Img< FloatType > img;
	
	//img = OpenImg.open( "/Users/preibischs/Documents/Microscopy/SPIM/HisYFP-SPIM/img_Angle0.tif", new ArrayImgFactory< FloatType >() );
	img = new ArrayImgFactory< FloatType >().create( new long[]{ 515,  231, 15 }, new FloatType() );
	
	final Cursor< FloatType > c = img.localizingCursor();
	
	while ( c.hasNext() )
	{
		c.next().set( c.getIntPosition( 0 ) % 10 + c.getIntPosition( 1 ) % 13 + c.getIntPosition( 2 ) % 3 );
	}
	
	new ImageJ();
	ImageJFunctions.show( img );
	ImageJFunctions.show( simple2x( img, img.factory(), new boolean[]{ true, true, true } ) );
}
 
开发者ID:fiji,项目名称:SPIM_Registration,代码行数:19,代码来源:Downsample.java

示例4: testFillHoles1

import net.imglib2.img.Img; //导入方法依赖的package包/类
@Test
public void testFillHoles1() {
	Img<BitType> result = ops.create().img(invertedImgWithFilledHoles);
	Img<BitType> inverted = ops.create().img(invertedImgWithFilledHoles);
	ops.image().invert(inverted, imgWithHoles);
	ops.morphology().fillHoles(result, inverted, new DiamondShape(1));

	Cursor<BitType> resultC = result.localizingCursor();
	RandomAccess<BitType> groundTruthRA = invertedImgWithFilledHoles.randomAccess();

	while (resultC.hasNext()) {
		boolean r = resultC.next().get();
		groundTruthRA.setPosition(resultC);
		assertEquals(groundTruthRA.get().get(), r);
	}
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:17,代码来源:MorphologyOpsTest.java

示例5: centralMoment2

import net.imglib2.img.Img; //导入方法依赖的package包/类
public static <T extends RealType<T>> double centralMoment2( Img<T> img, int d ){
	double c = moment1(img,d);
	int nd = img.numDimensions();

	logger.debug("moment 2 central for " + nd + " dims");

	double mom = 0; 

	if( d >= nd){
		logger.warn("Dimension for moment must be less than image dimensionality ... returning 0");
		return mom;
	}
	double[] loc = new double[nd];
	Cursor<T> lc = img.localizingCursor();
	while(lc.hasNext()){
		lc.next();
		lc.localize(loc);	
		mom +=  (loc[d] - c) * (loc[d] - c) * lc.get().getRealDouble();
	}

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

示例6: createEdgeImg

import net.imglib2.img.Img; //导入方法依赖的package包/类
public static <T extends NativeType<T> & RealType<T>> Img<T> createEdgeImg(int[] sz, double[] w,  T t, double sigma){
   ArrayImgFactory<T> factory = new ArrayImgFactory<T>();
   Img<T> out = factory.create( sz, t);
   
   double[] ctr = ArrayUtil.toDouble(sz);
   double[] ones = new double[ctr.length]; 
   ArrayUtil.fill(ones, 1);
   ctr = ArrayUtil.subtract(ctr, ones);
   ArrayUtil.divide(ctr, 2);
   
   logger.debug(" ctr = " + ArrayUtil.printArray(ctr));
   
   Cursor<T> c = out.localizingCursor();
   double[] pos = new double[out.numDimensions()];
   while(c.hasNext()){
      T val = c.next();
      c.localize(pos);
      double[] pt = ArrayUtil.subtract(pos, ctr);
      double[] res = ArrayUtil.multiply( w , pt);
      val.setReal( 
            sigmoid( ArrayUtil.sum(res), sigma )
         );
   }
   
   return out;
}
 
开发者ID:bogovicj,项目名称:hhmi-exp,代码行数:27,代码来源:ImgOps.java

示例7: createGradientImg

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

示例8: upsample

import net.imglib2.img.Img; //导入方法依赖的package包/类
public static <T extends RealType<T> & NativeType<T>> Img<T> upsample(Img<T> input, long[] out_size, Interpolator interpType){
	int nDim = input.numDimensions();
	if(nDim != out_size.length){
		return input;
	}
	long[] in_size = new long[nDim]; 
	input.dimensions(in_size);
	float[] upfactor = new float[nDim];
	for(int i=0; i<nDim; i++){
		upfactor[i] = (float)out_size[i]/in_size[i];
	}
	RealRandomAccess< T > interpolant;
	switch(interpType){
		case Linear:
			NLinearInterpolatorFactory<T> NLinterp_factory = new NLinearInterpolatorFactory<T>();
			interpolant = Views.interpolate( Views.extendBorder( input ), NLinterp_factory ).realRandomAccess();
			break;
		case Lanczos:
			LanczosInterpolatorFactory<T> LanczosInterp_factory = new LanczosInterpolatorFactory<T>();
			interpolant = Views.interpolate( Views.extendBorder( input ), LanczosInterp_factory ).realRandomAccess();
			break;
		default: // NearestNeighbor:
			NearestNeighborInterpolatorFactory<T> NNInterp_factory = new NearestNeighborInterpolatorFactory<T>();
			interpolant = Views.interpolate( Views.extendBorder( input ), NNInterp_factory ).realRandomAccess();
			break;
	}
	final ImgFactory< T > imgFactory = new ArrayImgFactory< T >();
	final Img< T > output = imgFactory.create( out_size , input.firstElement().createVariable() );
	Cursor< T > out_cursor = output.localizingCursor();
	float[] tmp = new float[2];
	while(out_cursor.hasNext()){
		out_cursor.fwd();
		for ( int d = 0; d < nDim; ++d )
			tmp[ d ] = out_cursor.getFloatPosition(d) /upfactor[d];
		interpolant.setPosition(tmp);
		out_cursor.get().setReal( Math.round( interpolant.get().getRealFloat() ) );
	}
	return output;
}
 
开发者ID:mpicbg-scicomp,项目名称:Interactive-H-Watershed,代码行数:40,代码来源:Utils.java

示例9: createGaussianKernel

import net.imglib2.img.Img; //导入方法依赖的package包/类
final private static Img< FloatType > createGaussianKernel( final double[] sigmas )
{
	final int numDimensions = sigmas.length;

	final long[] imageSize = new long[ numDimensions ];
	final double[][] kernel = new double[ numDimensions ][];

	for ( int d = 0; d < numDimensions; ++d )
	{
		kernel[ d ] = Util.createGaussianKernel1DDouble( sigmas[ d ], true );
		imageSize[ d ] = kernel[ d ].length;
	}

	final Img< FloatType > kernelImg = ArrayImgs.floats( imageSize );

	final Cursor< FloatType > cursor = kernelImg.localizingCursor();
	final int[] position = new int[ numDimensions ];

	while ( cursor.hasNext() )
	{
		cursor.fwd();
		cursor.localize( position );

		double value = 1;

		for ( int d = 0; d < numDimensions; ++d )
			value *= kernel[ d ][ position[ d ] ];

		cursor.get().set( ( float ) value );
	}

	return kernelImg;
}
 
开发者ID:fiji,项目名称:SPIM_Registration,代码行数:34,代码来源:ContentBased.java

示例10: main

import net.imglib2.img.Img; //导入方法依赖的package包/类
public static void main( String[] args )
{
	new ImageJ();
	
	// test blending
	ImgFactory< FloatType > f = new ArrayImgFactory< FloatType >();
	Img< FloatType > img = f.create( new int[] { 400, 400 }, new FloatType() ); 
	
	Cursor< FloatType > c = img.localizingCursor();
	final int numDimensions = img.numDimensions();
	final double[] tmp = new double[ numDimensions ];
	
	// for blending
	final long[] dimensions = new long[ numDimensions ];
	img.dimensions( dimensions );
	final float percentScaling = 0.2f;
	final double[] border = new double[ numDimensions ];
				
	while ( c.hasNext() )
	{
		c.fwd();
		
		for ( int d = 0; d < numDimensions; ++d )
			tmp[ d ] = c.getFloatPosition( d );
		
		c.get().set( (float)BlendingPixelFusion.computeWeight( tmp, dimensions, border, percentScaling ) );
	}
	
	ImageJFunctions.show( img );
	Log.debug( "done" );
}
 
开发者ID:fiji,项目名称:Stitching,代码行数:32,代码来源:Fusion.java

示例11: processReal

import net.imglib2.img.Img; //导入方法依赖的package包/类
static private final <T extends RealType<T>> Img<T> processReal(final Img<T> img, final long[] dim, final Mode mode) throws Exception {

		final Img<T> res = img.factory().create(dim, img.firstElement().createVariable());

		InterpolatorFactory<T,RandomAccessible<T>> ifac;
		switch (mode) {
		case LINEAR:
			ifac = new NLinearInterpolatorFactory<T>();
			break;
		case NEAREST_NEIGHBOR:
			ifac = new NearestNeighborInterpolatorFactory<T>();
			break;
		default:
			throw new Exception("Resample: unknown mode!");
		}

		final RealRandomAccess<T> inter = ifac.create(Views.extend(img, new OutOfBoundsMirrorFactory<T,Img<T>>(OutOfBoundsMirrorFactory.Boundary.SINGLE)));
		final Cursor<T> c2 = res.localizingCursor();
		final float[] s = new float[dim.length];
		for (int i=0; i<s.length; i++) s[i] = (float)img.dimension(i) / dim[i];
		final long[] d = new long[dim.length];
		final float[] p = new float[dim.length];
		while (c2.hasNext()) {
			c2.fwd();
			c2.localize(d); // TODO "localize" seems to indicate the opposite of what it does
			for (int i=0; i<d.length; i++) p[i] = d[i] * s[i];
			inter.move(p);
			c2.get().set(inter.get());			
		}
		return res;
	}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:32,代码来源:Resample.java

示例12: main

import net.imglib2.img.Img; //导入方法依赖的package包/类
public static void main( final String[] args )
	{
		final int n = 2;
		final long[] dimensions = new long[] { 5, 5 };
		final ImgFactory< CoordinateType > f = new ListImgFactory< CoordinateType >();
		final CoordinateType type = new CoordinateType( n );
		final Img< CoordinateType > img = f.create( dimensions, type );
		final Cursor< CoordinateType > c = img.localizingCursor();
		while ( c.hasNext() )
			c.next().setPosition( c );
		// c.reset();
		// while ( c.hasNext() )
		// System.out.println( c.next() );

//		final Point center = new Point( 2l, 2l );
//		final LocalNeighborhood2< CoordinateType > neighborhood = new LocalNeighborhood2< CoordinateType >( img, center );
//		final Cursor< CoordinateType > nc = neighborhood.cursor();
//		while ( nc.hasNext() )
//			System.out.println( nc.next() );

		final Interval span = Intervals.createMinMax( -1, -1, 1, 1 );
		final Cursor< Neighborhood< CoordinateType > > n3 = new RectangleNeighborhoodCursor< CoordinateType >( Views.interval( img, Intervals.expand( img, -1 ) ), span, RectangleNeighborhoodSkipCenter.< CoordinateType >factory() );
		while ( n3.hasNext() )
		{
			for ( final CoordinateType t : n3.next() )
				System.out.println( t );
			System.out.println( "-----" );
		}
	}
 
开发者ID:imglib,项目名称:imglib2-tests,代码行数:30,代码来源:ShowCoordinates2D.java

示例13: createGradientImgY

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

示例14: toBooleanArray3dNeg

import net.imglib2.img.Img; //导入方法依赖的package包/类
public static <T extends RealType<T>> boolean[][][] toBooleanArray3dNeg(Img<T> img){
   boolean[][][] out = new boolean[(int)img.dimension(0)][(int)img.dimension(1)][(int)img.dimension(2)];
   Cursor<T> cursor = img.localizingCursor();
   int[] pos = new int[3];
   while(cursor.hasNext()){
      cursor.next();
      cursor.localize(pos);
      out[pos[0]][pos[1]][pos[2]] = (cursor.get().getRealDouble() < 0.5);
   }
   
   return out;
}
 
开发者ID:bogovicj,项目名称:hhmi-exp,代码行数:13,代码来源:ImgOps.java

示例15: toFloatArray3d

import net.imglib2.img.Img; //导入方法依赖的package包/类
public static <T extends RealType<T>> float[][][] toFloatArray3d(Img<T> img){
   float[][][] out = new float[(int)img.dimension(0)][(int)img.dimension(1)][(int)img.dimension(2)];
   Cursor<T> cursor = img.localizingCursor();
   int[] pos = new int[3];
   while(cursor.hasNext()){
      cursor.next();
      cursor.localize(pos);
      out[pos[0]][pos[1]][pos[2]] = (cursor.get().getRealFloat());
   }
   return out;
}
 
开发者ID:bogovicj,项目名称:hhmi-exp,代码行数:12,代码来源:ImgOps.java


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