How to get Hounsfield units from raw pixel data for CT?

Get the slope and intercept from the header of the file then you could write a function or create a look up table to generate values based on: HU = Gray_Value * slope + intercept.