//计算直方图
vector<vector<int>> CalHistgram(const Mat& img) {
vector<vector<int>>histogram(256);
for (int i = 0; i < histogram.size(); ++i)
histogram[i].resize(3);
for (int row = 0; row < img.rows; row++)
{
for (int col = 0; col < img.cols; col++)
{
auto vec3b = img.at<Vec3b>(row, col);
histogram[vec3b[0]][0]++;
histogram[vec3b[1]][1]++;
histogram[vec3b[2]][2]++;
}
}
return histogram;
}
直方图计算C++代码实现
最新推荐文章于 2023-03-15 20:05:13 发布