Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 7daffe2e authored by INGELS Florian's avatar INGELS Florian
Browse files

Added hellinger distance between transformations

parent f7f84db6
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ from visu_core.vtk.actor import vtk_actor ...@@ -8,7 +8,7 @@ from visu_core.vtk.actor import vtk_actor
from visu_core.vtk.polydata import face_scalar_property_polydata from visu_core.vtk.polydata import face_scalar_property_polydata
from scipy.spatial.transform import Rotation as R from scipy.spatial.transform import Rotation as R
from scipy.linalg import svd, inv from scipy.linalg import svd, inv, det
from scipy.stats import chi2 from scipy.stats import chi2
class AffineTransform(object): class AffineTransform(object):
...@@ -194,4 +194,12 @@ def random_transform(translation=True,scale=True,rotation=True): ...@@ -194,4 +194,12 @@ def random_transform(translation=True,scale=True,rotation=True):
tf.set_parameters(t,rot.as_matrix() @ np.diag(s)) tf.set_parameters(t,rot.as_matrix() @ np.diag(s))
return tf return tf
#-----------------------------------------------------# #-----------------------------------------------------#
\ No newline at end of file
def hellinger_distance(tf1,tf2):
t1 = tf1.translation
t2 = tf2.translation
sig1 = tf1.get_covariance_matrix()
sig2 = tf2.get_covariance_matrix()
sigm = (sig1+sig2)/2
return 1 - (det(sig1)*det(sig2))**(1/4) / det(sigm)**(1/2)*np.exp((-1/8) * np.transpose(t1 - t2) @ inv(sigm) @ (t1 - t2))
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment