将 6/10/12 位流转换为缩放的无符号字符/短整型
在 PC 领域,一个字节通常表示 8 位的内存边界对齐,计算机将其视为单个单元。在小型计算机和大型计算机中,也可以使用更长的序列,例如 16 位和 32 位(分别称为全字和双字)。
但在遥感领域,传感器/探测器通过使用自己的辐射分辨率(例如 6 位、10 位和 12 位)来测量来自大气和地球的辐射强度的变化。因此,地面站捕获的遥感原始数据图像总是以6位、10位或12位BCD流的形式打包。这些数据逐条扫描线存储。
我的工作是从打开的二进制文件中逐条读取这种扫描线,并将其存储到 unsigned char 源缓冲区一段时间。对于 6 位流,我必须扩展到 8 位(一个字节),对于 10 位或 12 位流,我将使它们缩放为无符号短整数。最后,我应该得到一个无符号字符(6 位)或无符号短目标缓冲区。
您能告诉我该怎么做吗? C/C++ 代码演示将受到高度赞赏!谢谢。
10101010 01110101 00011001
| |
-----------
10-bit BCD
10101010 01110101 00011001
| |
-----------
10-bit BCD
10101010 01110101 01100110
| |
------------
10-bit BCD
In the world of PC's, a byte usually denotes a memory boundary alignment of 8 bits which the computer treats as a single unit. In mini and mainframe computers, longer sequences like 16 and 32 bits (referred to as full words and double words respectively) are also possible.
But in the remote sensing world, the sensors/detectors are used to measure changes in the intensity of radiation from the atmosphere and the Earth by using their own radiometric resolutions such as 6-bit, 10-bit, and 12-bit. Therefore, the remotely sensed raw data image captured by the ground station are always packed in the form of 6-bit, 10-bit, or 12-bit BCD streams. These data are stored scanline by scanline.
My job is to read this kind of scanline one by one form an opend binary file, and stored to an unsigned char source buffer for a while. For 6-bit stream, I must scale up to 8-bit (one byte), and for 10-bit or 12-bit stream, I will make them to be scaled unsigned short integer. Finally, I should get an unsigned char (for 6-bit) or unsigned short destination buffer.
Would you please show me how to do that? C/C++ code demo will be highly appreciated! Thank you.
10101010 01110101 00011001
| |
-----------
10-bit BCD
10101010 01110101 00011001
| |
-----------
10-bit BCD
10101010 01110101 01100110
| |
------------
10-bit BCD
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常的方法是左移输入和输出之间的位数差,然后添加输入的高位以填充低位。
对于较低位,还有一种我不常见的替代方法 - 用噪声填充它们。这掩盖了原始样本中的一些量化误差。
The usual way is to left shift by the difference in the number of bits between the input and the output, then add in the high order bits from the input to fill out the lower bits.
There's an alternate approach for the lower bits that I haven't seen very often - fill them with noise. This masks some of the quantization error in the original sample.