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