Skip to content

Commit

Permalink
Merge pull request #1105 from pmneila/master
Browse files Browse the repository at this point in the history
Minor fix for bugs in HOG implementation
  • Loading branch information
ahojnnes committed Aug 18, 2014
2 parents 9ea0d27 + 64e20d8 commit f7a7c1b
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions skimage/feature/_hog.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,15 @@ def hog(image, orientations=9, pixels_per_cell=(8, 8),
# convert uint image to float
# to avoid problems with subtracting unsigned numbers in np.diff()
image = image.astype('float')

gx = np.zeros(image.shape)
gy = np.zeros(image.shape)
gx[:, :-1] = np.diff(image, n=1, axis=1)
gy[:-1, :] = np.diff(image, n=1, axis=0)

gx = np.empty(image.shape, dtype=np.double)
gx[:, 0] = 0
gx[:, -1] = 0
gx[:, 1:-1] = image[:, 2:] - image[:, :-2]
gy = np.empty(image.shape, dtype=np.double)
gy[0, :] = 0
gy[-1, :] = 0
gy[1:-1, :] = image[2:, :] - image[:-2, :]

"""
The third stage aims to produce an encoding that is sensitive to
Expand Down Expand Up @@ -144,9 +148,9 @@ def hog(image, orientations=9, pixels_per_cell=(8, 8),
dx = radius * cos(float(o) / orientations * np.pi)
dy = radius * sin(float(o) / orientations * np.pi)
rr, cc = draw.line(int(centre[0] - dx),
int(centre[1] - dy),
int(centre[1] + dy),
int(centre[0] + dx),
int(centre[1] + dy))
int(centre[1] - dy))
hog_image[rr, cc] += orientation_histogram[y, x, o]

"""
Expand Down

0 comments on commit f7a7c1b

Please sign in to comment.