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


Java Dimensions.numDimensions方法代码示例

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


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

示例1: calculatePCM

import net.imglib2.Dimensions; //导入方法依赖的package包/类
public static <T extends RealType<T>, S extends RealType<S>, R extends RealType<R>, C extends ComplexType<C>> RandomAccessibleInterval<R> calculatePCM(
		RandomAccessibleInterval<T> img1, RandomAccessibleInterval<S> img2, int[] extension,
		ImgFactory<R> factory, R type, ImgFactory<C> fftFactory, C fftType, ExecutorService service){

	
	// TODO: Extension absolute per dimension in pixels, i.e. int[] extension
	// TODO: not bigger than the image dimension because the second mirroring is identical to the image
	
	Dimensions extSize = PhaseCorrelation2Util.getExtendedSize(img1, img2, extension);
	long[] paddedDimensions = new long[extSize.numDimensions()];
	long[] fftSize = new long[extSize.numDimensions()];
	FFTMethods.dimensionsRealToComplexFast(extSize, paddedDimensions, fftSize);
	
	RandomAccessibleInterval<C> fft1 = fftFactory.create(fftSize, fftType);
	RandomAccessibleInterval<C> fft2 = fftFactory.create(fftSize, fftType);
	
	FFT.realToComplex(Views.interval(PhaseCorrelation2Util.extendImageByFactor(img1, extension), 
			FFTMethods.paddingIntervalCentered(img1, new FinalInterval(paddedDimensions))), fft1, service);
	FFT.realToComplex(Views.interval(PhaseCorrelation2Util.extendImageByFactor(img2, extension), 
			FFTMethods.paddingIntervalCentered(img2, new FinalInterval(paddedDimensions))), fft2, service);
	
	RandomAccessibleInterval<R> pcm = calculatePCMInPlace(fft1, fft2, factory, type, service);
	return pcm;
	
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:26,代码来源:PhaseCorrelation2.java

示例2: calculate

import net.imglib2.Dimensions; //导入方法依赖的package包/类
@Override
public long[][] calculate(Dimensions inputDimensions) {

	long[][] size = new long[2][];
	size[0] = new long[inputDimensions.numDimensions()];
	size[1] = new long[inputDimensions.numDimensions()];

	for (int i = 0; i < inputDimensions.numDimensions(); i++) {
		// real size
		if (powerOfTwo) {
			size[0][i] = NextPowerOfTwo.nextPowerOfTwo(inputDimensions.dimension(i));
		} else {
			size[0][i] = (long) NextSmoothNumber.nextSmooth((int) inputDimensions.dimension(i));
		}
		// complex size
		if (i == 0) {
			size[1][i] = (size[0][i] / 2 + 1);
		} else {
			size[1][i] = size[0][i];
		}
	}

	return size;

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

示例3: getSizeDifference

import net.imglib2.Dimensions; //导入方法依赖的package包/类
/**
 * calculate the size difference of two Dimensions objects (dim2-dim1)
 * @param dim1 first Dimensions
 * @param dim2 second Dimensions
 * @return int array of difference
 */	
public static int[] getSizeDifference(Dimensions dim1, Dimensions dim2) {
	int[] diff = new int[dim1.numDimensions()];
	for (int i = 0; i < dim1.numDimensions(); i++){
		diff[i] = (int) (dim2.dimension(i) - dim1.dimension(i));
	}		
	return diff;
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:14,代码来源:PhaseCorrelation2Util.java

示例4: getExtendedSize

import net.imglib2.Dimensions; //导入方法依赖的package包/类
/**
 * calculate the size of an extended image big enough to hold dim1 and dim2
 * with each dimension also enlarged by extension pixels on each side (but at most by the original image size)
 * @param dim1 first Dimensions
 * @param dim2 second Dimensions
 * @param extension: number of pixels to add at each side in each dimension
 * @return extended dimensions
 */
public static FinalDimensions getExtendedSize(Dimensions dim1, Dimensions dim2, int [] extension) {
	long[] extDims = new long[dim1.numDimensions()];
	for (int i = 0; i <dim1.numDimensions(); i++){
		extDims[i] = dim1.dimension(i) > dim2.dimension(i) ? dim1.dimension(i) : dim2.dimension(i);
		long extBothSides = extDims[i] < extension[i] ? extDims[i] * 2 : extension[i] * 2;
		extDims[i] += extBothSides;
	}
	return new FinalDimensions(extDims);		
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:18,代码来源:PhaseCorrelation2Util.java

示例5: extensionByFactor

import net.imglib2.Dimensions; //导入方法依赖的package包/类
public static int[] extensionByFactor(Dimensions dims, double extensionFactor){
	int[] res = new int[dims.numDimensions()];
	for (int i = 0; i< dims.numDimensions(); i++){
		res[i] = (int) (dims.dimension(i)*extensionFactor);
	}
	return res;
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:8,代码来源:PhaseCorrelation2Util.java

示例6: cropCellDimensions

import net.imglib2.Dimensions; //导入方法依赖的package包/类
static public void cropCellDimensions(
		final Dimensions sourceDimensions,
		final long[] offset,
		final int[] cellDimensions,
		final long[] croppedCellDimensions )
{
	final int n = sourceDimensions.numDimensions();
	for ( int d = 0; d < n; ++d )
		croppedCellDimensions[ d ] = Math.min( cellDimensions[ d ], sourceDimensions.dimension( d ) - offset[ d ] );
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:11,代码来源:H5Utils.java

示例7: getPaddedInputDimensionsRealToComplex

import net.imglib2.Dimensions; //导入方法依赖的package包/类
/**
 * Calculates padding size size for real to complex FFT
 * 
 * @param fast if true calculate size for fast FFT
 * @param inputDimensions original real dimensions
 * @return padded real dimensions
 */
public static Dimensions getPaddedInputDimensionsRealToComplex(
	final boolean fast, final Dimensions inputDimensions)
{
	final long[] paddedSize = new long[inputDimensions.numDimensions()];
	final long[] fftSize = new long[inputDimensions.numDimensions()];

	dimensionsRealToComplex(fast, inputDimensions, paddedSize, fftSize);

	return new FinalDimensions(paddedSize);

}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:19,代码来源:FFTMethodsUtility.java

示例8: getFFTDimensionsRealToComplex

import net.imglib2.Dimensions; //导入方法依赖的package包/类
/**
 * Calculates complex FFT size for real to complex FFT
 * 
 * @param fast if true calculate size for fast FFT
 * @param inputDimensions original real dimensions
 * @return complex FFT dimensions
 */
public static Dimensions getFFTDimensionsRealToComplex(final boolean fast,
	final Dimensions inputDimensions)
{
	final long[] paddedSize = new long[inputDimensions.numDimensions()];
	final long[] fftSize = new long[inputDimensions.numDimensions()];

	dimensionsRealToComplex(fast, inputDimensions, paddedSize, fftSize);

	return new FinalDimensions(fftSize);

}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:19,代码来源:FFTMethodsUtility.java

示例9: calculate

import net.imglib2.Dimensions; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public O calculate(final I input, final Dimensions paddedDimensions) {

	final long[] paddedSize = new long[paddedDimensions.numDimensions()];
	paddedDimensions.dimensions(paddedSize);

	O inputInterval = (O) FFTMethods.paddingIntervalCentered(input,
		FinalDimensions.wrap(paddedSize));

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

示例10: drawViewOutlines

import net.imglib2.Dimensions; //导入方法依赖的package包/类
public static void drawViewOutlines( final Graphics2D g, final Dimensions dims, final AffineTransform3D transfrom, final Color color )
{
	final int n = dims.numDimensions();

	final Queue< List< Boolean > > worklist = new LinkedList<>();
	// add 0,0,..
	final List< Boolean > origin = new ArrayList<>();
	for (int d = 0; d < n; d++)
		origin.add( false );
	worklist.add( origin );

	while ( worklist.size() > 0 )
	{
		final List< Boolean > vertex1 = worklist.poll();
		final List< List< Boolean > > neighbors = getHigherVertices( vertex1 );

		worklist.addAll( neighbors );

		for (final List<Boolean> vertex2 : neighbors)
		{
			final double[] v1Pos = new double[ n ];
			final double[] v2Pos = new double[ n ];

			for (int d = 0; d < n; d++)
			{
				// the outline goes from -0.5 to dimension(d) - 0.5 (compared to the actual range of (0, dim(d)-1))
				// this is because BDV (correctly) draws pixels with center at pixel location 
				v1Pos[d] = vertex1.get( d ) ? dims.dimension( d ) - 0.5 : -0.5;
				v2Pos[d] = vertex2.get( d ) ? dims.dimension( d ) - 0.5 : -0.5;
			}

			transfrom.apply( v1Pos, v1Pos );
			transfrom.apply( v2Pos, v2Pos );

			g.setColor( color );
			g.setStroke( new BasicStroke( 1.0f ) );
			g.drawLine((int) v1Pos[0],(int) v1Pos[1],(int) v2Pos[0],(int) v2Pos[1] );
		}
		
	}
	
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:43,代码来源:LinkOverlay.java

示例11: expandPeakToPossibleShifts

import net.imglib2.Dimensions; //导入方法依赖的package包/类
public static List<PhaseCorrelationPeak2> expandPeakToPossibleShifts(
		PhaseCorrelationPeak2 peak, Dimensions pcmDims, Dimensions img1Dims, Dimensions img2Dims)
{
	int n = pcmDims.numDimensions();
	double[] subpixelDiff = new double[n];
	
	if (peak.getSubpixelPcmLocation() != null)
		for (int i = 0; i < n; i++)
			subpixelDiff[i] = peak.getSubpixelPcmLocation().getDoublePosition( i ) - peak.getPcmLocation().getIntPosition( i );

	int[] originalPCMPeakWithOffset = new int[n];
	peak.getPcmLocation().localize(originalPCMPeakWithOffset);

	int[] extensionImg1 = getSizeDifference(img1Dims, pcmDims);
	int[] extensionImg2 = getSizeDifference(img2Dims, pcmDims);
	int[] offset = new int[pcmDims.numDimensions()];
	for(int i = 0; i < offset.length; i++){
		offset[i] = (extensionImg2[i] - extensionImg1[i] ) / 2;
		originalPCMPeakWithOffset[i] += offset[i];
		originalPCMPeakWithOffset[i] %= pcmDims.dimension(i); 
	}		
	
	List<PhaseCorrelationPeak2> shiftedPeaks = new ArrayList<PhaseCorrelationPeak2>();
	for (int i = 0; i < Math.pow(2, pcmDims.numDimensions()); i++){
		int[] possibleShift = originalPCMPeakWithOffset.clone();
		PhaseCorrelationPeak2 peakWithShift = new PhaseCorrelationPeak2(peak);
		for (int d = 0; d < pcmDims.numDimensions(); d++){
			/*
			 * mirror the shift around the origin in dimension d if (i / 2^d) is even
			 * --> all possible shifts
			 */
			if ((i / (int) Math.pow(2, d) % 2) == 0){
				possibleShift[d] = possibleShift[d] < 0 ? possibleShift[d] + (int) pcmDims.dimension(d) : possibleShift[d] - (int) pcmDims.dimension(d);
			}
		}
		peakWithShift.setShift(new Point(possibleShift));

		if (peakWithShift.getSubpixelPcmLocation() != null)
		{
			double[] subpixelShift = new double[n];
			for (int j =0; j<n;j++){
				subpixelShift[j] = possibleShift[j] + subpixelDiff[j];
			}

			peakWithShift.setSubpixelShift( new RealPoint( subpixelShift ) );
		}
		shiftedPeaks.add(peakWithShift);
	}		
	return shiftedPeaks;
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:51,代码来源:PhaseCorrelation2Util.java

示例12: getOverlapIntervals

import net.imglib2.Dimensions; //导入方法依赖的package包/类
public static Pair<Interval, Interval> getOverlapIntervals(Dimensions img1, Dimensions img2, Localizable shift){
	
	final int numDimensions = img1.numDimensions();
	final long[] offsetImage1 = new long[ numDimensions ];
	final long[] offsetImage2 = new long[ numDimensions ];
	final long[] maxImage1 = new long[ numDimensions ];
	final long[] maxImage2 = new long[ numDimensions ];
	
	long overlapSize;
	
	for ( int d = 0; d < numDimensions; ++d )
	{
		if ( shift.getLongPosition(d) >= 0 )
		{
			// two possiblities
			//
			//               shift=start              end
			//                 |					   |
			// A: Image 1 ------------------------------
			//    Image 2      ----------------------------------
			//
			//               shift=start	    end
			//                 |			     |
			// B: Image 1 ------------------------------
			//    Image 2      -------------------
			
			// they are not overlapping ( this might happen due to fft zeropadding and extension )
			if ( shift.getLongPosition(d) >= img1.dimension( d ) )
			{
				return null;
			}
			
			offsetImage1[ d ] = shift.getLongPosition(d);
			offsetImage2[ d ] = 0;
			overlapSize = Math.min( img1.dimension( d ) - shift.getLongPosition(d),  img2.dimension( d ) );
			maxImage1[ d ] = offsetImage1[d] + overlapSize -1;
			maxImage2[ d ] = offsetImage2[d] + overlapSize -1;
		}
		else
		{
			// two possiblities
			//
			//          shift start                	  end
			//            |	   |			`		   |
			// A: Image 1      ------------------------------
			//    Image 2 ------------------------------
			//
			//          shift start	     end
			//            |	   |          |
			// B: Image 1      ------------
			//    Image 2 -------------------
			
			// they are not overlapping ( this might happen due to fft zeropadding and extension
			if ( shift.getLongPosition(d) <= -img2.dimension( d ) )
			{
				return null;
			}

			offsetImage1[ d ] = 0;
			offsetImage2[ d ] = -shift.getLongPosition(d);
			overlapSize =  Math.min( img2.dimension( d ) + shift.getLongPosition(d),  img1.dimension( d ) );
			maxImage1[ d ] = offsetImage1[d] + overlapSize -1;
			maxImage2[ d ] = offsetImage2[d] + overlapSize -1;
		}
		
	}		
	
	FinalInterval img1Interval = new FinalInterval(offsetImage1, maxImage1);
	FinalInterval img2Interval = new FinalInterval(offsetImage2, maxImage2);
	
	Pair<Interval, Interval> res = new ValuePair<Interval, Interval>(img1Interval, img2Interval);		
	return res;		
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:74,代码来源:PhaseCorrelation2Util.java

示例13: dimensionsElement

import net.imglib2.Dimensions; //导入方法依赖的package包/类
public static Element dimensionsElement( final String name, final Dimensions size )
{
	final long[] array = new long[ size.numDimensions() ];
	size.dimensions( array );
	return longArrayElement( name, array );
}
 
开发者ID:bigdataviewer,项目名称:spimdata,代码行数:7,代码来源:XmlHelpers.java

示例14: calculate

import net.imglib2.Dimensions; //导入方法依赖的package包/类
@Override
public long[][] calculate(Dimensions inputDimensions) {

	long[][] size = new long[2][];
	size[0] = new long[inputDimensions.numDimensions()];
	size[1] = new long[inputDimensions.numDimensions()];

	if (fast && forward) {

		FFTMethods.dimensionsRealToComplexFast(inputDimensions, size[0], size[1]);

	}
	else if (!fast && forward) {
		FFTMethods.dimensionsRealToComplexSmall(inputDimensions, size[0],
			size[1]);

	}
	if (fast && !forward) {

		FFTMethods.dimensionsComplexToRealFast(inputDimensions, size[0], size[1]);

	}
	else if (!fast && !forward) {

		FFTMethods.dimensionsComplexToRealSmall(inputDimensions, size[0],
			size[1]);
	}

	return size;

}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:32,代码来源:ComputeFFTMethodsSize.java


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