1

我正在使用 scikit (skimage) 中的分水岭算法来分割我的图像,然后我使用 ndimage 库中的函数 find_objects 检测分割的对象。返回的类型是一个切片元组,如下所示:(slice(0L, 45L, None), slice(460L, 519L, None))。我需要在由 wathershed 分割的区域的中心点制作白色,那么如何从 slice 对象中找到它?有没有更简单的方法来找到这一点?

4

1 回答 1

1
rect = (slice(0L, 45L, None), slice(460L, 519L, None))

# Find the midpoint of the rectangle:
x,y = [(side.start+side.stop)/2. for side in rect]

在您的示例中,您得到x = 22.5and y = 489.5

于 2014-09-02T21:14:58.957 回答