创建标准化直方图

Creating a normalized histogram

我正在写一篇关于从人脸识别头发的研究论文,在研究论文中我卡在了以下部分:

We downsample each of Y,Cb and Cr channels into 64 levels.Then we can construct a three-dimensional color histogram in which each dimension has 64 bins. We normalize the color histogram in order to approximate the hair color likelihood distribution.

据我理解这个陈述,我得到了 3 个不同的直方图,我必须创建一个新的编译直方图,因为我没有在我的项目中使用 MATLAB,所以我需要找到一种方法来规范化 3 个不同的直方图直方图变成 1,我用谷歌搜索了很多但一无所获,有人可以帮我解决这个问题吗?我需要公式或类似的东西来实现这个, 首选语言是:

python, C++

我怀疑是3个直方图。这听起来更像是你有一个 Y、Cb、Cr 的 64x64x64 值的 3 维数组,其中每个存储桶(在该存储桶的 3D 阵列中)是对有多少人拥有该特定头发颜色的计数。归一化只是将每个桶除以总计数(从多少人那里获得颜色样本)的问题。 有了这个假设,下面的代码就可以工作了(我使用 16 而不是 64):

# Initialize 3D array to random counts
import random
cbucket = {}
for y in range(0,16):
    for cb in range(0,16):
        for cr in range(0,16):
            cbucket[ y,cb,cr ] = float(round(random.uniform(0,10)))

# Find total count
tcount = 0
for y in range(0,16):
    for cb in range(0,16):
        for cr in range(0,16):
            tcount += cbucket[ y,cb,cr ]

print("tcount: %6.2f " % tcount)

# now normalize
for y in range(0,16):
    for cb in range(0,16):
        for cr in range(0,16):
            cbucket[ y,cb,cr ] = cbucket[ y,cb,cr ]/tcount