private static float[] getStepSize( final AffineTransform3D model ) { final float[] size = new float[ 3 ]; final double[] tmp = new double[ 3 ]; final double[] o0 = new double[ 3 ]; model.apply( tmp, o0 ); for ( int d = 0; d < 3; ++d ) { final double[] o1 = new double[ 3 ]; for ( int i = 0; i < tmp.length; ++i ) tmp[ i ] = 0; tmp[ d ] = 1; model.apply( tmp, o1 ); size[ d ] = (float)length( o1, o0 ); } return size; }
public static List< InterestPoint > applyTransformation( final List< InterestPoint > list, final AffineTransform3D m ) { final ArrayList< InterestPoint > transformedList = new ArrayList< InterestPoint >(); for ( final InterestPoint p : list ) { final double[] l = new double[ 3 ]; m.apply( p.getL(), l ); transformedList.add( new InterestPoint( p.getId(), l ) ); } return transformedList; }
transform.apply( p, pt ); transformed.add( pt );
public static void correctForDownsampling( final List< InterestPoint > ips, final AffineTransform3D t ) { IOFunctions.println("(" + new Date(System.currentTimeMillis()) + "): Correcting coordinates for downsampling 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 ]; } }
/** * Get the transformed vector in screen coordinate when moving by * cellStep[0] in X direction. */ private void getXStep( final int[] cellStep, final AffineTransform3D sourceToScreen ) { final RealPoint p0 = new RealPoint( 3 ); final RealPoint p1 = new RealPoint( 3 ); p1.setPosition( cellStep[ 0 ], 0 ); final RealPoint s0 = new RealPoint( 3 ); final RealPoint s1 = new RealPoint( 3 ); sourceToScreen.apply( p0, s0 ); sourceToScreen.apply( p1, s1 ); for ( int d = 0; d < 3; ++d ) xStep[ d ] = s1.getDoublePosition( d ) - s0.getDoublePosition( d ); }
@Override protected void draw( final Graphics2D graphics ) { if ( points == null ) return; col = new Color( info.getColor().get() ); final AffineTransform3D transform = new AffineTransform3D(); getCurrentTransform3D( transform ); final double[] lPos = new double[ 3 ]; final double[] gPos = new double[ 3 ]; for ( final RealLocalizable p : points ) { 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 ); } }
@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 ) { final HashMap< ? extends ViewId, ? extends Collection< ? extends RealLocalizable > > coordinates = pointSource.getLocalCoordinates( t ); for ( final ViewId viewId : coordinates.keySet() ) { pointSource.getLocalToGlobalTransform( viewId, t, transform ); transform.preConcatenate( viewerTransform ); for ( final RealLocalizable p : coordinates.get( viewId ) ) { 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 ); } } } }
mapBackViewRegistration.apply( p[ i ], pa[ i ] );
public static RealInterval transformBoundingBoxReal( final RealInterval sourceInterval, final AffineTransform3D transform ) { final double[] bbMin = new double[] { Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY }; final double[] bbMax = new double[] { Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY }; final double[] min = new double[ 3 ]; final double[] max = new double[ 3 ]; final RealPoint sourceCorner = new RealPoint( 3 ); final RealPoint globalCorner = new RealPoint( 3 ); sourceInterval.realMin( min ); sourceInterval.realMax( max ); for ( int i = 0; i < 8; ++i ) { for ( int d = 0; d < 3; ++d ) { final double p = ( i & ( 1 << d ) ) == 0 ? min[ d ] : max[ d ]; sourceCorner.setPosition( p, d ); } transform.apply( sourceCorner, globalCorner ); for ( int d = 0; d < 3; ++d ) { final double p = globalCorner.getDoublePosition( d ); if ( p < bbMin[ d ] ) bbMin[ d ] = p; if ( p > bbMax[ d ] ) bbMax[ d ] = p; } } return new FinalRealInterval( bbMin, bbMax ); } }
center[ d ] = psf.dimension( d ) / 2; model.apply( center, tmp );
final double[] centerGlobal = new double[ 3 ]; final double[] translation = new double[ 3 ]; sourceTransform.apply( centerSource, centerGlobal ); LinAlgHelpers.quaternionApply( qViewer, centerGlobal, translation ); LinAlgHelpers.scale( translation, -1, translation ); final double[] pGlobal = new double[ 3 ]; final double[] pScreen = new double[ 3 ]; sourceTransform.apply( pSource, pGlobal ); viewerTransform.apply( pGlobal, pScreen ); final double scaleX = cX / pScreen[ 0 ]; final double scaleY = cY / pScreen[ 1 ];
sourceCorner.setPosition( p, d ); sourceTransform.apply( sourceCorner, globalCorner ); for ( int d = 0; d < 3; ++d )
sourceCorner.setPosition( p, d ); sourceTransform.apply( sourceCorner, globalCorner ); for ( int d = 0; d < 3; ++d )
cropToSource.apply( corner, sourceCorner ); sourceCorners.add( sourceCorner );
transform.apply( tmp1, tmp2 );
currentViewerTransform.apply( com, com );