将 Dicom 像素值重新缩放到 [0,1] 范围内

Rescaling Dicom pixel values to be in the range [0,1]

我无法找到从 .pixel_array 返回的值的范围,所以我不确定如何将这些值缩放到 [0,1] 等自定义范围。是否有 pydicom 内置函数可以执行此操作?

Bits StoredPixel Representation 的组合对于 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