diff --git a/bob/bio/vein/algorithm/HammingDistance.py b/bob/bio/vein/algorithm/HammingDistance.py index cfa5c2968bc69ffe8b69507807577a4f11784e7e..ac1446db835079ea699322572df2b5a1959315e3 100644 --- a/bob/bio/vein/algorithm/HammingDistance.py +++ b/bob/bio/vein/algorithm/HammingDistance.py @@ -3,35 +3,32 @@ from bob.bio.base.algorithm import Distance -import scipy.spatial.distance class HammingDistance (Distance): """This class calculates the Hamming distance between two binary images. - Each binary image is first flattened by concatenating its rows to form a one-dimensional vector. The Hamming distance is then calculated between the two binary vectors. - The Hamming distance is computed using :py:func:`scipy.spatial.distance.hamming`, which returns a scalar ``float`` to represent the proportion of mismatching corresponding bits between the two binary vectors. + The enrollement and scoring functions of this class are implemented by its + base :py:class:`bob.bio.base.algorithm.Distance`. - **Parameters:** + The input to this function should be of binary nature (boolean arrays). Each + binary input is first flattened to form a one-dimensional vector. The `Hamming + distance `_ is then + calculated between these two binary vectors. - ``distance_function`` : function - Set this parameter to ``scipy.spatial.distance.hamming`` to ensure we are calculating the Hamming distance + The current implementation uses :py:func:`scipy.spatial.distance.hamming`, + which returns a scalar 64-bit ``float`` to represent the proportion of + mismatching corresponding bits between the two binary vectors. - ``is_distance_function`` : bool - Set this flag to ``False`` to ensure that Hamming distances are returned as positive values rather than negative + The base clas constructor parameter ``is_distance_function`` is set to + ``False`` on purpose to ensure that calculated distances are returned as + positive values rather than negative. """ - - def __init__( - self, - distance_function = scipy.spatial.distance.hamming, - is_distance_function = False # setting this to False ensures that Hamming distances are returned as positive values rather than negative - ): - - # Call base class constructor - Distance.__init__( - self, - distance_function = distance_function, - is_distance_function = is_distance_function - ) \ No newline at end of file + def __init__(self): + from scipy.spatial.distance import hamming + super(HammingDistance, self).__init__( + distance_function = hamming, + is_distance_function = False, + ) diff --git a/bob/bio/vein/algorithm/__init__.py b/bob/bio/vein/algorithm/__init__.py index 793f107a27ff326af7608be8a189077a39c25ab7..e69a1e60d539aec619339c40178f8de535573ada 100644 --- a/bob/bio/vein/algorithm/__init__.py +++ b/bob/bio/vein/algorithm/__init__.py @@ -1,5 +1,4 @@ from .MiuraMatch import MiuraMatch -from .MiuraMatchRotationFast import MiuraMatchRotationFast from .Correlate import Correlate from .HammingDistance import HammingDistance @@ -19,7 +18,6 @@ def __appropriate__(*args): __appropriate__( MiuraMatch, - MiuraMatchRotationFast, Correlate, HammingDistance, )