From 9689ed2f9e78ce528eef394e3c1fa37bd57dd205 Mon Sep 17 00:00:00 2001 From: Ivo Flipse Date: Thu, 21 Jan 2016 12:28:35 +0100 Subject: [PATCH] This would return NaN if total is zero --- skimage/feature/_hoghistogram.pyx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/skimage/feature/_hoghistogram.pyx b/skimage/feature/_hoghistogram.pyx index cd34caae42b..7033aeffc8c 100644 --- a/skimage/feature/_hoghistogram.pyx +++ b/skimage/feature/_hoghistogram.pyx @@ -70,7 +70,9 @@ cdef float cell_hog(double[:, ::1] magnitude, total += magnitude[cell_row_index, cell_column_index] - return total / (cell_rows * cell_columns) + if total: + return total / (cell_rows * cell_columns) + return 0. def hog_histograms(double[:, ::1] gradient_columns, double[:, ::1] gradient_rows,