From 059807745e705a28d78d1b57abdf15470eb11c6e Mon Sep 17 00:00:00 2001
From: Andre Anjos <andre.anjos@idiap.ch>
Date: Fri, 6 Oct 2017 09:13:51 +0200
Subject: [PATCH] Set better defaults and use them on stock configuration

---
 bob/bio/vein/algorithm/MiuraMatch.py          |  4 +--
 .../vein/configurations/maximum_curvature.py  | 22 ++++--------
 .../configurations/repeated_line_tracking.py  | 34 +++----------------
 .../vein/configurations/wide_line_detector.py | 33 +++---------------
 bob/bio/vein/preprocessor/mask.py             |  6 ++--
 5 files changed, 21 insertions(+), 78 deletions(-)

diff --git a/bob/bio/vein/algorithm/MiuraMatch.py b/bob/bio/vein/algorithm/MiuraMatch.py
index 3e9741f..b5ade61 100644
--- a/bob/bio/vein/algorithm/MiuraMatch.py
+++ b/bob/bio/vein/algorithm/MiuraMatch.py
@@ -47,8 +47,8 @@ class MiuraMatch (Algorithm):
   """
 
   def __init__(self,
-      ch = 8,       # Maximum search displacement in y-direction
-      cw = 5,       # Maximum search displacement in x-direction
+      ch = 80,       # Maximum search displacement in y-direction
+      cw = 90,       # Maximum search displacement in x-direction
       ):
 
     # call base class constructor
diff --git a/bob/bio/vein/configurations/maximum_curvature.py b/bob/bio/vein/configurations/maximum_curvature.py
index a7ce8f9..3bee726 100644
--- a/bob/bio/vein/configurations/maximum_curvature.py
+++ b/bob/bio/vein/configurations/maximum_curvature.py
@@ -20,30 +20,20 @@ or the attribute ``sub_directory`` in a configuration file loaded **after**
 this resource.
 """
 
-from ..preprocessor import NoCrop, Padder, TomesLeeMask, \
-    HuangNormalization, NoFilter, Preprocessor
-
-# Filter sizes for the vertical "high-pass" filter
-FILTER_HEIGHT = 4
-FILTER_WIDTH = 40
-
-# Padding (to create a buffer during normalization)
-PAD_WIDTH = 5
-PAD_CONST = 51
+from ..preprocessor import NoCrop, TomesLeeMask, HuangNormalization, \
+    NoFilter, Preprocessor
 
 preprocessor = Preprocessor(
     crop=NoCrop(),
-    mask=TomesLeeMask(filter_height=FILTER_HEIGHT, filter_width=FILTER_WIDTH,
-      padder=Padder(padding_width=PAD_WIDTH, padding_constant=PAD_CONST)),
-    normalize=HuangNormalization(padding_width=PAD_WIDTH,
-      padding_constant=PAD_CONST),
+    mask=TomesLeeMask(),
+    normalize=HuangNormalization(),
     filter=NoFilter(),
     )
 """Preprocessing using gray-level based finger cropping and no post-processing
 """
 
 from ..extractor import MaximumCurvature
-extractor = MaximumCurvature(sigma = 5)
+extractor = MaximumCurvature()
 """Features are the output of the maximum curvature algorithm, as described on
 [MNM05]_.
 
@@ -53,7 +43,7 @@ Defaults taken from [TV13]_.
 # Notice the values of ch and cw are different than those from the
 # repeated-line tracking baseline.
 from ..algorithm import MiuraMatch
-algorithm = MiuraMatch(ch=80, cw=90)
+algorithm = MiuraMatch()
 """Miura-matching algorithm with specific settings for search displacement
 
 Defaults taken from [TV13]_.
diff --git a/bob/bio/vein/configurations/repeated_line_tracking.py b/bob/bio/vein/configurations/repeated_line_tracking.py
index a2f1e45..55702ef 100644
--- a/bob/bio/vein/configurations/repeated_line_tracking.py
+++ b/bob/bio/vein/configurations/repeated_line_tracking.py
@@ -20,23 +20,13 @@ or the attribute ``sub_directory`` in a configuration file loaded **after**
 this resource.
 """
 
-from ..preprocessor import NoCrop, Padder, TomesLeeMask, \
-    HuangNormalization, NoFilter, Preprocessor
-
-# Filter sizes for the vertical "high-pass" filter
-FILTER_HEIGHT = 4
-FILTER_WIDTH = 40
-
-# Padding (to create a buffer during normalization)
-PAD_WIDTH = 5
-PAD_CONST = 51
+from ..preprocessor import NoCrop, TomesLeeMask, HuangNormalization, \
+    NoFilter, Preprocessor
 
 preprocessor = Preprocessor(
     crop=NoCrop(),
-    mask=TomesLeeMask(filter_height=FILTER_HEIGHT, filter_width=FILTER_WIDTH,
-      padder=Padder(padding_width=PAD_WIDTH, padding_constant=PAD_CONST)),
-    normalize=HuangNormalization(padding_width=PAD_WIDTH,
-      padding_constant=PAD_CONST),
+    mask=TomesLeeMask(),
+    normalize=HuangNormalization(),
     filter=NoFilter(),
     )
 """Preprocessing using gray-level based finger cropping and no post-processing
@@ -44,21 +34,7 @@ preprocessor = Preprocessor(
 
 from ..extractor 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
-
-extractor = RepeatedLineTracking(
-    iterations=NUMBER_ITERATIONS,
-    r=DISTANCE_R,
-    profile_w=PROFILE_WIDTH,
-    seed=0, #Sets numpy.random.seed() to this value
-    )
+extractor = RepeatedLineTracking()
 """Features are the output of repeated-line tracking, as described on [MNM04]_.
 
 Defaults taken from [TV13]_.
diff --git a/bob/bio/vein/configurations/wide_line_detector.py b/bob/bio/vein/configurations/wide_line_detector.py
index 0fe8e69..8b2662c 100644
--- a/bob/bio/vein/configurations/wide_line_detector.py
+++ b/bob/bio/vein/configurations/wide_line_detector.py
@@ -20,23 +20,13 @@ or the attribute ``sub_directory`` in a configuration file loaded **after**
 this resource.
 """
 
-from ..preprocessor import NoCrop, Padder, TomesLeeMask, \
-    HuangNormalization, NoFilter, Preprocessor
-
-# Filter sizes for the vertical "high-pass" filter
-FILTER_HEIGHT = 4
-FILTER_WIDTH = 40
-
-# Padding (to create a buffer during normalization)
-PAD_WIDTH = 5
-PAD_CONST = 51
+from ..preprocessor import NoCrop, TomesLeeMask, HuangNormalization, \
+    NoFilter, Preprocessor
 
 preprocessor = Preprocessor(
     crop=NoCrop(),
-    mask=TomesLeeMask(filter_height=FILTER_HEIGHT, filter_width=FILTER_WIDTH,
-      padder=Padder(padding_width=PAD_WIDTH, padding_constant=PAD_CONST)),
-    normalize=HuangNormalization(padding_width=PAD_WIDTH,
-      padding_constant=PAD_CONST),
+    mask=TomesLeeMask(),
+    normalize=HuangNormalization(),
     filter=NoFilter(),
     )
 """Preprocessing using gray-level based finger cropping and no post-processing
@@ -44,20 +34,7 @@ preprocessor = Preprocessor(
 
 from ..extractor import WideLineDetector
 
-# Radius of the circular neighbourhood region
-RADIUS_NEIGHBOURHOOD_REGION = 5
-NEIGHBOURHOOD_THRESHOLD = 1
-
-#Sum of neigbourhood threshold
-SUM_NEIGHBOURHOOD = 41
-RESCALE = True
-
-extractor = WideLineDetector(
-    radius=RADIUS_NEIGHBOURHOOD_REGION,
-    threshold=NEIGHBOURHOOD_THRESHOLD,
-    g=SUM_NEIGHBOURHOOD,
-    rescale=RESCALE
-    )
+extractor = WideLineDetector()
 """Features are the output of the maximum curvature algorithm, as described on
 [HDLTL10]_.
 
diff --git a/bob/bio/vein/preprocessor/mask.py b/bob/bio/vein/preprocessor/mask.py
index a3d40e1..7c449ae 100644
--- a/bob/bio/vein/preprocessor/mask.py
+++ b/bob/bio/vein/preprocessor/mask.py
@@ -213,7 +213,7 @@ class KonoMask(Masker):
 
   """
 
-  def __init__(self, sigma=5, padder=None):
+  def __init__(self, sigma=5, padder=Padder()):
 
     self.sigma = sigma
     self.padder = padder
@@ -314,7 +314,7 @@ class LeeMask(Masker):
 
   """
 
-  def __init__(self, filter_height = 4, filter_width = 40, padder=None):
+  def __init__(self, filter_height = 4, filter_width = 40, padder=Padder()):
     self.filter_height = filter_height
     self.filter_width = filter_width
     self.padder = padder
@@ -403,7 +403,7 @@ class TomesLeeMask(Masker):
 
   """
 
-  def __init__(self, filter_height = 4, filter_width = 40, padder=None):
+  def __init__(self, filter_height = 4, filter_width = 40, padder=Padder()):
     self.filter_height = filter_height
     self.filter_width = filter_width
     self.padder = padder
-- 
GitLab