Skip to content
Snippets Groups Projects
Commit 8e4437bb authored by Tamino Huxohl's avatar Tamino Huxohl
Browse files

introduce custom dicom filetype and make scaling of images optional

parent c2d5166e
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@ from typing import Tuple
import numpy as np
import pydicom
dcm_type = pydicom.dataset.FileDataset
"""
Since DICOM images only allow images stored in short integer format,
......@@ -37,7 +38,10 @@ def load_dcm(filename: str) -> Tuple[pydicom.dataset.FileDataset, np.ndarray]:
:return: the dicom header and the scaled image as a numpy array
"""
dcm = pydicom.dcmread(filename)
image = dcm.pixel_array / dcm[DCM_TAG_PIXEL_SCALE_FACTOR].value
if DCM_TAG_PIXEL_SCALE_FACTOR in dcm:
image = dcm.pixel_array / dcm[DCM_TAG_PIXEL_SCALE_FACTOR].value
else:
image = dcm.pixel_array
return dcm, image
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment