Reading a 10 bit unsigned int file using Numpy

Viewed 13

I have a binary file that I want to read in to numpy using the fromfile function. If the data is formatted in uint8, there is no issue as Numpy has that type built in. Is there any way to do this for unsigned 10 bit integers?

import numpy as np 

fileName8bit = 'test_8bit.yuv'
fileName10bit = 'test_10bit.yuv'


data8 = np.fromfile(fileName8bit, np.uint8) # No issue here
data10 = np.fromfile(fileName10bit, np.uint10) # np.uint10 is not a datatype

Is there any possible workaround to using an unsigned 10 bit int data type?

0 Answers
Related