python实点云分割k-means(sklearn)详解

Neoma ·
更新时间:2024-11-13
· 861 次阅读

本文实例为大家分享了Python实点云分割k-means(sklearn),供大家参考,具体内容如下

植物叶片分割

import numpy as np import matplotlib.pyplot as plt import pandas as pd from sklearn.cluster import KMeans from sklearn.preprocessing import StandardScaler from mpl_toolkits.mplot3d import Axes3D data = pd.read_csv("jiaaobo1.txt",sep = " ") data1 = data.iloc[:,0:3] #标准化 transfer = StandardScaler() data_new = transfer.fit_transform(data1) data_new #预估计流程 estimator = KMeans(n_clusters = 10) estimator.fit(data_new) y_pred = estimator.predict(data_new) #也可以不预测 #cluster = KMeans(n_clusters = 9).fit(data_new) #y_pred = cluster.labels_s #质心 #centroid = cluster.cluster_centers_ #centroid.shape fig = plt.figure() ax = Axes3D(fig) for i in range(9): ax.scatter3D(data_new[y_pred == i,0],data_new[y_pred == i,1],data_new[y_pred == i,2],marker = ".") ax.view_init(elev = 60,azim = 30) ax.set_zlabel('Z') ax.set_ylabel('Y') ax.set_xlabel('X') plt.show() 您可能感兴趣的文章:python用opencv完成图像分割并进行目标物的提取5行Python代码实现图像分割的步骤详解Python实现投影法分割图像示例(二)Python实现投影法分割图像示例(一)



k-means Python

需要 登录 后方可回复, 如果你还没有账号请 注册新账号