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


Java Dimensions.dimension方法代码示例

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


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

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

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

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

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

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

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

示例7: computeMapBackModel

import net.imglib2.Dimensions; //导入方法依赖的package包/类
protected < M extends Model< M > > AffineTransform3D computeMapBackModel( final HashMap< ViewId, Tile< M > > tiles, final GlobalOptimizationType type, final SpimData2 spimData )
{
	final AbstractModel< ? > mapBackModel = type.getMapBackModel();
	
	if ( mapBackModel.getMinNumMatches() > 4 )
	{
		IOFunctions.println( "Cannot map back using a model that needs more than 4 points: " + mapBackModel.getClass().getSimpleName() );

		return null;
	}
	else
	{
		IOFunctions.println( "Mapping back to reference frame using a " + mapBackModel.getClass().getSimpleName() );
		
		final ViewId referenceTile = type.getMapBackReferenceTile( this );
		final ViewDescription referenceTileViewDescription = spimData.getSequenceDescription().getViewDescription( referenceTile );
		final ViewSetup referenceTileSetup = referenceTileViewDescription.getViewSetup();
		Dimensions size = ViewSetupUtils.getSizeOrLoad( referenceTileSetup, referenceTileViewDescription.getTimePoint(), spimData.getSequenceDescription().getImgLoader() );
		long w = size.dimension( 0 );
		long h = size.dimension( 1 );

		final double[][] p = new double[][]{
				{ 0, 0, 0 },
				{ w, 0, 0 },
				{ 0, h, 0 },
				{ w, h, 0 } };

		// original coordinates == pa
		final double[][] pa = new double[ 4 ][ 3 ];
		
		// map coordinates to the actual input coordinates
		final ViewRegistration inputModel = spimData.getViewRegistrations().getViewRegistration( referenceTile );

		for ( int i = 0; i < p.length; ++i )
			inputModel.getModel().apply( p[ i ], pa[ i ] );
		
		final M outputModel = tiles.get( referenceTile ).getModel();
		
		// transformed coordinates == pb
		final double[][] pb = new double[ 4 ][ 3 ];

		for ( int i = 0; i < p.length; ++i )
			pb[ i ] = outputModel.apply( pa[ i ] );

		// compute the model that maps pb >> pa
		try
		{
			final ArrayList< PointMatch > pm = new ArrayList< PointMatch >();
			
			for ( int i = 0; i < p.length; ++i )
				pm.add( new PointMatch( new Point( pb[ i ] ), new Point( pa[ i ] ) ) );
			
			mapBackModel.fit( pm );
		} catch ( Exception e )
		{
			IOFunctions.println( "Could not compute model for mapping back: " + e );
			e.printStackTrace();
			return null;
		}

		final AffineTransform3D mapBack = new AffineTransform3D();
		final double[][] m = new double[ 3 ][ 4 ];
		((Affine3D<?>)mapBackModel).toMatrix( m );
		
		mapBack.set( m[0][0], m[0][1], m[0][2], + m[0][3],
					m[1][0], m[1][1], m[1][2], m[1][3], 
					m[2][0], m[2][1], m[2][2], m[2][3] );

		IOFunctions.println( "Model for mapping back: " + mapBack + "\n" );

		return mapBack;
	}
}
 
开发者ID:fiji,项目名称:SPIM_Registration,代码行数:74,代码来源:GlobalOptimizationSubset.java

示例8: computeMaxBoundingBoxDimensions

import net.imglib2.Dimensions; //导入方法依赖的package包/类
/**
 * @param spimData
 * @param viewIdsToProcess
 * @param minBB
 * @param maxBB
 * @return - true if the SpimData object was modified, otherwise false
 */
public static boolean computeMaxBoundingBoxDimensions( final SpimData2 spimData, final List< ViewId > viewIdsToProcess, final double[] minBB, final double[] maxBB )
{
	for ( int d = 0; d < minBB.length; ++d )
	{
		minBB[ d ] = Double.MAX_VALUE;
		maxBB[ d ] = -Double.MAX_VALUE;
	}

	boolean changed = false;
	IOFunctions.println( new Date( System.currentTimeMillis() ) + ": Estimating Bounding Box for Fusion. If size of images is not known (they were never opened before), some of them need to be opened once to determine their size.");

	for ( final ViewId viewId : viewIdsToProcess )
	{
		final ViewDescription viewDescription = spimData.getSequenceDescription().getViewDescription( 
				viewId.getTimePointId(), viewId.getViewSetupId() );

		if ( !viewDescription.isPresent() )
			continue;

		if ( !viewDescription.getViewSetup().hasSize() )
			changed = true;

		final Dimensions size = ViewSetupUtils.getSizeOrLoad( viewDescription.getViewSetup(), viewDescription.getTimePoint(), spimData.getSequenceDescription().getImgLoader() );
		final double[] min = new double[]{ 0, 0, 0 };
		final double[] max = new double[]{
				size.dimension( 0 ) - 1,
				size.dimension( 1 ) - 1,
				size.dimension( 2 ) - 1 };
		
		final ViewRegistration r = spimData.getViewRegistrations().getViewRegistration( viewId );
		r.updateModel();
		final FinalRealInterval interval = r.getModel().estimateBounds( new FinalRealInterval( min, max ) );
		
		for ( int d = 0; d < minBB.length; ++d )
		{
			minBB[ d ] = Math.min( minBB[ d ], interval.realMin( d ) );
			maxBB[ d ] = Math.max( maxBB[ d ], interval.realMax( d ) );
		}
	}

	return changed;
}
 
开发者ID:fiji,项目名称:SPIM_Registration,代码行数:50,代码来源:BoundingBoxGUI.java


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