Code valid for all image dtypes

This commit is contained in:
Pablo Márquez Neila
2014-08-18 02:12:27 +02:00
parent 23bc3ed077
commit 808e53c7ae
+2 -2
View File
@@ -80,11 +80,11 @@ def hog(image, orientations=9, pixels_per_cell=(8, 8),
# to avoid problems with subtracting unsigned numbers in np.diff()
image = image.astype('float')
gx = np.empty_like(image)
gx = np.empty(image.shape)
gx[:, 0] = 0
gx[:, -1] = 0
gx[:, 1:-1] = image[:, 2:] - image[:, :-2]
gy = np.empty_like(image)
gy = np.empty(image.shape)
gy[0, :] = 0
gy[-1, :] = 0
gy[1:-1, :] = image[2:, :] - image[:-2, :]