Reputation: 87
I haven't been able to find the range of values that is returned from .pixel_array so I'm not sure how to scale the values to a custom range like [0,1]. Is there a pydicom inbuilt function that does this already?
Upvotes: 3
Views: 450
Reputation: 1330
A combination of Bits Stored and Pixel Representation should be enough for Pixel Data:
from pydicom import dcmread
ds = dcmread("/path/to/dataset")
if ds.PixelRepresentation == 0:
# Unsigned integers
min_px = 0
max_px = 2**ds.BitsStored - 1
else:
# Signed integers
min_px = -2**(ds.BitsStored - 1)
max_px = 2**(ds.BitsStored - 1) - 1
Upvotes: 4