python將圖片轉為矢量圖的方法步驟
本文主要介紹了python圖片轉為矢量圖,分享給大家,具體如下:
import numpy as npimport matplotlib.pyplot as pltimport cv2fig, ax = plt.subplots()plt.figure(1)image=cv2.imread('2.jpg')# you can specify the marker size two ways directly:# 這樣一個一個像素太慢了故而要將同樣顏色的坐標進行分類處理color_class=[]x_y=dict()for x,w in enumerate(image): for y,colors in enumerate(w): if colors.tolist() not in color_class: s=image[:, :, :1] == colors[0] s1=image[:, :, 1:2] == colors[1] s2=image[:, :, 2:3] == colors[2] ss=s*s1*s2 color_class.append(colors.tolist()) x_y[len(color_class)]=np.where(ss.reshape((ss.shape[0],ss.shape[1]))) print(x,y)for i ,colors in enumerate(color_class): a, b = x_y[i + 1] plt.plot(a,b, '.',color=[colors[2]/255,colors[1]/255,colors[0]/255], markersize=1, label=’a’) # blue circle with size 20fig.savefig(’scatter.svg’, dpi=200, format=’svg’)if __name__ == ’__main__’: pass
到此這篇關于python將圖片轉為矢量圖的方法步驟的文章就介紹到這了,更多相關python圖片轉為矢量圖內容請搜索好吧啦網以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持好吧啦網!
相關文章:
1. vue使用moment如何將時間戳轉為標準日期時間格式2. Python數據相關系數矩陣和熱力圖輕松實現(xiàn)教程3. js select支持手動輸入功能實現(xiàn)代碼4. php redis setnx分布式鎖簡單原理解析5. 《Java程序員修煉之道》作者Ben Evans:保守的設計思想是Java的最大優(yōu)勢6. CSS3中Transition屬性詳解以及示例分享7. bootstrap select2 動態(tài)從后臺Ajax動態(tài)獲取數據的代碼8. 如何在PHP中讀寫文件9. java加載屬性配置properties文件的方法10. 什么是Python變量作用域
