@Override public void apply( final double[] source, final double[] target ) { tps.apply( source, target ); }
/** * Transform pt in place. * * @param pt the point */ public void applyInPlace( final double[] pt ) { final double[] tmp = new double[ ndims ]; apply( pt, tmp ); for ( int i = 0; i < ndims; ++i ) { pt[ i ] = tmp[ i ]; } }
public void apply( final double[] pt, final double[] result ) { apply( pt, result, false ); }
/** * Transforms the input point according to the thin plate spline stored by * this object. * * @param pt the point to be transformed * @return the transformed point */ public double[] apply( final double[] pt ) { final double[] result = new double[ ndims ]; apply( pt, result ); return result; }
/** * Computes the displacement between the i^th source point and the input * point. * * Stores the result in the input array 'res'. Does not validate inputs. * * @param i first index * @param pt the point * @param res the result */ protected void tgtPtDisplacement( final int i, final double[] pt, final double[] res ) { apply( pt, res ); for ( int d = 0; d < ndims; d++ ) { res[ d ]-= pt[ d ]; } }
public void printXfmBacks2d( final int maxx, final int maxy, final int delx, final int dely ) { final double[] pt = new double[ 2 ]; final double[] result = new double[ 2 ]; for ( int x = 0; x < maxx; x += delx ) for ( int y = 0; y < maxy; y += dely ) { pt[ 0 ] = x; pt[ 1 ] = y; this.apply( pt, result ); System.out.println( "( " + x + ", " + y + " ) -> ( " + result[ 0 ] + ", " + result[ 0 ] + " )" ); } }
public static double maxError( double[][] sourcePoints, double[][] targetPoints, ThinPlateR2LogRSplineKernelTransform xfm, boolean debug ) { double maxError = 0.0; int D = sourcePoints.length; int N = sourcePoints[ 0 ].length; double[] spt = new double[ sourcePoints.length ]; double[] tpt = new double[ sourcePoints.length ]; for( int i = 0; i < N; i++ ) { for( int n = 0; n < D; n++ ) { spt[ n ] = sourcePoints[ n ][ i ]; tpt[ n ] = targetPoints[ n ][ i ]; } double[] result = xfm.apply( spt ); double distance = distance( tpt, result ); if( debug ) System.out.println( "distance at: " + i + " is " + distance ); if( distance > maxError ) maxError = distance; } return maxError; }
@Override public void apply( final RealLocalizable source, final RealPositionable target ) { rpa.setPosition( source ); tps.apply( a, b ); for ( int d = 0; d < a.length; ++d ) target.setPosition( b[ d ], d ); }
double[] phix_ap = xfm.apply( x_ap );