问题描述
- opencv中的kmeans函数
-
LBPimage是一个3通道的灰度图像。通过kmeans函数之后,分的两类,labels的各个分量都是0,只有第一个和最后一个元素是1.请问大神们,错在哪里。 Mat LBPimage=LBP(imgs); int nl = LBPimage.rows; int nc = LBPimage.cols; Mat points; points.create(nc*nl, 1, CV_32FC1); int n = 0; for (int i = 0; i < nl; i++) { for (int j = 0; j < nc; j++) { points.at<int>(n,0) = (int)LBPimage.at<Vec3b>(i, j)[0]; n++; } } Mat labels; Mat centers; kmeans(points, 2, labels, TermCriteria(CV_TERMCRIT_EPS,10000,0.01), 50, KMEANS_PP_CENTERS, centers);
时间: 2024-08-31 14:28:23