python-opencv-kmeans聚类

python-opencv-kmeans聚类

1 python-opencv-kmeans聚类

# -*- coding: utf-8 -*-
"""
Created on Sat Dec 31 15:35:59 2016

@author:  http://blog.csdn.net/lql0716
"""

import cv2
import numpy as np

point = np.float32([[0,1],[1,1],[1,0],[1,2],[-1,0],[-1,-1],[7,8],[9,11],[1,15]])
point = point.reshape((point.shape))

criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 10, 1.0)
flags = cv2.KMEANS_RANDOM_CENTERS

ompactness,labels,centers = cv2.kmeans(point,2,criteria,1, flags)


#http://docs.opencv.org/2.4/modules/core/doc/clustering.html?highlight=kmeans#cv2.kmeans

kmeans官方文档:

  • http://docs.opencv.org/2.4/modules/core/doc/clustering.html?highlight=kmeans#cv2.kmeans
  • http://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_ml/py_kmeans/py_kmeans_opencv/py_kmeans_opencv.html?highlight=kmeans

你可能感兴趣的:(Python,OpenCV--Python,opencv)