diff --git a/bob/bio/vein/algorithm/Correlate.py b/bob/bio/vein/algorithm/Correlate.py index 4e82f02140b2be0c18fd40e714dc5e376f2a8597..e35310617c82d465e96a244b07494f229f1125e1 100644 --- a/bob/bio/vein/algorithm/Correlate.py +++ b/bob/bio/vein/algorithm/Correlate.py @@ -47,7 +47,7 @@ class Correlate(Algorithm): """ - I = probe.astype(numpy.float64) + image_ = probe.astype(numpy.float64) if len(model.shape) == 2: model = numpy.array([model]) @@ -58,7 +58,7 @@ class Correlate(Algorithm): for md in model: R = md.astype(numpy.float64) - Nm = skimage.feature.match_template(I, R) + Nm = skimage.feature.match_template(image_, R) # figures out where the maximum is on the resulting matrix t0, s0 = numpy.unravel_index(Nm.argmax(), Nm.shape) diff --git a/bob/bio/vein/algorithm/MiuraMatch.py b/bob/bio/vein/algorithm/MiuraMatch.py index a70a93febdb1bf3599f2a2c209f4991994028ef0..463342593629d3b112333cc31e8ce9d6d819beef 100644 --- a/bob/bio/vein/algorithm/MiuraMatch.py +++ b/bob/bio/vein/algorithm/MiuraMatch.py @@ -83,7 +83,7 @@ class MiuraMatch(BioAlgorithm): """ - I = probe.astype(numpy.float64) + image_ = probe.astype(numpy.float64) if len(model.shape) == 2: model = numpy.array([model]) @@ -103,7 +103,7 @@ class MiuraMatch(BioAlgorithm): # yields best results. Otherwise, you may try the other options bellow # -> check our test_correlation() method on the test units for more # details and benchmarks. - Nm = scipy.signal.fftconvolve(I, numpy.rot90(crop_R, k=2), "valid") + Nm = scipy.signal.fftconvolve(image_, numpy.rot90(crop_R, k=2), "valid") # 2nd best: use convolve2d or correlate2d directly; # Nm = scipy.signal.convolve2d(I, numpy.rot90(crop_R, k=2), 'valid') # 3rd best: use correlate2d @@ -122,7 +122,7 @@ class MiuraMatch(BioAlgorithm): Nmm / ( crop_R.sum() - + I[ + + image_[ t0 : t0 + h - 2 * self.ch, s0 : s0 + w - 2 * self.cw ].sum() ) diff --git a/bob/bio/vein/extractor/MaximumCurvature.py b/bob/bio/vein/extractor/MaximumCurvature.py index 698ff1b770e97e174d683d01bc9f9dbda9c00ab3..5248d972cfd18730ec85c41a838de2cf7089459c 100644 --- a/bob/bio/vein/extractor/MaximumCurvature.py +++ b/bob/bio/vein/extractor/MaximumCurvature.py @@ -33,7 +33,7 @@ class MaximumCurvature(Extractor): self.sigma = sigma def detect_valleys(self, image, mask): - """Detects valleys on the image respecting the mask + r"""Detects valleys on the image respecting the mask This step corresponds to Step 1-1 in the original paper. The objective is, for all 4 cross-sections (z) of the image (horizontal, vertical, 45 and -45 @@ -178,7 +178,7 @@ class MaximumCurvature(Extractor): ) def eval_vein_probabilities(self, k): - """Evaluates joint vein centre probabilities from cross-sections + r"""Evaluates joint vein centre probabilities from cross-sections This function will take $\kappa$ and will calculate the vein centre probabilities taking into consideration valley widths and depths. It @@ -318,7 +318,7 @@ class MaximumCurvature(Extractor): return V def connect_centres(self, V): - """Connects vein centres by filtering vein probabilities ``V`` + r"""Connects vein centres by filtering vein probabilities ``V`` This function does the equivalent of Step 2 / Equation 4 at Miura's paper. diff --git a/bob/bio/vein/extractor/PrincipalCurvature.py b/bob/bio/vein/extractor/PrincipalCurvature.py index 751be994d8d2df7bea5b164721520bfbc925438c..84c1bbea95819d6b1baa22a2c469084c8b69d912 100644 --- a/bob/bio/vein/extractor/PrincipalCurvature.py +++ b/bob/bio/vein/extractor/PrincipalCurvature.py @@ -46,14 +46,14 @@ class PrincipalCurvature(Extractor): fingervein image""" finger_mask = numpy.zeros(mask.shape) - finger_mask[mask == True] = 1 + finger_mask[mask == True] = 1 # noqa: E712 sigma = numpy.sqrt(self.sigma**2 / 2) gx = self.ut_gauss(image, self.sigma, 1, 0) gy = self.ut_gauss(image, self.sigma, 0, 1) - Gmag = numpy.sqrt(gx**2 + gy**2) # Gradient magnitude + Gmag = numpy.sqrt(gx**2 + gy**2) # Gradient magnitude # Apply threshold gamma = (self.threshold / 100) * numpy.max(Gmag) diff --git a/bob/bio/vein/extractor/RepeatedLineTracking.py b/bob/bio/vein/extractor/RepeatedLineTracking.py index 65d627c6060b3f630fe6dbb72fa2330643657563..6a9ec79752c833ba2586528ece614e4c9a841da5 100644 --- a/bob/bio/vein/extractor/RepeatedLineTracking.py +++ b/bob/bio/vein/extractor/RepeatedLineTracking.py @@ -54,10 +54,10 @@ class RepeatedLineTracking(Extractor): numpy.random.seed(self.seed) finger_mask = numpy.zeros(mask.shape) - finger_mask[mask == True] = 1 + finger_mask[mask == True] = 1 # noqa: E712 # Rescale image if required - if self.rescale == True: + if self.rescale: scaling_factor = 0.6 # finger_image = bob.ip.base.scale(finger_image, scaling_factor) # finger_mask = bob.ip.base.scale(finger_mask, scaling_factor) @@ -121,14 +121,14 @@ class RepeatedLineTracking(Extractor): finger_mask[:, 0:border] = 0 finger_mask[:, finger_mask.shape[1] - border :] = 0 - ## Uniformly distributed starting points - aux = numpy.argwhere((finger_mask > 0) == True) + # Uniformly distributed starting points + aux = numpy.argwhere(finger_mask > 0) indices = numpy.random.permutation(aux) indices = indices[ 0 : self.iterations, : ] # Limit to number of iterations - ## Iterate through all starting points + # Iterate through all starting points for it in range(0, self.iterations): yc = indices[it, 0] # Current tracking point, y xc = indices[it, 1] # Current tracking point, x @@ -175,7 +175,6 @@ class RepeatedLineTracking(Extractor): bool ) ).T.reshape(-1) - == True ) Nc = numpy.concatenate( (xc + filtermask[tmp, 0], yc + filtermask[tmp, 1]), axis=1 @@ -184,10 +183,10 @@ class RepeatedLineTracking(Extractor): Vl = -1 continue - ## Detect dark line direction near current tracking point + # Detect dark line direction near current tracking point Vdepths = numpy.zeros((Nc.shape[0], 1)) # Valley depths for i in range(0, Nc.shape[0]): - ## Horizontal or vertical + # Horizontal or vertical if Nc[i, 1] == yc: # Horizontal plane yp = Nc[i, 1] @@ -217,7 +216,7 @@ class RepeatedLineTracking(Extractor): + finger_image[int(yp), int(xp - hW)] ) - ## Oblique directions + # Oblique directions if ((Nc[i, 0] > xc) and (Nc[i, 1] < yc)) or ( (Nc[i, 0] < xc) and (Nc[i, 1] > yc) ): diff --git a/bob/bio/vein/extractor/WideLineDetector.py b/bob/bio/vein/extractor/WideLineDetector.py index 9350e728991622c295d97944bc56613dbcfdee3f..d64899ffcc42a25a9cdc5695d173658a59beeefe 100644 --- a/bob/bio/vein/extractor/WideLineDetector.py +++ b/bob/bio/vein/extractor/WideLineDetector.py @@ -45,10 +45,10 @@ class WideLineDetector(Extractor): finger_image = finger_image.astype(numpy.float64) finger_mask = numpy.zeros(mask.shape) - finger_mask[mask == True] = 1 + finger_mask[mask == True] = 1 # noqa: E712 # Rescale image if required - if self.rescale == True: + if self.rescale: scaling_factor = 0.24 new_size = tuple( diff --git a/bob/bio/vein/preprocessor/crop.py b/bob/bio/vein/preprocessor/crop.py index 7064ff0d150a8437b00c573be5b94accbf82a769..4ca5b2d56d80d090d79f5d81f9f45e123f1225d8 100644 --- a/bob/bio/vein/preprocessor/crop.py +++ b/bob/bio/vein/preprocessor/crop.py @@ -35,7 +35,7 @@ class Cropper(object): """ - raise NotImplemented("You must implement the __call__ slot") + raise NotImplementedError("You must implement the __call__ slot") class FixedCrop(Cropper): diff --git a/bob/bio/vein/preprocessor/filters.py b/bob/bio/vein/preprocessor/filters.py index 31f3ef1f1b424a561c3964189889c55afcdaca74..9ef0a9c013a117a8fd24972d4e433f02d3dfb13f 100644 --- a/bob/bio/vein/preprocessor/filters.py +++ b/bob/bio/vein/preprocessor/filters.py @@ -31,7 +31,7 @@ class Filter(object): """ - raise NotImplemented("You must implement the __call__ slot") + raise NotImplementedError("You must implement the __call__ slot") class NoFilter(Filter): diff --git a/bob/bio/vein/preprocessor/mask.py b/bob/bio/vein/preprocessor/mask.py index 7e1551db14de856368b3a03dde9011b0a47ffc0c..01dd15d79b28b16cd96a95fe49459a381b478029 100644 --- a/bob/bio/vein/preprocessor/mask.py +++ b/bob/bio/vein/preprocessor/mask.py @@ -91,7 +91,7 @@ class Masker(object): """ - raise NotImplemented("You must implement the __call__ slot") + raise NotImplementedError("You must implement the __call__ slot") class FixedMask(Masker): diff --git a/bob/bio/vein/preprocessor/normalize.py b/bob/bio/vein/preprocessor/normalize.py index f047c1f3934e95a7661a3d1e20d8628b8d311dd2..7c4f38e4a9231475e90af1376ecac64b94bd81ba 100644 --- a/bob/bio/vein/preprocessor/normalize.py +++ b/bob/bio/vein/preprocessor/normalize.py @@ -38,7 +38,7 @@ class Normalizer(object): """ - raise NotImplemented("You must implement the __call__ slot") + raise NotImplementedError("You must implement the __call__ slot") class NoNormalization(Normalizer): diff --git a/bob/bio/vein/preprocessor/utils.py b/bob/bio/vein/preprocessor/utils.py index b4de1617c5df03c66b3afb45440d1601ee4cc5b7..81931d2dd80725327255a3ddbb036ec2eb24f712 100644 --- a/bob/bio/vein/preprocessor/utils.py +++ b/bob/bio/vein/preprocessor/utils.py @@ -235,7 +235,7 @@ def show_mask_over_image(image, mask, color="red"): def jaccard_index(a, b): - """Calculates the intersection over union for two masks + r"""Calculates the intersection over union for two masks This function calculates the Jaccard index: diff --git a/bob/bio/vein/script/view_sample.py b/bob/bio/vein/script/view_sample.py index 4dccc88b87eecc49e6dacb8770df250271a5557b..4c7dd42a97c2b6ba582b63ce6a5a7adaa92d4e60 100644 --- a/bob/bio/vein/script/view_sample.py +++ b/bob/bio/vein/script/view_sample.py @@ -256,7 +256,7 @@ def main(user_input=None): try: binary = f.load(os.path.join(args["<processed>"], "extracted")) binary = numpy.rot90(binary, k=1) - except: + except Exception: binary = None fig = proof_figure(stem, image, mask, image_pp, binary) if args["--save"]: diff --git a/bob/bio/vein/tests/test_databases.py b/bob/bio/vein/tests/test_databases.py index d06a2fbbbc73635241617419311ea925a2e58189..2e4cf9fe5753ecc09f77e90de35042da1c7402d6 100644 --- a/bob/bio/vein/tests/test_databases.py +++ b/bob/bio/vein/tests/test_databases.py @@ -96,7 +96,7 @@ def test_utfvp(): except Exception: pass - N_SUBJECTS, N_FINGERS, N_SESSIONS = 60, 6, 4 + N_SUBJECTS, N_SESSIONS = 60, 4 # nom nom_parameters = { "N_train": 10,