Guest User

Untitled

a guest
Jun 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. def procrustes_analysis(reference_shape, shape):
  2. '''
  3. Scales, and rotates a shape optimally to
  4. be aligned with a reference shape
  5. Args:
  6. reference_shape(2nx1 NumPy array), a shape that
  7. serves as reference alignment
  8.  
  9. shape(2nx1 NumPy array), a shape that is aligned
  10.  
  11. Returns:
  12. aligned_shape(2nx1 NumPy array), an aligned shape
  13. translated to the location of reference shape
  14. '''
  15. #copy both shapes in caseoriginals are needed later
  16. temp_ref = np.copy(reference_shape)
  17. temp_sh = np.copy(shape)
  18.  
  19. translate(temp_ref)
  20. translate(temp_sh)
  21.  
  22. #get scale and rotation
  23. scale, theta = get_rotation_scale(temp_ref, temp_sh)
  24.  
  25. #scale, rotate both shapes
  26. temp_sh = temp_sh / scale
  27. aligned_shape = rotate(temp_sh, theta)
  28.  
  29. return aligned_shape
Add Comment
Please, Sign In to add comment