In the traditional K-means clustering algorithm, the number of clusters is difficult to be estimated and the selection of the initial cluster centers has a great influence on the clustering results. To solve these problems, we proposed cell-based K-means clustering algorithm. The objects closer to a cluster center are dense, and the objects farther away from a cluster center are sparse. Therefore, we analyzed the distribution of objects by dividing the data space into cells. Theoretical analysis and experimental results show that the improved algorithm not only can get the number of clusters, but also can select the initial clustering centers close to the true cluster centers. In addition, we applied the improved algorithm to distributed system, which can achieve both the security of data and the accuracy of clustering.