MATLAB Answers

Read 10 bit raw image data in matlab using uint16, why it is read as 12 bit ???

31 views (last 30 days)
joynjo
joynjo on 7 Jun 2018
Commented: joynjo on 7 Jun 2018
I read a 10bits multispectral raw image data using uint16 as follows
fid=fopen(file_name,'r');
a=fread(fid,width*height*band,'uint16');
fclose(fid);
but I got the maximum value of this data is 4095, it means that my data is read as 12-bit data. Is there anyone know why?
I also tried to read the same data in uint32 and the result becomes 28-bit data.
why there is a 4-bit difference here?

Accepted Answer

Walter Roberson
Walter Roberson on 7 Jun 2018
When a manufacturer makes two devices with different precision, the manufacturer often "left justifies" the lower-precision values to the width of the higher precision, so that the value range is still the same between the two devices, but the higher precision device returns values that are more precise.
For the same reason, it is not uncommon for manufacturers to output 12 bit values as the left-most 12 bits (12 most significant) in a 16 bit field -- leaving room for a future more precise device with the same value range but higher accuracy. This relieves the need to rewrite processing software.
You should look at min(diff(unique(a))) . If it is 4 then you have 10 bits worth of data; if it is 1 then you have 12 actual bits worth of data.
Another thing that happens is that 10 bit data that has been recorded raw with a bayer mosaic might be left shifted and interpolated to 12 bits of RGB

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!