fread function for reading 10 bit raw file.
Show older comments
When I read 10 bit raw file in fread as Uint16 and as uint8 the size of the data is doubled in case of reading as uint8. Wanted to know how fread function internally reads 10 bit data in uint8 and uint16 data type.
sample of my code below:
fid = fopen('2.raw');
data = fread(fid,'uint16');
fclose(fid);
Accepted Answer
More Answers (1)
Jan
on 10 Mar 2022
If the 10bit data are written as bitstream, 8 numbers use 10 bytes. If you read this as UINT8 or UINT16 does not matter: the sequence of bits in the memory is equal. If these bits are interpreted as UINT8 or UINT16 will change the values, of course.
A difference is that the number if bytes need not be even, such that reading the file as UINT16 might skip the last byte.
To import the data use the fomat UBIT10:
fid = fopen('2.raw');
data = fread(fid, 'ubit10=>uint16');
fclose(fid);
1 Comment
Gayathri Sankaran
on 11 Mar 2022
Categories
Find more on Data Import and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!