Repository: scikit-image/scikit-image

Issue:
blob_log, blob_dog and blob_doh error when not detecting peaks
## Description

Blob detection with any of the skimage.feature.blob_log, blob_dog or blob_doh fails when no blobs are detected.

```
IndexError                                Traceback (most recent call last)
<ipython-input-15-0eabae5c0e37> in <module>()
----> 1 blob_log(a)

/Users/jj/anaconda3/lib/python3.5/site-packages/skimage/feature/blob.py in blob_log(image, min_sigma, max_sigma, num_sigma, threshold, overlap, log_scale)
    306     lm = local_maxima.astype(np.float64)
    307     # Convert the last index to its corresponding scale value
--> 308     lm[:, 2] = sigma_list[local_maxima[:, 2]]
    309     local_maxima = lm
    310     return _prune_blobs(local_maxima, overlap)

IndexError: index 2 is out of bounds for axis 1 with size 2
```
## Way to reproduce

``` python
from skimage.feature import blob_log
a=np.zeros((100,100))
blob_log(a)
```

I'm on OSX 10.11.6, Python 3.5, scikit-image 0.12.3



Discussion:
I am looking at this


Resolving patch:
diff --git a/skimage/feature/blob.py b/skimage/feature/blob.py
--- a/skimage/feature/blob.py
+++ b/skimage/feature/blob.py
@@ -200,6 +200,9 @@ def blob_dog(image, min_sigma=1, max_sigma=50, sigma_ratio=1.6, threshold=2.0,
                                   footprint=np.ones((3, 3, 3)),
                                   threshold_rel=0.0,
                                   exclude_border=False)
+    # Catch no peaks
+    if local_maxima.size == 0:
+        return np.empty((0,3))
     # Convert local_maxima to float64
     lm = local_maxima.astype(np.float64)
     # Convert the last index to its corresponding scale value
@@ -302,6 +305,9 @@ def blob_log(image, min_sigma=1, max_sigma=50, num_sigma=10, threshold=.2,
                                   threshold_rel=0.0,
                                   exclude_border=False)
 
+    # Catch no peaks
+    if local_maxima.size == 0:
+        return np.empty((0,3))
     # Convert local_maxima to float64
     lm = local_maxima.astype(np.float64)
     # Convert the last index to its corresponding scale value
@@ -412,6 +418,9 @@ def blob_doh(image, min_sigma=1, max_sigma=30, num_sigma=10, threshold=0.01,
                                   threshold_rel=0.0,
                                   exclude_border=False)
 
+    # Catch no peaks
+    if local_maxima.size == 0:
+        return np.empty((0,3))
     # Convert local_maxima to float64
     lm = local_maxima.astype(np.float64)
     # Convert the last index to its corresponding scale value


Test patch:
diff --git a/skimage/feature/tests/test_blob.py b/skimage/feature/tests/test_blob.py
--- a/skimage/feature/tests/test_blob.py
+++ b/skimage/feature/tests/test_blob.py
@@ -41,6 +41,10 @@ def test_blob_dog():
 
     assert_raises(ValueError, blob_dog, img3)
 
+    # Testing no peaks
+    img_empty = np.zeros((100,100))
+    assert blob_dog(img_empty).size == 0
+
 
 def test_blob_log():
     r2 = math.sqrt(2)
@@ -115,6 +119,10 @@ def test_blob_log():
 
     assert_raises(ValueError, blob_log, img3)
 
+    # Testing no peaks
+    img_empty = np.zeros((100,100))
+    assert blob_log(img_empty).size == 0
+
 
 def test_blob_doh():
     img = np.ones((512, 512), dtype=np.uint8)
@@ -194,6 +202,10 @@ def test_blob_doh():
 
     assert_raises(ValueError, blob_doh, img3)
 
+    # Testing no peaks
+    img_empty = np.zeros((100,100))
+    assert blob_doh(img_empty).size == 0
+
 
 def test_blob_overlap():
     img = np.ones((512, 512), dtype=np.uint8)