I'am trying to run a simple geopandas code using ANACONDA spyder. However, I'am encountering an error.
I have included the code and the error as below:
--
here is the code:
import geopandas as gpd
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
world.plot()
import matplotlib.pyplot as plt
plt.show()
Run Code Online (Sandbox Code Playgroud)
--
here is the error:
File "C:\Users\usr\Anaconda3\lib\site-packages\geopandas\plotting.py", line 90, in plot_polygon_collection "The descartes package is required for plotting polygons in geopandas."
ImportError: The descartes package is required for plotting polygons in geopandas.
--
I checked online …
有没有办法将图像转换为矢量化形式,如下所示:
我已经查找了 CNN、Pillow 和 CV2 方法,但是我没有在网上找到任何可用的资源来实现此图像转换。
感谢您在此事上的帮助。
正常图像:
矢量化图像:
更新:
我已经使用SLIC方法实现了图像分割,以下是新代码和结果图像。可以看出,新图像接近矢量化图像(期望的结果),但质量/细节差异仍然很大。
还有其他想法吗?
from skimage import data, segmentation, color
from skimage.future import graph
from matplotlib import pyplot as plt
from PIL import Image
from skimage import io
path='/home/user/Desktop/Image1.jpeg'
img = io.imread(path)
labels1 = segmentation.slic(img, compactness=50, n_segments=5000,
start_label=1)
out1 = color.label2rgb(labels1, img, kind='avg', bg_label=0)
out1 = Image.fromarray(out1, 'RGB')
out1.save('/home/user/Desktop/1.png')
g = graph.rag_mean_color(img, labels1, mode='similarity')
labels2 = graph.cut_normalized(labels1, g)
out2 = color.label2rgb(labels2, img, kind='avg', bg_label=0)
out2 = Image.fromarray(out2, 'RGB')
out2.save('/home/user/Desktop/2.png')
fig, ax = …
Run Code Online (Sandbox Code Playgroud)