From 77165de55fcdd3b3de35e0606ac60e353bd5445d Mon Sep 17 00:00:00 2001 From: Kirill Shklovsky Date: Wed, 14 Aug 2013 20:46:52 -0400 Subject: [PATCH] Changed the 180 constant in bin calculation to avoid rounding errors The code 180 / orientations performs integral division in python < 3, leading to the calculations ignoring some orientations near the 180 maximum --- skimage/feature/_hog.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skimage/feature/_hog.py b/skimage/feature/_hog.py index a2ece2f0..431a5986 100644 --- a/skimage/feature/_hog.py +++ b/skimage/feature/_hog.py @@ -117,9 +117,9 @@ def hog(image, orientations=9, pixels_per_cell=(8, 8), #create new integral image for this orientation # isolate orientations in this range - temp_ori = np.where(orientation < 180 / orientations * (i + 1), + temp_ori = np.where(orientation < 180.0 / orientations * (i + 1), orientation, -1) - temp_ori = np.where(orientation >= 180 / orientations * i, + temp_ori = np.where(orientation >= 180.0 / orientations * i, temp_ori, -1) # select magnitudes for those orientations cond2 = temp_ori > -1