Luc*_*uca 3 python scikit-learn
在python sklearn包中的skimage.segmentation包中有一个很好的超分辨率段生成(SLIC)实现.
slic()方法返回整数标签集.我的问题是如何才能获得彼此空间邻居的片段?我想要做的是使用这些段构建图形,边缘将连接直接邻居.但是,我无法弄清楚如何获得段的直接邻居.
执行SLIC的python代码如下:
from skimage import io
from skimage.segmentation import slic
from skimage.segmentation import find_boundaries
# An image of dimensions 300, 300
image = img_as_float(io.imread("image.png"))
# call slic. This returns an numpy array which assigns to every
# pixel in the image an integer label
# So segments is a numpy array of shape (300, 300)
segments = slic(image, 100, sigma = 5)
# Now I want to know the neighbourhood segment for each super-pixel
# There is a method called find_boundaries which returns a boolean
# for every pixel to show if it is a boundary pixel or not.
b = find_boundaries(segments)
Run Code Online (Sandbox Code Playgroud)
在这里,我被困住了.我想知道如何解析这个边界索引并找出给定的标签索引(比如0),哪个标签索引共享一个带有索引0的标签的边界.有没有办法有效地做到这一点而不通过边界数组循环对于每个标签索引?
| 归档时间: |
|
| 查看次数: |
3039 次 |
| 最近记录: |