Skip to content

Commit

Permalink
Comment explaining conversion "odd" of pixel array type. (didymo#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fincap authored Oct 25, 2023
1 parent dc1f91a commit c736006
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Model/CalculateImages.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ def scaled_pixmap(np_pixels, window, level, width, height,
:return: pixmap, a QPixmap of the slice
"""

# Rescale pixel arrays
''' The numpy pixel array is converted to a signed int before any additional operations are applied.
This is due to the pydicom.dataset.Dataset.convert_pixel_data() function returning a numpy array of dtype uint16.
The dtype is dependent on the DICOM elements: BitsAllocated and PixelRepresentation.
dtype could theoretically return any combination of unsigned/signed 1, 8, 16, 32, or 64 bit values.
Undefined behaviour when np_pixels is any type other than uint16 or int16. '''
np_pixels = np_pixels.astype(np.int16)
if window != 0 and level != 0:
# Transformation applied to each individual pixel to unique
Expand Down

0 comments on commit c736006

Please sign in to comment.