In cases where the image has fewer significant bits than the bit depth of the PNG-file, the image encoder that produces the PNG-file must store the original significant bits as the most significant bits of the pixel data, but has the option of filling in the (undefined) least significant bits as it wishes, according to the PNG standard.
One common method of doing this is "left-bit replication", which you have observed. This has the effect of scaling the original data (approximately linearly) to fill the dynamic range allowed by the bit depth of the PNG-file. This accounts for the data repetition observed.
The image decoder has the option of ignoring the number of significant bits, but the original data can always be obtained by bit-shifting out the least significant bits.
You may use the BITSHIFT function in MATLAB to recover the original data. For instance, with the 10-bit image with 16-bit color depth:
data = imread('foo.png');
data = bitshift(data, 10 - 16);
Best Answer