针对灰度直方图在影像分类时需要考虑阈值和K-最近邻分类算法分类效率低等问题,提出了一种基于灰度直方图与KNN相结合的影像分割算法:首先对待分割的影像进行灰度直方图统计;其次利用灰度直方图对影像进行硬阈值的划分,得到已知类别样本和未标记样本;然后选择一定数量已知类别的样本对KNN分类器进行训练;最后利用KNN分类器对未标记样本进行类别划分,得到最终分割图像。实验结果表明,该算法结合了灰度直方图高效性和KNN高精度的优势,避免了直方图分割最佳阈值的选取;与传统的KNN算法相比,本文算法大大提高了分类效率,且精度相当,满足实际生产应用的需求。
Because of the gray histogram needs to be considered threshold value in the image classification and the K-nearest neighbor classification algorithm have low efficiency of classification problems,an approach for images segmentation based on gray histogram and K-nearest neighbors algorithm is proposed.Firstly,statistical gray histogram of the image is given.Second,hard threshold of the histogram is divided pixel samples into known categories of samples and did not labeled samples.Then it selects a certain number of the known categories of samples training the K-nearest neighbors classifier,using the K-nearest neighbors classifier to classification the unlabeled samples and get the final segmentation image.The experimental results show that the proposed algorithm combines the advantage of the gray histogram high speed classification and K-nearest neighbors classification precision,and don′t need to choose the best segmentation threshold.Compared with traditional K-nearest neighbors algorithm for image segmentation,this proposed algorithm has greatly increased the efficiency of classification and also has the same precision.This proposed algorithm meet the needs of actual production application.