Repository: scikit-image/scikit-image

Issue:
`watershed_demo` fails on mouse click
## Description
```
[egor@host scikit-image]$ python viewer_examples/plugins/watershed_demo.py 
Watershed plugin
----------------
Use mouse to paint each region with a different label.
Press OK to display segmented image.
Traceback (most recent call last):
  File "/home/egor/.local/lib/python3.6/site-packages/matplotlib/cbook/__init__.py", line 388, in process
    proxy(*args, **kwargs)
  File "/home/egor/.local/lib/python3.6/site-packages/matplotlib/cbook/__init__.py", line 228, in __call__
    return mtd(*args, **kwargs)
  File "/home/egor/Workspace/_contrib/scikit-image/skimage/viewer/utils/canvas.py", line 75, in on_mouse_press
    self.active_tool.on_mouse_press(event)
  File "/home/egor/Workspace/_contrib/scikit-image/skimage/viewer/canvastools/painttool.py", line 149, in on_mouse_press
    self.update_overlay(event.xdata, event.ydata)
  File "/home/egor/Workspace/_contrib/scikit-image/skimage/viewer/canvastools/painttool.py", line 172, in update_overlay
    overlay[self.window.at(y, x)] = self.label
TypeError: slice indices must be integers or None or have an __index__ method
```

## Way to reproduce
[If reporting a bug, please include the following important information:]
- [x] Code example
- [x] Relevant images (if any)
- [x] Operating system and version: `Linux 4.14.49-1-lts #1 SMP Tue Jun 12 16:32:50 CEST 2018 x86_64 GNU/Linux`
- [x] Python version: 3.6.5
- [x] scikit-image version (run `skimage.__version__`): https://github.com/scikit-image/scikit-image/commit/18f97d864a9468555851aac08c731b6813db2091
- [x] matplotlib: 2.2.2




Discussion:

Resolving patch:
diff --git a/skimage/viewer/canvastools/painttool.py b/skimage/viewer/canvastools/painttool.py
--- a/skimage/viewer/canvastools/painttool.py
+++ b/skimage/viewer/canvastools/painttool.py
@@ -206,12 +206,21 @@ def __init__(self, radius, array_shape):
 
     def at(self, row, col):
         h, w = self.array_shape
-        r = self.radius
+        r = round(self.radius)
+        # Note: the int() cast is necessary because row and col are np.float64,
+        # which does not get cast by round(), unlike a normal Python float:
+        # >>> round(4.5)
+        # 4
+        # >>> round(np.float64(4.5))
+        # 4.0
+        # >>> int(round(np.float64(4.5)))
+        # 4
+        row, col = int(round(row)), int(round(col))
         xmin = max(0, col - r)
         xmax = min(w, col + r + 1)
         ymin = max(0, row - r)
         ymax = min(h, row + r + 1)
-        return [slice(ymin, ymax), slice(xmin, xmax)]
+        return (slice(ymin, ymax), slice(xmin, xmax))
 
 
 if __name__ == '__main__':  # pragma: no cover
diff --git a/viewer_examples/plugins/watershed_demo.py b/viewer_examples/plugins/watershed_demo.py
--- a/viewer_examples/plugins/watershed_demo.py
+++ b/viewer_examples/plugins/watershed_demo.py
@@ -28,7 +28,7 @@ def help(self):
 
     def _show_watershed(self):
         viewer = self.image_viewer
-        edge_image = filter.sobel(viewer.image)
+        edge_image = filters.sobel(viewer.image)
         labels = morphology.watershed(edge_image, self.paint_tool.overlay)
         viewer.ax.imshow(labels, cmap=plt.cm.jet, alpha=0.5)
         viewer.redraw()


Test patch: