OpenCV:相当于Matlab的imhist(),带有智能箱

时间:2015-11-29 12:47:02

标签: matlab opencv image-processing

在Matlab中,当您使用带有多个二进制位的histogram = imhist(img, 40); 函数作为参数时,智能选择二进制位,如下面的调用,返回40个二进制位图:

calcHist()

例如,[0,25]范围内的强度水平明显不同于范围内的强度水平[230,255],<强度>随着强度水平的增加,容器范围变得更大< /强>

例如,在有50个分档的直方图中,我期望值 0 5 在同一个bin中,但我绝对希望 250 255 在同一个bin中。

下面的图表显示了它 - 您可以看到在较低强度级别,差异更加明显:

Diagram

在OpenCV的imhist()中,所有垃圾箱的大小都相同,即它没有考虑强度等级的这个事实。

  • 在OpenCV中是否有Matlab的imhist()实现?
  • 是否可以在某处获得imhist()的Matlab实现,以便我们可以尝试将其“翻译”为OpenCV?

修改

我刚查过它,并找到了1. [0, 31] -> 32 colors 2. [32, 95] -> 64 colors 3. [96, 159] -> 64 colors 4. [160, 223] -> 64 colors 5. [224, 255] -> 32 colors 如何运作的以下详细信息:

使用5个直方图箱,将计算以下范围:

1.  [0, 14]    -> 15 colors
2.  [15, 42]   -> 28 colors
3.  [43, 70]   -> 28 colors
4.  [71, 99]   -> 29 colors
5.  [100, 127] -> 28 colors
6.  [128, 155] -> 28 colors
7.  [156, 184] -> 29 colors
8.  [185, 212] -> 28 colors
9.  [213, 240] -> 28 colors
10. [241, 255] -> 15 colors

另一个有10个箱子的例子:

imhist(im, num_bins)

奇怪......但这就是它的运作方式..

看起来x = 256 / (n-1)的工作方式如下(伪代码):

  1. 计算n
  2. (n-2)个箱子。如果我们删除第一个bin和最后一个bin,我们会有x个bin。让我们让每个箱子都有x强度等级范围。
  3. 我们已将(n-2)分配给x个分区,我们仍然剩下一个x = 256 / (5 - 1); % This results 64 and is going to be the size of the central bins % Hence, now the size of the first and the second bin will be 32 each 个分区。我们将它分为第一个箱子的一半和最后一个箱子的一半。
  4. 5个箱子的例子:

    {{1}}

0 个答案:

没有答案