如何修复skimage.viewer.canvastools.PaintTool中的类型错误

时间:2019-06-17 09:34:50

标签: python scikit-image

我正在尝试使用skimage.viewer.canvastools.PaintTool绘制覆盖蒙版,并且无法解决类型错误。

我成功生成了一个ImageViewer窗口,该窗口带有一个半透明的覆盖蒙版和一个用于绘画的彩色像素光标,但是当我尝试绘画时没有任何响应。当我关闭ImageViewer时,我收到“ TypeError:切片索引必须为整数或无,或者具有 index 方法”

from skimage.viewer.canvastools import PaintTool
from skimage.viewer import  ImageViewer

viewer = ImageViewer(img) # grayscale image
color = np.shape(img) # 2D tuple
p = PaintTool(viewer,color,5,0.5)
viewer.show()

我希望ImageViewer窗口弹出并允许在我的图像上绘制,但是会引发TypeError。

Traceback (most recent call last):
  File "C:\Users\User\Anaconda3\lib\site-packages\matplotlib\cbook\__init__.py", line 215, in process
func(*args, **kwargs)
  File "C:\Users\User\Anaconda3\lib\site-packages\skimage\viewer\utils\canvas.py", line 75, in on_mouse_press
self.active_tool.on_mouse_press(event)
  File "C:\Users\User\Anaconda3\lib\site-packages\skimage\viewer\canvastools\painttool.py", line 149, in on_mouse_press
self.update_cursor(event.xdata, event.ydata)
  File "C:\Users\User\Anaconda3\lib\site-packages\skimage\viewer\canvastools\painttool.py", line 172, in update_overlay
def update_overlay(self, x, y):
TypeError: slice indices must be integers or None or have an __index__ method

0 个答案:

没有答案