diff --git a/TPS/TPSCy/TPSCy.pyx b/TPS/TPSCy/TPSCy.pyx index feee5bc096c803f01ede7a4931391ec0c1eac76d..7dc059eb22c65c5d117928967e1f3f0ea2236108 100644 --- a/TPS/TPSCy/TPSCy.pyx +++ b/TPS/TPSCy/TPSCy.pyx @@ -248,12 +248,15 @@ def generate( cdef double * W = < double * > malloc( n * 2 * sizeof( double ) ) cdef double * linear = < double * > malloc( 3 * 2 * sizeof( double ) ) cdef double * be = < double * > malloc( 1 * sizeof( double ) ) + cdef double * scale = < double * > malloc( 1 * sizeof( double ) ) _generate( src, dst, # input variables W, linear, be # output storage ) + scale[ 0 ] = sqrt( ( linear[ 2 ] * linear[ 5 ] ) - ( linear[ 3 ] * linear[ 4 ] ) ) + ############################################################################ # # Python object return @@ -264,6 +267,7 @@ def generate( 'src': np.asarray( src ), 'dst': np.asarray( dst ), 'linear': np.array( < double [ :3, :2 ] > linear ), + 'scale': scale[ 0 ], 'weights': np.array( < double [ :n, :2 ] > W ), 'be': be[ 0 ], } diff --git a/TPS/TPSpy.py b/TPS/TPSpy.py index 4f5187bf6ba10e807c411754fd46de849e14cf58..74ef9698d1db5db3ab18d6adbb238f9d0c5a1352 100644 --- a/TPS/TPSpy.py +++ b/TPS/TPSpy.py @@ -78,6 +78,8 @@ def generate( src, dst ): W = Wa[ :-3 , : ] a = Wa[ -3: , : ] + s = np.sqrt( np.linalg.det( Wa[ -2: , : ] ) ) + WK = np.dot( W.T, K ) WKW = np.dot( WK, W ) @@ -87,6 +89,7 @@ def generate( src, dst ): 'src': src, 'dst': dst, 'linear': a, + 'scale': s, 'weights': W, 'be': be }