Repository: scikit-image/scikit-image

Issue:
Does skimage.feature.haar_like_feature computes all the features?
I was trying to compute all the haar-like features for a 24x24 detection window using the `skimage.feature.haar_like_feature`, however I found out that it doesn't really return all the features.

Have a look at this question that I asked on stackoverflow describing the same problem:
https://stackoverflow.com/questions/62682760/computing-all-the-haar-like-features-using-scikit-image



Discussion:

Resolving patch:
diff --git a/skimage/feature/haar.py b/skimage/feature/haar.py
--- a/skimage/feature/haar.py
+++ b/skimage/feature/haar.py
@@ -153,9 +153,9 @@ def haar_like_feature(int_image, r, c, width, height, feature_type=None,
     >>> img_ii = integral_image(img)
     >>> feature = haar_like_feature(img_ii, 0, 0, 5, 5, 'type-3-x')
     >>> feature
-    array([-1, -2, -3, -4, -1, -2, -3, -4, -1, -2, -3, -4, -1, -2, -3, -4, -1,
-           -2, -3, -4, -1, -2, -3, -4, -1, -2, -3, -1, -2, -3, -1, -2, -3, -1,
-           -2, -1, -2, -1, -2, -1, -1, -1])
+    array([-1, -2, -3, -4, -5, -1, -2, -3, -4, -5, -1, -2, -3, -4, -5, -1, -2,
+           -3, -4, -1, -2, -3, -4, -1, -2, -3, -4, -1, -2, -3, -1, -2, -3, -1,
+           -2, -3, -1, -2, -1, -2, -1, -2, -1, -1, -1])
 
     You can compute the feature for some pre-computed coordinates.
 
@@ -172,8 +172,8 @@ def haar_like_feature(int_image, r, c, width, height, feature_type=None,
     >>> feature
     array([ 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
             0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
-            0,  0,  0,  0,  0,  0,  0,  0, -1, -3, -1, -3, -1, -3, -1, -3, -1,
-           -3, -1, -3, -1, -3, -2, -1, -3, -2, -2, -2, -1])
+            0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, -1, -3, -5, -2, -4, -1,
+           -3, -5, -2, -4, -2, -4, -2, -4, -2, -1, -3, -2, -1, -1, -1, -1, -1])
 
     References
     ----------


Test patch:
diff --git a/skimage/feature/tests/test_haar.py b/skimage/feature/tests/test_haar.py
--- a/skimage/feature/tests/test_haar.py
+++ b/skimage/feature/tests/test_haar.py
@@ -33,8 +33,8 @@ def test_haar_like_feature_error():
 @pytest.mark.parametrize("feature_type,shape_feature,expected_feature_value",
                          [('type-2-x', (84,), [0.]),
                           ('type-2-y', (84,), [0.]),
-                          ('type-3-x', (42,), [-4., -3., -2., -1.]),
-                          ('type-3-y', (42,), [-4., -3., -2., -1.]),
+                          ('type-3-x', (42,), [-5, -4., -3., -2., -1.]),
+                          ('type-3-y', (42,), [-5, -4., -3., -2., -1.]),
                           ('type-4', (36,), [0.])])
 def test_haar_like_feature(feature_type, shape_feature,
                            expected_feature_value, dtype):
@@ -102,15 +102,19 @@ def test_haar_like_feature_precomputed(feature_type):
 @pytest.mark.parametrize("feature_type,height,width,expected_coord",
                          [('type-2-x', 2, 2,
                            [[[(0, 0), (0, 0)], [(0, 1), (0, 1)]],
+                            [[(0, 0), (1, 0)], [(0, 1), (1, 1)]],
                             [[(1, 0), (1, 0)], [(1, 1), (1, 1)]]]),
                           ('type-2-y', 2, 2,
                            [[[(0, 0), (0, 0)], [(1, 0), (1, 0)]],
+                            [[(0, 0), (0, 1)], [(1, 0), (1, 1)]],
                             [[(0, 1), (0, 1)], [(1, 1), (1, 1)]]]),
                           ('type-3-x', 3, 3,
                            [[[(0, 0), (0, 0)], [(0, 1), (0, 1)],
                              [(0, 2), (0, 2)]],
                             [[(0, 0), (1, 0)], [(0, 1), (1, 1)],
                              [(0, 2), (1, 2)]],
+                            [[(0, 0), (2, 0)], [(0, 1), (2, 1)],
+                             [(0, 2), (2, 2)]],
                             [[(1, 0), (1, 0)], [(1, 1), (1, 1)],
                              [(1, 2), (1, 2)]],
                             [[(1, 0), (2, 0)], [(1, 1), (2, 1)],
@@ -122,6 +126,8 @@ def test_haar_like_feature_precomputed(feature_type):
                              [(2, 0), (2, 0)]],
                             [[(0, 0), (0, 1)], [(1, 0), (1, 1)],
                              [(2, 0), (2, 1)]],
+                            [[(0, 0), (0, 2)], [(1, 0), (1, 2)],
+                             [(2, 0), (2, 2)]],
                             [[(0, 1), (0, 1)], [(1, 1), (1, 1)],
                              [(2, 1), (2, 1)]],
                             [[(0, 1), (0, 2)], [(1, 1), (1, 2)],