0

我想创建图像的深度直方图,以查看深度值的分布如何变化。但我不知道该怎么做,因为可能的深度太多了,计算每个深度会导致直方图有很多箱。就像 (480*640) 图像中的 307,200 个 bin。

在以下网页中:

http://www.i-programmer.info/programming/hardware/2714-getting-started-with-microsoft-kinect-sdk-depth.html?start=2

他们将深度值的数量除以 4,然后对数据执行位移调整以创建外观合理的显示:

for (int i = 0; i < PImage.Bits.Length; i += 2)
{
 temp= (PImage.Bits[i+1]<<8 |
               PImage.Bits[i])& 0x1FFF ;
 count[temp >> 2]++;
 temp <<= 2;
 PImage.Bits[i] = (byte) (temp & 0xFF);
 PImage.Bits[i + 1] = (byte) (temp >> 8);
}

我了解他们所做的操作,但我不明白这种方法如何将数据缩小到 1/4

那么,如何在不使用太多垃圾箱的情况下显示该信息以创建外观合理的显示?

有任何想法吗?

此致,

4

1 回答 1

1

这部分解释它:

有太多可能的深度,计算每个深度会导致直方图有很多箱,所以我们将距离除以四,这意味着我们只需要四分之一的箱数:

int[] count = new int[0x1FFF / 4 +1];

通过将深度值除以 4,您可以通过降低测量不同深度的分辨率来减少 bin 的数量。这允许的大小count数组的大小可以小 4 倍。

根据您的评论

就像 (480*640) 图像中的 307,200 个 bin。

我想你可能误解了直方图是什么。屏幕大小与 bin 数量无关。在整个场景中测量的每个不同深度级别只能获得一个数据点,它们根本与屏幕位置无关。


代码说明:

for (int i = 0; i < PImage.Bits.Length; i += 2)
{
    //gets the depth value by combining 2 adjacent bytes from the data into 
    //a 2 byte value and trims the value to a max of 8191 (2^13)
    temp= (PImage.Bits[i+1]<<8 |
                  PImage.Bits[i])& 0x1FFF;

    //divides the value by 4 and increments counter for that depth value
    count[temp >> 2]++;

    //multiply depth value by 4, trimming off the lower bits, I assume this  
    //makes the depth differences more obvious when we write the new depth 
    //value back to the image data
    temp <<= 2;

    //write the depth value back to the image buffer
    PImage.Bits[i] = (byte) (temp & 0xFF);
    PImage.Bits[i + 1] = (byte) (temp >> 8);
}
于 2014-08-05T01:28:03.903 回答