diff --git a/bob/bio/vein/extractor/MaximumCurvature.py b/bob/bio/vein/extractor/MaximumCurvature.py index e7627167b0e0eee40263907eb72f6bef3539e7a9..0d891cfd1fe43e984d48707b901f114dcaa36141 100644 --- a/bob/bio/vein/extractor/MaximumCurvature.py +++ b/bob/bio/vein/extractor/MaximumCurvature.py @@ -36,10 +36,6 @@ class MaximumCurvature (Extractor): """Computes and returns the Maximum Curvature features for the given input fingervein image""" - if image.dtype != numpy.uint8: - image = bob.core.convert(image,numpy.uint8,(0,255),(0,1)) - #No es necesario pasarlo a uint8, en matlab lo dejan en float64. Comprobar si varian los resultados en vera database y ajustar. - finger_mask = numpy.zeros(mask.shape) finger_mask[mask == True] = 1 diff --git a/bob/bio/vein/extractor/RepeatedLineTracking.py b/bob/bio/vein/extractor/RepeatedLineTracking.py index 84074aff73c3760795626b6e516f00aff9a1fcef..5b9d4ab1a2cf8a434b6edd5303f0701aa39e4e9d 100644 --- a/bob/bio/vein/extractor/RepeatedLineTracking.py +++ b/bob/bio/vein/extractor/RepeatedLineTracking.py @@ -55,10 +55,6 @@ class RepeatedLineTracking (Extractor): # Sets the random seed before starting to process numpy.random.seed(self.seed) - #Convert image to uint8 - if finger_image.dtype != numpy.uint8: - finger_image = bob.core.convert(finger_image,numpy.uint8,(0,255),(0,1)) - finger_mask = numpy.zeros(mask.shape) finger_mask[mask == True] = 1 diff --git a/bob/bio/vein/tests/test.py b/bob/bio/vein/tests/test.py index ab9b76f9c6c3adddcba10568226bf8a4bd242766..a43ca7bddf50cd29b80a37a6ad3e54c052847e30 100644 --- a/bob/bio/vein/tests/test.py +++ b/bob/bio/vein/tests/test.py @@ -30,7 +30,7 @@ def F(parts): """Returns the test file path""" return pkg_resources.resource_filename(__name__, os.path.join(*parts)) - + def test_finger_crop(): @@ -44,7 +44,6 @@ def test_finger_crop(): from bob.bio.vein.preprocessor.FingerCrop import FingerCrop preprocess = FingerCrop(fingercontour='leemaskMatlab', padding_width=0) - preproc, mask = preprocess(img) #preprocessor_utils.show_mask_over_image(preproc, mask) @@ -84,6 +83,24 @@ def test_max_curvature(): assert numpy.mean(numpy.abs(output_img - output_img_ref)) < 8e-3 +def test_max_curvature_HE(): + # Maximum Curvature method when Histogram Equalization post-processing is applied to the preprocessed vein image + + # Read in input image + input_img_filename = F(('preprocessors', '0019_3_1_120509-160517.png')) + input_img = bob.io.base.load(input_img_filename) + + # Preprocess the data and apply Histogram Equalization postprocessing (same parameters as in maximum_curvature.py configuration file + postprocessing) + from bob.bio.vein.preprocessor.FingerCrop import FingerCrop + FC = FingerCrop(postprocessing = 'HE') + preproc_data = FC(input_img) + + # Extract features from preprocessed and histogram equalized data using MC extractor (same parameters as in maximum_curvature.py configuration file) + from bob.bio.vein.extractor.MaximumCurvature import MaximumCurvature + MC = MaximumCurvature(sigma = 5) + extr_data = MC(preproc_data) + + def test_repeated_line_tracking(): #Repeated Line Tracking method against Matlab reference @@ -109,6 +126,30 @@ def test_repeated_line_tracking(): assert numpy.mean(numpy.abs(output_img - output_img_ref)) < 0.5 +def test_repeated_line_tracking_HE(): + # Repeated Line Tracking method when Histogram Equalization post-processing is applied to the preprocessed vein image + + # Read in input image + input_img_filename = F(('preprocessors', '0019_3_1_120509-160517.png')) + input_img = bob.io.base.load(input_img_filename) + + # Preprocess the data and apply Histogram Equalization postprocessing (same parameters as in repeated_line_tracking.py configuration file + postprocessing) + from bob.bio.vein.preprocessor.FingerCrop import FingerCrop + FC = FingerCrop(postprocessing = 'HE') + preproc_data = FC(input_img) + + # Extract features from preprocessed and histogram equalized data using RLT extractor (same parameters as in repeated_line_tracking.py configuration file) + from bob.bio.vein.extractor.RepeatedLineTracking import RepeatedLineTracking + # Maximum number of iterations + NUMBER_ITERATIONS = 3000 + # Distance between tracking point and cross section of profile + DISTANCE_R = 1 + # Width of profile + PROFILE_WIDTH = 21 + RLT = RepeatedLineTracking(iterations = NUMBER_ITERATIONS, r = DISTANCE_R, profile_w = PROFILE_WIDTH, seed = 0) + extr_data = RLT(preproc_data) + + def test_wide_line_detector(): #Wide Line Detector method against Matlab reference @@ -133,6 +174,30 @@ def test_wide_line_detector(): assert numpy.allclose(output_img, output_img_ref) +def test_wide_line_detector_HE(): + # Wide Line Detector method when Histogram Equalization post-processing is applied to the preprocessed vein image + + # Read in input image + input_img_filename = F(('preprocessors', '0019_3_1_120509-160517.png')) + input_img = bob.io.base.load(input_img_filename) + + # Preprocess the data and apply Histogram Equalization postprocessing (same parameters as in wide_line_detector.py configuration file + postprocessing) + from bob.bio.vein.preprocessor.FingerCrop import FingerCrop + FC = FingerCrop(postprocessing = 'HE') + preproc_data = FC(input_img) + + # Extract features from preprocessed and histogram equalized data using WLD extractor (same parameters as in wide_line_detector.py configuration file) + from bob.bio.vein.extractor.WideLineDetector import WideLineDetector + # Radius of the circular neighbourhood region + RADIUS_NEIGHBOURHOOD_REGION = 5 + NEIGHBOURHOOD_THRESHOLD = 1 + # Sum of neigbourhood threshold + SUM_NEIGHBOURHOOD = 41 + RESCALE = True + WLD = WideLineDetector(radius = RADIUS_NEIGHBOURHOOD_REGION, threshold = NEIGHBOURHOOD_THRESHOLD, g = SUM_NEIGHBOURHOOD, rescale = RESCALE) + extr_data = WLD(preproc_data) + + def test_miura_match(): #Match Ratio method against Matlab reference