【发布时间】:2015-12-16 16:56:01
【问题描述】:
我正在为灰度图像编写自己的强度直方图,其中将 bin 的数量传递给函数。 这是我到目前为止所拥有的:
std::vector<unsigned int> Image::histogram(const int bins)
{
std::vector<unsigned int> histogram(bins ,0);
for (unsigned int i(0); i < bins; i++)
{
for (unsigned int j(0); j < m_height * m_width; ++j)
{
if (i == m_p_image[j])
{
histogram[i]++;
}
}
}
return histogram;
}
这非常适用于 256 个 bin,因为每个计数都添加到直方图中,但是对于 128 个 bin,它会错过图像的后半部分,我知道如果 bin 大小小于 256,我需要实现一种将点分组在一起的方法但我不确定该怎么做。
【问题讨论】:
标签: c++ image-processing histogram