Commit b4d0a6d0 authored by André Anjos's avatar André Anjos 💬

Remove numpy warnings for floating-point indexes

parent d7dcfc4d
...@@ -85,10 +85,11 @@ class RepeatedLineTracking (Extractor): ...@@ -85,10 +85,11 @@ class RepeatedLineTracking (Extractor):
hWo = numpy.round(hW*math.sqrt(2)/2) # half width for oblique directions hWo = numpy.round(hW*math.sqrt(2)/2) # half width for oblique directions
# Omit unreachable borders # Omit unreachable borders
finger_mask[0:self.r+hW,:] = 0 border = int(self.r+hW)
finger_mask[finger_mask.shape[0]-(self.r+hW):,:] = 0 finger_mask[0:border,:] = 0
finger_mask[:,0:self.r+hW] = 0 finger_mask[finger_mask.shape[0]-border:,:] = 0
finger_mask[:,finger_mask.shape[1]-(self.r+hW):] = 0 finger_mask[:,0:border] = 0
finger_mask[:,finger_mask.shape[1]-border:] = 0
## Uniformly distributed starting points ## Uniformly distributed starting points
aux = numpy.argwhere( (finger_mask > 0) == True ) aux = numpy.argwhere( (finger_mask > 0) == True )
...@@ -153,7 +154,7 @@ class RepeatedLineTracking (Extractor): ...@@ -153,7 +154,7 @@ class RepeatedLineTracking (Extractor):
else: else:
# Left direction # Left direction
xp = Nc[i,0] - self.r 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): elif (Nc[i,0] == xc):
# Vertical plane # Vertical plane
xp = Nc[i,0] xp = Nc[i,0]
...@@ -163,7 +164,7 @@ class RepeatedLineTracking (Extractor): ...@@ -163,7 +164,7 @@ class RepeatedLineTracking (Extractor):
else: else:
# Up direction # Up direction
yp = Nc[i,1] - self.r 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 ## Oblique directions
if ( (Nc[i,0] > xc) and (Nc[i,1] < yc) ) or ( (Nc[i,0] < xc) and (Nc[i,1] > yc) ): 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): ...@@ -176,7 +177,7 @@ class RepeatedLineTracking (Extractor):
# Bottom left # Bottom left
xp = Nc[i,0] - ro xp = Nc[i,0] - ro
yp = Nc[i,1] + 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: else:
# Diagonal, down \ # Diagonal, down \
if (Nc[i,0] < xc and Nc[i,1] < yc): if (Nc[i,0] < xc and Nc[i,1] < yc):
...@@ -187,7 +188,7 @@ class RepeatedLineTracking (Extractor): ...@@ -187,7 +188,7 @@ class RepeatedLineTracking (Extractor):
# Bottom right # Bottom right
xp = Nc[i,0] + ro xp = Nc[i,0] + ro
yp = Nc[i,1] + 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 # End search of candidates
index = numpy.argmax(Vdepths) #Determine best candidate index = numpy.argmax(Vdepths) #Determine best candidate
# Register tracking information # Register tracking information
......
...@@ -285,11 +285,11 @@ class FingerCrop (Preprocessor): ...@@ -285,11 +285,11 @@ class FingerCrop (Preprocessor):
img_h,img_w = image.shape img_h,img_w = image.shape
# Determine lower half starting point # Determine lower half starting point
half_img_h = img_h/2 half_img_h = int(img_h/2)
# Construct mask for filtering # Construct mask for filtering
mask = numpy.ones((self.mask_h,self.mask_w), dtype='float64') 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) img_filt = utils.imfilter(image, mask)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment