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


Java Img.numDimensions方法代码示例

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


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

示例1: HWatershedLabeling

import net.imglib2.img.Img; //导入方法依赖的package包/类
public HWatershedLabeling(Img<T> input, float threshold, Connectivity connectivity)
{
	int nDims = input.numDimensions();
	long[] dims = new long[nDims];
	input.dimensions(dims);
	ImgFactory<IntType> imgFactoryIntType=null;
	try {
		imgFactoryIntType = input.factory().imgFactory( new IntType() );
	} catch (IncompatibleTypeException e) {
		e.printStackTrace();
	}
	
	if ( imgFactoryIntType != null )
	{
		this.labelMapMaxTree = imgFactoryIntType.create(dims, new IntType(0));
		Cursor<IntType> c_label = labelMapMaxTree.cursor();
		Cursor<T>       c_input = input.cursor();
		while( c_input.hasNext() )
		{
			c_label.next().setInteger( (int) c_input.next().getRealFloat() );
		}
	}
	
	this.threshold = threshold;
	this.connectivity = connectivity;
}
 
开发者ID:mpicbg-scicomp,项目名称:Interactive-H-Watershed,代码行数:27,代码来源:HWatershedLabeling.java

示例2: mapInterval

import net.imglib2.img.Img; //导入方法依赖的package包/类
public final static <T extends NumericType<T>> void mapInterval(
		final KernelTransformFloatSeparable xfm,
		final Img<T> src, final Img<T> tgt )
{
	NLinearInterpolatorFactory<T> interp = new NLinearInterpolatorFactory<T>();
	RealRandomAccess<T> sara = Views.interpolate( Views.extendZero(src), interp ).realRandomAccess();
	
	Cursor<T> tc = tgt.cursor();
	float[] pos = new float[src.numDimensions()]; 
	while( tc.hasNext() ){
		tc.fwd();
		tc.localize(pos);
		float[] srcPt  = xfm.transformPoint( pos );
		sara.setPosition( srcPt );
		tc.get().set( sara.get() );
		
	}
}
 
开发者ID:bogovicj,项目名称:hhmi-exp,代码行数:19,代码来源:SimCrack.java

示例3: transferN

import net.imglib2.img.Img; //导入方法依赖的package包/类
/** Copy img into iimg, offset by 1 in every dimension. */
static private final <R extends NumericType<R>, T extends NumericType<T>> void transferN(
		final Img<R> img,
		final Img<T> iimg,
		final Converter<R, T> converter)
{
	// Copy img to iimg, with an offset of 1 in every dimension
	final long[] min = new long[img.numDimensions()];
	final long[] max = new long[min.length];
	for (int i=0; i<min.length; ++i) {
		min[i] = 1;
		max[i] = img.dimension(i);
	}
	final Cursor<R> c1 = img.cursor();
	final RandomAccess<T> r = Views.zeroMin(Views.interval(iimg, min, max)).randomAccess();
	while (c1.hasNext()) {
		c1.fwd();
		r.setPosition(c1);
		converter.convert(c1.get(), r.get());
	}
}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:22,代码来源:FastIntegralImg.java

示例4: integrateN

import net.imglib2.img.Img; //导入方法依赖的package包/类
/** In place; assumes iimg already contains the information of the image to integrate. */
static private final <T extends NumericType<T>> void integrateN(
		final Img<T> iimg,
		final T sum)
{
	final RandomAccess<T> r2 = iimg.randomAccess();
	final int numDimensions = iimg.numDimensions();
	// Integrate iimg by summing over all possible kinds of rows
	final int[] rowDims = new int[numDimensions -1];
	for (int rowDimension = 0; rowDimension < numDimensions; ++rowDimension) {
		// Reset position
		for (int i=0; i<numDimensions; ++i) {
			r2.setPosition(1L, i);
		}
		
		// Prepare the set of dimensions to iterate over
		for (int i=0, k=0; i<rowDims.length; ++i, ++k) {
			if (i == rowDimension) ++k;
			rowDims[i] = k;
		}

		// Iterate over all dimensions other than rowDimension
		integrateRows(rowDimension, iimg, r2, sum, rowDims);
	}
}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:26,代码来源:FastIntegralImg.java

示例5: sum

import net.imglib2.img.Img; //导入方法依赖的package包/类
static public Img<FloatType> sum(
		final Img<? extends RealType<?>> img) throws Exception {
	RandomAccess<? extends RealType<?>> c = img.randomAccess();
	int[] pos = new int[img.numDimensions()];
	pos[0] = 348;
	pos[1] = 95;
	c.setPosition(pos);
	System.out.println("Original pixel at 348,95: " + c.get().getRealDouble());

	Img<FloatType> result = Compute.inFloats(new Add(img, img, img, img));

	RandomAccess<? extends RealType<?>> r = result.randomAccess();
	r.setPosition(pos);
	System.out.println("After varargs addition, pixel at 348,95: " + r.get().getRealDouble()
			+ " which is 4 * val: " + (c.get().getRealDouble() * 4 == r.get().getRealDouble()));
	
	return result;
}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:19,代码来源:Benchmark.java

示例6: process

import net.imglib2.img.Img; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
static private final <N extends NumericType<N>> Img<N> process(final Img<N> img, long[] dim, final Mode mode) throws Exception {
	// Pad dim array with missing dimensions
	if (dim.length != img.numDimensions()) {
		long[] d = new long[img.numDimensions()];
		int i = 0;
		for (; i<dim.length; i++) d[i] = dim[i];
		for (; i<img.numDimensions(); i++) d[i] = img.dimension(i);
		dim = d;
	}
	final Type<?> type = img.firstElement().createVariable();
	if (ARGBType.class.isAssignableFrom(type.getClass())) { // type instanceof RGBALegacyType fails to compile
		return (Img)processRGBA((Img)img, dim, mode);
	} else if (type instanceof RealType<?>) {
		return processReal((Img)img, dim, mode);
	} else {
		throw new Exception("Affine transform: cannot handle type " + type.getClass());
	}
}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:20,代码来源:Resample.java

示例7: writeShort

import net.imglib2.img.Img; //导入方法依赖的package包/类
public static <T extends GenericShortType<T>> void writeShort(Img<T> img, String fn)
{
	try
	{
		ImagePlus ipdp = mimicImagePlusShort( img, "name" );
		if(img.numDimensions()==2){
			copyToImageProcessor2dShort(img, ipdp.getProcessor());
		}else if(img.numDimensions()==3){
			copyToImageProcessor3dShort(img, ipdp);
		}
		IJ.save(ipdp, fn);
	}
	catch(Exception e)
	{
		e.printStackTrace();
	}
}
 
开发者ID:bogovicj,项目名称:hhmi-exp,代码行数:18,代码来源:ImgOps.java

示例8: mimicImagePlusShort

import net.imglib2.img.Img; //导入方法依赖的package包/类
public static <T extends GenericShortType<T>> ImagePlus mimicImagePlusShort(
		Img<T> img, String name)
{
	ImagePlus ip = null;
	if(img.numDimensions()==2){
		ByteProcessor fp = new ByteProcessor(
				(int)img.dimension(0),(int)img.dimension(1));
		ip = new ImagePlus(name, fp);
		
	}else if(img.numDimensions()==3){
		
		ImageStack stack = ImageStack.create(
				(int)img.dimension(0),
				(int)img.dimension(1),
				(int)img.dimension(2),
				16);
		ip = new ImagePlus(name, stack);
	}
	
	return ip;
}
 
开发者ID:bogovicj,项目名称:hhmi-exp,代码行数:22,代码来源:ImgOps.java

示例9: 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

示例10: upsample

import net.imglib2.img.Img; //导入方法依赖的package包/类
public static <T extends RealType<T> & NativeType<T>> Img<T> upsample(Img<T> input, float[] upsampling_factor, Interpolator interpType)
{
	int nDim = input.numDimensions(); 
	long[] dims = new long[nDim];
	input.dimensions(dims);
	long[] out_size = new long[nDim];
	
	for(int i=0; i<nDim; i++)
		out_size[i] = (long) (  (float)dims[i] * upsampling_factor[i]  );
	
	return upsample( input, out_size, interpType);
}
 
开发者ID:mpicbg-scicomp,项目名称:Interactive-H-Watershed,代码行数:13,代码来源:Utils.java

示例11: validateFormat

import net.imglib2.img.Img; //导入方法依赖的package包/类
private void validateFormat(final Img<T> image) throws IOException {
	final int ndims = image.numDimensions();
	if (ndims != 2) {
		final long[] dims = new long[ndims];
		image.dimensions(dims);
		throw new IOException("Can only process 2D images, not an image with " +
			ndims + " dimensions (" + Arrays.toString(dims) + ")");
	}
	if (!(image.firstElement() instanceof UnsignedShortType)) {
		throw new IOException("Can only process uint16 images. " +
			"Please convert your image first via Image > Type > 16-bit.");
	}
}
 
开发者ID:fiji,项目名称:microscope-image-quality,代码行数:14,代码来源:MicroscopeImageFocusQualityClassifier.java

示例12: scaleMatrix

import net.imglib2.img.Img; //导入方法依赖的package包/类
private static Img< DoubleType > scaleMatrix( final Img< DoubleType > matrix, final double[] scalingFactors )
{
	final long[] dim = new long[ matrix.numDimensions() ];
	matrix.dimensions( dim );
	final Img< DoubleType > scaledMatrix = matrix.factory().create( dim, matrix.firstElement().createVariable() );
	for ( Cursor< DoubleType > m = matrix.cursor(), s = scaledMatrix.cursor(); s.hasNext(); )
	{
		m.fwd();
		s.fwd();
		s.get().set( scalingFactors[ m.getIntPosition( 0 ) ] * scalingFactors[ m.getIntPosition( 1 ) ] * m.get().get() );
	}
	return scaledMatrix;
}
 
开发者ID:saalfeldlab,项目名称:z-spacing,代码行数:14,代码来源:ShiftCoordinatesTest.java

示例13: 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

示例14: dimensions

import net.imglib2.img.Img; //导入方法依赖的package包/类
static private final long[] dimensions(final Img<?> img) {
	final long[] ds = new long[img.numDimensions()];
	for (int d=0; d<ds.length; ++d) {
		ds[d] = img.dimension(d) + 1;
	}
	return ds;
}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:8,代码来源:FastIntegralImg.java

示例15: regressionTest

import net.imglib2.img.Img; //导入方法依赖的package包/类
@Test
public void regressionTest() throws Exception {

	// load in input image and expected output image.
	Img<FloatType> inputImg = (Img<FloatType>) ops.run(
		net.imagej.ops.image.equation.DefaultEquation.class,
		"Math.tan(0.3*p[0]) + Math.tan(0.1*p[1])");
	Img<FloatType> expectedOutput = ((Img<FloatType>) openFloatImg(
		"Result.tif"));

	// create ouput image
	long[] dims = new long[inputImg.numDimensions()];
	inputImg.dimensions(dims);
	Img<FloatType> actualOutput = ArrayImgs.floats(dims);

	// scale over which the filter operates (sensitivity)
	int scale = 1;

	// physical spacing between data points (1,1 since I got it from the
	// computer)
	double[] spacing = { 1, 1 };

	// run the op
	ops.run(net.imagej.ops.filter.vesselness.DefaultFrangi.class, actualOutput,
		inputImg, spacing, scale);

	// compare the output image data to that stored in the file.
	Cursor<FloatType> cursor = Views.iterable(actualOutput).localizingCursor();
	RandomAccess<FloatType> actualRA = actualOutput.randomAccess();
	RandomAccess<FloatType> expectedRA = expectedOutput.randomAccess();

	while (cursor.hasNext()) {
		cursor.fwd();
		actualRA.setPosition(cursor);
		expectedRA.setPosition(cursor);
		assertEquals(expectedRA.get().get(), actualRA.get().get(), 0);
	}
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:39,代码来源:FrangiVesselnessTest.java


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