2

如何提取超像素、检索边缘然后简化这些?这是我到目前为止所得到的:

import skimage
import numpy as np
from rasterio import features
from shapely.geometry import Polygon, MultiPolygon

image = skimage.util.img_as_float(skimage.io.imread("image.jpg"))
labels = skimage.segmentation.slic(image, n_segments = 200, sigma = 5)
boundaries = skimage.segmentation.find_boundaries(labels).astype(np.uint8)

#this is where it goes wrong as rasterio creates shapes with distinct edges
shapes = rasterio.features.shapes(boundaries)

polygons = MultiPolygon([Polygon(sh[0]["coordinates"][0]) for sh in shapes])
out = polygons.simplify(0.05)

这里的问题是简化在每个多边形的基础上工作,因此它的输出不是一个紧密的网格。

我正在寻找与此类似的东西,因此获得边缘并能够简化。

4

0 回答 0