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


Java AffineTransform3D.apply方法代码示例

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


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

示例1: rotationCentered

import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
/**
 * Computes a rotation about an input center point
 * 
 * @param axis
 * @param angle in radians
 * @param center
 * @return
 */
public static AffineTransform3D rotationCentered( int axis, double angle, double[] center)
{
	/******************************/
	AffineTransform3D xfm = new AffineTransform3D();
	xfm.rotate( axis, angle );

	int ndims = center.length;
	double[] target = new double[ ndims ];
	
	xfm.apply( center, target );
	
	double[] diff = ArrayUtil.subtract( center, target );

	for (int i = 0; i < ndims; i++) {
		xfm.set(diff[i], i, ndims);
	}
	/******************************/

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

示例2: drawEdge

import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
protected void drawEdge( final Graphics2D g2d, final Spot source, final Spot target, final AffineTransform3D transform, final float transparency, final boolean limitDrawingDetph, final double drawingDepth )
{

	// Find x & y & z in physical coordinates
	final double x0i = source.getFeature( Spot.POSITION_X );
	final double y0i = source.getFeature( Spot.POSITION_Y );
	final double z0i = source.getFeature( Spot.POSITION_Z );
	final double[] physicalPositionSource = new double[] { x0i, y0i, z0i };

	final double x1i = target.getFeature( Spot.POSITION_X );
	final double y1i = target.getFeature( Spot.POSITION_Y );
	final double z1i = target.getFeature( Spot.POSITION_Z );
	final double[] physicalPositionTarget = new double[] { x1i, y1i, z1i };

	// In pixel units
	final double[] pixelPositionSource = new double[ 3 ];
	transform.apply( physicalPositionSource, pixelPositionSource );
	final double[] pixelPositionTarget = new double[ 3 ];
	transform.apply( physicalPositionTarget, pixelPositionTarget );

	if (limitDrawingDetph && Math.abs( pixelPositionSource[2]) > drawingDepth &&  Math.abs( pixelPositionTarget[2]) > drawingDepth)
		return;

	// Round
	final int x0 = ( int ) Math.round( pixelPositionSource[ 0 ] );
	final int y0 = ( int ) Math.round( pixelPositionSource[ 1 ] );
	final int x1 = ( int ) Math.round( pixelPositionTarget[ 0 ] );
	final int y1 = ( int ) Math.round( pixelPositionTarget[ 1 ] );

	g2d.setComposite( AlphaComposite.getInstance( AlphaComposite.SRC_OVER, transparency ) );
	g2d.drawLine( x0, y0, x1, y1 );
}
 
开发者ID:fiji,项目名称:MaMuT,代码行数:33,代码来源:MamutOverlay.java

示例3: setMask

import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
/**
	 *  Samples a patch of size N^d where d is the dimensionality of the 
	 *  source image src. The input transformation maps the x- and y-axes 
	 *  to the axes of the sampling plane and is typically determined by 
	 *  the {@link pickTransformation} method.
	 * 
	 *
	 * @param basepos point
	 * @param N size of a dimension of the output patch
	 * @param xfm transformation
	 * @param src source image
	 * @return 
	 */
	public static <L extends NumericType<L>> void setMask(float[] basepos, int[] patchSize,  
			AffineTransform3D xfmIn,  RandomAccessible<L> src, L val ){
		
		AffineTransform3D xfm = xfmIn.copy();
//		AffineTransform3D xfm = xfmIn.inverse();
		
		logger.debug("set edgel mask ");
		logger.debug("xfm : " + xfm);
		
		RandomAccess<L> ra = src.randomAccess();
//		ra.setPosition(position);
		
		int ndims_in  = src.numDimensions();
		
		logger.debug(" basepos  :" + ArrayUtil.printArray( basepos ) );
		logger.debug(" out size :" + ArrayUtil.printArray( patchSize ) );

		double[]  pos	= new double[ndims_in];
		double[] dpos	= new double[ndims_in];
		

		IntervalIterator iter = new IntervalIterator(patchSize);
		while(iter.hasNext()){
			
			iter.fwd();
			iter.localize(pos);
			
			xfm.apply( pos, dpos);
			int[] pt = ArrayUtil.toIntRound(dpos);
			logger.trace(" pt :" + ArrayUtil.printArray( pt ) );
			
			ra.setPosition(pt);
			ra.get().set(val);
		}
	}
 
开发者ID:bogovicj,项目名称:hhmi-exp,代码行数:49,代码来源:CrackCorrection.java

示例4: correctForDownsampling

import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
protected void correctForDownsampling( final List< InterestPoint > ips, final AffineTransform3D t )
{
	IOFunctions.println("(" + new Date(System.currentTimeMillis()) + "): Correcting coordinates for downsampling (xy=" + downsampleXY + "x, z=" + downsampleZ + "x) using AffineTransform: " + t );

	if ( ips == null || ips.size() == 0 )
	{
		IOFunctions.println("(" + new Date(System.currentTimeMillis()) + "): WARNING: List is empty." );
		return;
	}

	final double[] tmp = new double[ ips.get( 0 ).getL().length ];

	for ( final InterestPoint ip : ips )
	{
		t.apply( ip.getL(), tmp );

		ip.getL()[ 0 ] = tmp[ 0 ];
		ip.getL()[ 1 ] = tmp[ 1 ];
		ip.getL()[ 2 ] = tmp[ 2 ];

		t.apply( ip.getW(), tmp );

		ip.getW()[ 0 ] = tmp[ 0 ];
		ip.getW()[ 1 ] = tmp[ 1 ];
		ip.getW()[ 2 ] = tmp[ 2 ];
	}
}
 
开发者ID:fiji,项目名称:SPIM_Registration,代码行数:28,代码来源:DifferenceOf.java

示例5: drawOverlays

import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
@Override
public void drawOverlays( final Graphics g )
{
	final Graphics2D graphics = ( Graphics2D ) g;
	final int t = viewer.getState().getCurrentTimepoint();
	final double[] lPos = new double[ 3 ];
	final double[] gPos = new double[ 3 ];
	final AffineTransform3D transform = new AffineTransform3D();

	for ( final InterestPointSource pointSource : interestPointSources )
	{
		pointSource.getLocalToGlobalTransform( t, transform );
		transform.preConcatenate( viewerTransform );

		for ( final RealLocalizable p : pointSource.getLocalCoordinates( t ) )
		{
			p.localize( lPos );
			transform.apply( lPos, gPos );
			final double size = getPointSize( gPos );
			final int x = ( int ) ( gPos[ 0 ] - 0.5 * size );
			final int y = ( int ) ( gPos[ 1 ] - 0.5 * size );
			final int w = ( int ) size;
			graphics.setColor( getColor( gPos ) );
			graphics.fillOval( x, y, w, w );
		}
	}
}
 
开发者ID:fiji,项目名称:SPIM_Registration,代码行数:28,代码来源:InterestPointOverlay.java

示例6: main

import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
public static void main(String[] args)
{
	AffineTransform3D scale = new AffineTransform3D();
	
	scale.scale( 2.0 );
	//scale.rotate( 0, 45 );
	
	
	AffineTransform3D translate = new AffineTransform3D();
	translate.translate( new double[] {100.0, 100.0, 100.0} );
	AffineTransform3D translate2 = new AffineTransform3D();
	translate2.translate( new double[] {200.0, 200.0, 200.0} );
	
	AffineTransform3D conc = scale.copy().preConcatenate( translate );
	scale.scale( 3.0 );
	AffineTransform3D conc2 = scale.copy().preConcatenate( translate2 );
	//System.out.println( scale );
	//System.out.println( translate );
	System.out.println( conc );
	System.out.println( conc2 );
	
	RealPoint p1 = new RealPoint( 3 );
	conc.apply( p1, p1 );
	RealPoint p2 = new RealPoint( 3 );
	conc2.apply( p2, p2 );
	
	System.out.println( p1 );
	System.out.println( p2 );
	
	AffineTransform3D everythingbuttraslation = conc.copy();
	everythingbuttraslation.set( 0, 0, 3 );
	everythingbuttraslation.set( 0, 1, 3 );
	everythingbuttraslation.set( 0, 2, 3 );
	
	AffineTransform3D everythingbuttraslation2 = conc2.copy();
	everythingbuttraslation2.set( 0, 0, 3 );
	everythingbuttraslation2.set( 0, 1, 3 );
	everythingbuttraslation2.set( 0, 2, 3 );
	
	double[] trans1 = conc.getTranslation();
	double[] trans2 = conc2.getTranslation();
	
	everythingbuttraslation.inverse().apply( trans1, trans1 );
	everythingbuttraslation2.inverse().apply( trans2, trans2 );
	
	System.out.println( new RealPoint( trans1 ) );
	System.out.println( new RealPoint( trans2 ) );
	
	
	System.out.println( mapBackTransform( everythingbuttraslation, everythingbuttraslation2 ) );
	
	
	
	
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:56,代码来源:TransformTools.java

示例7: reCenterViews

import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
public static void reCenterViews(final BigDataViewer viewer, final Collection<BasicViewDescription< ? >> selectedViews, final ViewRegistrations viewRegistrations)
{
	AffineTransform3D currentViewerTransform = viewer.getViewer().getDisplay().getTransformEventHandler().getTransform().copy();
	final int cX = viewer.getViewer().getWidth() / 2; // size of the display area of the frame
	final int cY = viewer.getViewer().getHeight() / 2; // size of the display area of the frame

	IOFunctions.println( viewer.getViewer().getWidth() + " " + viewer.getViewer().getHeight() );

	final HashMap< BasicViewDescription< ? >, Dimensions > dimensions = new HashMap<>();
	final HashMap< BasicViewDescription< ? >, AffineTransform3D > registrations = new HashMap<>();

	for ( final BasicViewDescription< ? > view : selectedViews )
	{
		viewRegistrations.getViewRegistration( view ).updateModel();
		registrations.put( view, viewRegistrations.getViewRegistration( view ).getModel() );
		dimensions.put( view, view.getViewSetup().getSize() );
	}

	final BoundingBox bb = new BoundingBoxMaximal( selectedViews, dimensions, registrations ).estimate( "max" );
	final double[] com = new double[] {
			( bb.max( 0 ) - bb.min( 0 ) )/2 + bb.min( 0 ),
			( bb.max( 1 ) - bb.min( 1 ) )/2 + bb.min( 1 ),
			( bb.max( 2 ) - bb.min( 2 ) )/2 + bb.min( 2 ) };

	final RealInterval bounds = currentViewerTransform.estimateBounds( bb );
	IOFunctions.println( TransformTools.printRealInterval( bounds ));

	double currentScale = Math.max( 
			( bounds.realMax( 0 ) - bounds.realMin( 0 ) ) / viewer.getViewer().getWidth(),
			( bounds.realMax( 1 ) - bounds.realMin( 1 ) ) / viewer.getViewer().getHeight() );

	final Scale3D scale = new Scale3D( 1.0/currentScale, 1.0/currentScale, 1.0/currentScale );

	// ignore old translation
	currentViewerTransform.set( 0, 0, 3 );
	currentViewerTransform.set( 0, 1, 3 );
	currentViewerTransform.set( 0, 2, 3 );

	currentViewerTransform.preConcatenate( scale );

	// to screen units
	currentViewerTransform.apply( com, com );

	// reset translational part
	currentViewerTransform.set( -com[0] + cX , 0, 3 );
	currentViewerTransform.set( -com[1] + cY , 1, 3 );

	// check if all selected views are 2d
	boolean allViews2D = true;
	for (final BasicViewDescription< ? > vd : selectedViews)
		if (vd.isPresent() && vd.getViewSetup().hasSize() && vd.getViewSetup().getSize().dimension( 2 ) != 1)
		{
			allViews2D = false;
			break;
		}

	// do not move in z if we have 2d data
	if (allViews2D)
		currentViewerTransform.set( 0, 2, 3 );
	else
		currentViewerTransform.set( -com[2], 2, 3 );

	viewer.getViewer().setCurrentViewerTransform( currentViewerTransform );
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:65,代码来源:TransformationTools.java

示例8: drawViewOutlines

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

示例9: drawOverlays

import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
@Override
public void drawOverlays(Graphics g)
{
	// dont do anything if the overlay was set to inactive or we have no Tile selected (no links to display)
	if (!isActive || activeLinks.size() == 0)
		return;

	for ( Pair<Group<ViewId>, Group<ViewId>> p: activeLinks)
	{
		// local coordinates of views, without BDV transform 
		final double[] lPos1 = new double[ 3 ];
		final double[] lPos2 = new double[ 3 ];
		// global coordianates, after BDV transform
		final double[] gPos1 = new double[ 3 ];
		final double[] gPos2 = new double[ 3 ];
		
		BasicViewDescription<?> vdA = spimData.getSequenceDescription().getViewDescriptions().get( p.getA().iterator().next() );
		BasicViewDescription<?> vdB = spimData.getSequenceDescription().getViewDescriptions().get( p.getB().iterator().next() );
		ViewRegistration vrA = spimData.getViewRegistrations().getViewRegistration(  p.getA().iterator().next() );
		ViewRegistration vrB = spimData.getViewRegistrations().getViewRegistration(  p.getB().iterator().next() );

		long[] sizeA = new long[vdA.getViewSetup().getSize().numDimensions()];
		long[] sizeB = new long[vdB.getViewSetup().getSize().numDimensions()];
		spimData.getSequenceDescription().getViewDescriptions().get( p.getA().iterator().next() ).getViewSetup().getSize().dimensions( sizeA );
		spimData.getSequenceDescription().getViewDescriptions().get( p.getB().iterator().next() ).getViewSetup().getSize().dimensions( sizeB );
		
		// TODO: this uses the transform of the first view in the set, maybe do something better?
		AffineTransform3D vt1 = spimData.getViewRegistrations().getViewRegistration( p.getA().iterator().next() ).getModel();
		AffineTransform3D vt2 = spimData.getViewRegistrations().getViewRegistration( p.getB().iterator().next() ).getModel();
		
		boolean overlaps = SimpleBoundingBoxOverlap.overlaps( SimpleBoundingBoxOverlap.getBoundingBox(	vdA.getViewSetup(), vrA ), SimpleBoundingBoxOverlap.getBoundingBox( vdB.getViewSetup(), vrB ) );

		if (!overlaps)
			continue;
		
		final AffineTransform3D transform = new AffineTransform3D();
		transform.preConcatenate( viewerTransform );

		for( int i = 0; i < 3; i++)
		{
			// start from middle of view
			lPos1[i] += sizeA[i] / 2;
			lPos2[i] += sizeB[i] / 2;
		}

		vt1.apply( lPos1, lPos1 );
		vt2.apply( lPos2, lPos2 );
		
		transform.apply( lPos1, gPos1 );
		transform.apply( lPos2, gPos2 );

		Graphics2D g2d = null;

		if ( Graphics2D.class.isInstance( g ) )
			g2d = (Graphics2D) g;

		if ( lastFilteredResults.contains( p ) || lastFilteredResults.contains( TransformationTools.reversePair( p ) ) )
		{
			g.setColor( Color.ORANGE );
			if ( g2d != null ) g2d.setStroke( dashed );
		}
		else if ( lastInconsistentResults.contains( p ) || lastInconsistentResults.contains( TransformationTools.reversePair( p ) ) )
		{
			g.setColor( Color.RED );
			if ( g2d != null ) g2d.setStroke( dashed );
		}
		else if ( stitchingResults.getPairwiseResults().containsKey( p ) || stitchingResults.getPairwiseResults().containsKey( TransformationTools.reversePair( p ) ) )
		{
			g.setColor( Color.GREEN );
			if ( g2d != null ) g2d.setStroke( thick );
		}
		else
		{
			g.setColor( Color.GRAY );
			if ( g2d != null ) g2d.setStroke( dashed );
		}

		g.drawLine((int) gPos1[0],(int) gPos1[1],(int) gPos2[0],(int) gPos2[1] );
	}
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:81,代码来源:DemoLinkOverlay.java

示例10: click

import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
@Override
public void click( final int x, final int y )
{
	synchronized ( viewer )
	{
		if ( idPicker.getIdAtDisplayCoordinate( x, y ) == Label.OUTSIDE )
			return;
		final AffineTransform3D transform = new AffineTransform3D();
		viewer.getState().getViewerTransform( transform );
		final double scale = Affine3DHelpers.extractScale( transform, 0 ) * minLabelScale / Math.sqrt( 3 );
		System.out.println( labelTransform );
		final int xScale = ( int ) Math.round( x / scale );
		final int yScale = ( int ) Math.round( y / scale );
		final long[] initialMin = { xScale - 16, yScale - 16 };
		final long[] initialMax = { xScale + 15, yScale + 15 };
		viewer.setCursor( Cursor.getPredefinedCursor( Cursor.WAIT_CURSOR ) );
		setCoordinates( x, y );
		System.out.println( "Filling " + labelLocation + " with " + selectionController.getActiveFragmentId() + " (2D)" );

		final RealPoint rp = new RealPoint( 3 );
		transform.apply( labelLocation, rp );
		final Point p = new Point( xScale, yScale );

		System.out.println( x + " " + y + " " + p + " " + rp );

		final AffineTransform3D tf = labelTransform.copy();
		tf.preConcatenate( transform );
		tf.preConcatenate( new Scale3D( 1.0 / scale, 1.0 / scale, 1.0 / scale ) );

		final AffineTransform3D tfFront = tf.copy().preConcatenate( new Translation3D( 0, 0, -1.0 / Math.sqrt( 3 ) ) );
		final AffineTransform3D tfBack = tf.copy().preConcatenate( new Translation3D( 0, 0, 1.0 / Math.sqrt( 3 ) ) );

		final long t0 = System.currentTimeMillis();

		final BitType notVisited = new BitType( false );
		final BitType fillLabel = new BitType( true );

		final GrowingStoreRandomAccessibleSingletonAccess< BitType > tmpFillFront = fillMask( tfFront, initialMin, initialMax, p, notVisited.copy(), fillLabel.copy() );
		final GrowingStoreRandomAccessibleSingletonAccess< BitType > tmpFillBack = fillMask( tfBack, initialMin, initialMax, p, notVisited.copy(), fillLabel.copy() );

		final long label = selectionController.getActiveFragmentId();

		writeMask( tmpFillFront, tfFront, label );
		writeMask( tmpFillBack, tfBack, label );

		final long t1 = System.currentTimeMillis();
		System.out.println( "Filling took " + ( t1 - t0 ) + " ms" );
		System.out.println( "  modified box: " + Util.printInterval( dirtyLabelsInterval.getDirtyInterval() ) );
		viewer.setCursor( Cursor.getPredefinedCursor( Cursor.DEFAULT_CURSOR ) );
		viewer.requestRepaint();

	}
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:54,代码来源:LabelFillController.java

示例11: warpToLandmark

import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
public void warpToLandmark( int row, BigWarpViewerPanel viewer )
{
	int offset = 0;
	int ndims = landmarkModel.getNumdims();
	double[] pt = null;
	if( viewer.getIsMoving() && viewer.getOverlay().getIsTransformed() )
	{
		if ( BigWarp.this.landmarkModel.isWarped( row ) )
		{
			pt = LandmarkTableModel.toPrimitive( BigWarp.this.landmarkModel.getWarpedPoints().get( row ) );
		}
		else
		{
			offset = ndims;
		}
	}else if( !viewer.getIsMoving() )
	{
		offset = ndims;
	}

	if ( pt == null )
	{
		if ( ndims == 3 )

			pt = new double[] {
					(Double) landmarkModel.getValueAt( row, offset + 2 ),
					(Double) landmarkModel.getValueAt( row, offset + 3 ),
					(Double) landmarkModel.getValueAt( row, offset + 4 ) };
		else
			pt = new double[] {
					(Double) landmarkModel.getValueAt( row, offset + 2 ),
					(Double) landmarkModel.getValueAt( row, offset + 3 ), 0.0 };
	}

	// we have an unmatched point
	if ( Double.isInfinite( pt[ 0 ] ) )
		return;

	final AffineTransform3D transform = viewer.getDisplay().getTransformEventHandler().getTransform();
	final AffineTransform3D xfmCopy = transform.copy();
	xfmCopy.set( 0.0, 0, 3 );
	xfmCopy.set( 0.0, 1, 3 );
	xfmCopy.set( 0.0, 2, 3 );

	final double[] center = new double[] { viewer.getWidth() / 2, viewer.getHeight() / 2, 0 };
	final double[] ptxfm = new double[ 3 ];
	xfmCopy.apply( pt, ptxfm );

	// select appropriate row in the table
	landmarkTable.setRowSelectionInterval( row, row );

	// this should work fine in the 2d case
	final TranslationAnimator animator = new TranslationAnimator( transform, new double[] { center[ 0 ] - ptxfm[ 0 ], center[ 1 ] - ptxfm[ 1 ], -ptxfm[ 2 ] }, 300 );
	viewer.setTransformAnimator( animator );
	viewer.transformChanged( transform );
}
 
开发者ID:saalfeldlab,项目名称:bigwarp,代码行数:57,代码来源:BigWarp.java

示例12: setMaskXfm

import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
/**
	 *  Samples a patch of size N^d where d is the dimensionality of the 
	 *  source image src. The input transformation maps the x- and y-axes 
	 *  to the axes of the sampling plane and is typically determined by 
	 *  the {@link pickTransformation} method.
	 * 
	 *
	 * @param basepos point
	 * @param N size of a dimension of the output patch
	 * @param xfm transformation
	 * @param src source image
	 * @return 
	 */
	public static <L extends NumericType<L>> void setMaskXfm(double[] basepos, int[] patchSize,  
			AffineTransform3D xfmIn,  RandomAccessible<L> src, L val ){
		
		AffineTransform3D xfm = xfmIn.copy();
		
		RandomAccess<L> ra = src.randomAccess();
//		ra.setPosition(position);
		
		int ndims_in  = src.numDimensions();
		
		logger.debug(" basepos  :" + ArrayUtil.printArray( basepos ) );
		logger.debug(" out size :" + ArrayUtil.printArray( patchSize ) );

		double[]  pos	= new double[ndims_in];
		double[] dpos	= new double[ndims_in];
		
		// determine translation
		double[] midPt = ArrayUtil.toDouble(patchSize);
		ArrayUtil.addInPlace(midPt, -1);
		ArrayUtil.divide(midPt, 2);
		logger.debug(" midPt :" + ArrayUtil.printArray( midPt ) );
		
		double[] target = new double[ndims_in];
		
		xfm.apply(midPt, target);
		double[] diff = ArrayUtil.subtract( basepos, target );
		
		logger.debug(" diff  :" + ArrayUtil.printArray( diff ) );
		
		for( int i=0; i<ndims_in; i++ ){
			xfm.set( diff[i], i, ndims_in);
		}

		IntervalIterator iter = new IntervalIterator(patchSize);
		while(iter.hasNext()){
			
			iter.fwd();
			iter.localize(pos);
			
			xfm.apply( pos, dpos);
			int[] pt = ArrayUtil.toIntRound(dpos);
			logger.trace(" pt :" + ArrayUtil.printArray( pt ) );
			
			ra.setPosition(pt);
			ra.get().set(val);
		}
	}
 
开发者ID:bogovicj,项目名称:hhmi-exp,代码行数:61,代码来源:CrackCorrection.java

示例13: main

import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
public static void main(String[] args){
	
	double[] u = new double[]{ 0.245, -0.563, -0.055 };
	double[] v = new double[]{ 0.3,   -0.5,    0.2   };
	
	AffineTransform3D mtx = rotation(u,v);
	
	System.out.println("mtx: " + mtx);
	
	double[] uXfm = new double[3];
	mtx.apply(u, uXfm);
	
	System.out.println("u   : " + ArrayUtil.printArray(u));
	System.out.println("uXfm: " + ArrayUtil.printArray(uXfm));
	
}
 
开发者ID:bogovicj,项目名称:hhmi-exp,代码行数:17,代码来源:RodriguesRotation.java

示例14: getInterestPoints

import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
/**
 * Creates lists of input points for the registration, based on the current transformation of the views
 * 
 * Note: this always duplicates the location array from the input List&gt; InterestPoint &lt; !!!
 * 
 * @param timepoint
 */
protected HashMap< ViewId, MatchPointList > getInterestPoints( final TimePoint timepoint )
{
	final HashMap< ViewId, MatchPointList > interestPoints = new HashMap< ViewId, MatchPointList >();
	final ViewRegistrations registrations = spimData.getViewRegistrations();
	final ViewInterestPoints interestpoints = spimData.getViewInterestPoints();
	
	for ( final ViewDescription vd : SpimData2.getAllViewIdsForTimePointSorted( spimData, viewIdsToProcess, timepoint) )
	{
		if ( !vd.isPresent() )
			continue;

		final ChannelProcess c = getChannelProcessForChannel( channelsToProcess, vd.getViewSetup().getChannel() );

		// no registration for this viewdescription
		if ( c == null )
			continue;

		final Angle a = vd.getViewSetup().getAngle();
		final Illumination i = vd.getViewSetup().getIllumination();

		// assemble a new list
		final ArrayList< InterestPoint > list = new ArrayList< InterestPoint >();

		// check the existing lists of points
		final ViewInterestPointLists lists = interestpoints.getViewInterestPointLists( vd );

		if ( !lists.contains( c.getLabel() ) )
		{
			IOFunctions.println( "Interest points for label '" + c.getLabel() + "' not found for timepoint: " + timepoint.getId() + " angle: " + 
					a.getId() + " channel: " + c.getChannel().getId() + " illum: " + i.getId() );
			
			continue;
		}
		
		if ( lists.getInterestPointList( c.getLabel() ).getInterestPoints() == null )
		{
			if ( !lists.getInterestPointList( c.getLabel() ).loadInterestPoints() )
			{
				IOFunctions.println( "Interest points for label '" + c.getLabel() + "' could not be loaded for timepoint: " + timepoint.getId() + " angle: " + 
						a.getId() + " channel: " + c.getChannel().getId() + " illum: " + i.getId() );
				
				continue;
			}
		}
		
		final List< InterestPoint > ptList = lists.getInterestPointList( c.getLabel() ).getInterestPoints();
		
		final ViewRegistration r = registrations.getViewRegistration( vd );
		r.updateModel();
		final AffineTransform3D m = r.getModel();
		
		for ( final InterestPoint p : ptList )
		{
			final double[] l = new double[ 3 ];
			m.apply( p.getL(), l );
			
			list.add( new InterestPoint( p.getId(), l ) );
		}
		
		interestPoints.put( vd, new MatchPointList( list, c ) );
	}

	return interestPoints;
}
 
开发者ID:fiji,项目名称:SPIM_Registration,代码行数:72,代码来源:GlobalOptimizationType.java

示例15: transformPSF

import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
/**
 * Transforms the extracted PSF using the affine transformation of the corresponding view
 * 
 * @param psf - the extracted psf (NOT z-scaling corrected)
 * @param model - the transformation model
 * @return the transformed psf which has odd sizes and where the center of the psf is also the center of the transformed psf
 */
protected static < T extends RealType< T > & NativeType< T > > ArrayImg< T, ? > transformPSF(
		final RandomAccessibleInterval< T > psf,
		final AffineTransform3D model )
{
	// here we compute a slightly different transformation than the ImageTransform does
	// two things are necessary:
	// a) the center pixel stays the center pixel
	// b) the transformed psf has a odd size in all dimensions
	
	final int numDimensions = psf.numDimensions();
	
	final RealInterval minMaxDim = model.estimateBounds( psf );
	
	final double[] size = new double[ numDimensions ];		
	final long[] newSize = new long[ numDimensions ];		
	final double[] offset = new double[ numDimensions ];
	
	// the center of the psf has to be the center of the transformed psf as well
	// this is important!
	final double[] center = new double[ numDimensions ];
	final double[] tmp = new double[ numDimensions ];

	for ( int d = 0; d < numDimensions; ++d )
		center[ d ] = psf.dimension( d ) / 2;
	
	model.apply( center, tmp );

	for ( int d = 0; d < numDimensions; ++d )
	{
		size[ d ] = minMaxDim.realMax( d ) - minMaxDim.realMin( d );
		
		newSize[ d ] = (int)size[ d ] + 1;
		if ( newSize[ d ] % 2 == 0 )
			++newSize[ d ];
			
		// the offset is defined like this:
		// the transformed coordinates of the center of the psf
		// are the center of the transformed psf
		offset[ d ] = tmp[ d ] - newSize[ d ]/2;
	}
	
	return transform( psf, model, newSize, offset );
}
 
开发者ID:fiji,项目名称:SPIM_Registration,代码行数:51,代码来源:ExtractPSF.java


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