From b4d0a6d0cd17bff8e488b34c996e918e820f9e86 Mon Sep 17 00:00:00 2001 From: Andre Anjos <andre.anjos@idiap.ch> Date: Fri, 4 Nov 2016 15:18:32 +0100 Subject: [PATCH] Remove numpy warnings for floating-point indexes --- bob/bio/vein/extractor/RepeatedLineTracking.py | 17 +++++++++-------- bob/bio/vein/preprocessor/FingerCrop.py | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/bob/bio/vein/extractor/RepeatedLineTracking.py b/bob/bio/vein/extractor/RepeatedLineTracking.py index c3c5d6a..84074af 100644 --- a/bob/bio/vein/extractor/RepeatedLineTracking.py +++ b/bob/bio/vein/extractor/RepeatedLineTracking.py @@ -85,10 +85,11 @@ class RepeatedLineTracking (Extractor): hWo = numpy.round(hW*math.sqrt(2)/2) # half width for oblique directions # Omit unreachable borders - finger_mask[0:self.r+hW,:] = 0 - finger_mask[finger_mask.shape[0]-(self.r+hW):,:] = 0 - finger_mask[:,0:self.r+hW] = 0 - finger_mask[:,finger_mask.shape[1]-(self.r+hW):] = 0 + border = int(self.r+hW) + finger_mask[0:border,:] = 0 + finger_mask[finger_mask.shape[0]-border:,:] = 0 + finger_mask[:,0:border] = 0 + finger_mask[:,finger_mask.shape[1]-border:] = 0 ## Uniformly distributed starting points aux = numpy.argwhere( (finger_mask > 0) == True ) @@ -153,7 +154,7 @@ class RepeatedLineTracking (Extractor): else: # Left direction xp = Nc[i,0] - self.r - Vdepths[i] = finger_image[yp + hW, xp] - 2*finger_image[yp,xp] + finger_image[yp - hW, xp] + Vdepths[i] = finger_image[int(yp + hW), int(xp)] - 2*finger_image[int(yp),int(xp)] + finger_image[int(yp - hW), int(xp)] elif (Nc[i,0] == xc): # Vertical plane xp = Nc[i,0] @@ -163,7 +164,7 @@ class RepeatedLineTracking (Extractor): else: # Up direction yp = Nc[i,1] - self.r - Vdepths[i] = finger_image[yp, xp + hW] - 2*finger_image[yp,xp] + finger_image[yp, xp - hW] + Vdepths[i] = finger_image[int(yp), int(xp + hW)] - 2*finger_image[int(yp),int(xp)] + finger_image[int(yp), int(xp - hW)] ## Oblique directions if ( (Nc[i,0] > xc) and (Nc[i,1] < yc) ) or ( (Nc[i,0] < xc) and (Nc[i,1] > yc) ): @@ -176,7 +177,7 @@ class RepeatedLineTracking (Extractor): # Bottom left xp = Nc[i,0] - ro yp = Nc[i,1] + ro - Vdepths[i] = finger_image[yp - hWo, xp - hWo] - 2*finger_image[yp,xp] + finger_image[yp + hWo, xp + hWo] + Vdepths[i] = finger_image[int(yp - hWo), int(xp - hWo)] - 2*finger_image[int(yp),int(xp)] + finger_image[int(yp + hWo), int(xp + hWo)] else: # Diagonal, down \ if (Nc[i,0] < xc and Nc[i,1] < yc): @@ -187,7 +188,7 @@ class RepeatedLineTracking (Extractor): # Bottom right xp = Nc[i,0] + ro yp = Nc[i,1] + ro - Vdepths[i] = finger_image[yp + hWo, xp - hWo] - 2*finger_image[yp,xp] + finger_image[yp - hWo, xp + hWo] + Vdepths[i] = finger_image[int(yp + hWo), int(xp - hWo)] - 2*finger_image[int(yp),int(xp)] + finger_image[int(yp - hWo), int(xp + hWo)] # End search of candidates index = numpy.argmax(Vdepths) #Determine best candidate # Register tracking information diff --git a/bob/bio/vein/preprocessor/FingerCrop.py b/bob/bio/vein/preprocessor/FingerCrop.py index f6dbd2e..a634948 100644 --- a/bob/bio/vein/preprocessor/FingerCrop.py +++ b/bob/bio/vein/preprocessor/FingerCrop.py @@ -285,11 +285,11 @@ class FingerCrop (Preprocessor): img_h,img_w = image.shape # Determine lower half starting point - half_img_h = img_h/2 + half_img_h = int(img_h/2) # Construct mask for filtering mask = numpy.ones((self.mask_h,self.mask_w), dtype='float64') - mask[(self.mask_h/2):,:] = -1.0 + mask[int(self.mask_h/2):,:] = -1.0 img_filt = utils.imfilter(image, mask) -- GitLab