Skip to main content

DICOM -> JPG/PNG/BMP/TIFF/ndarray

Project description

dicom2jpg

Converts DICOM to JPG/PNG/BMP/TIFF and numpy.ndarray

Installation

pip install dicom2jpg

Introdunction

import dicom2jpg

dicom_img_01 = "/Users/user/Desktop/img01.dcm"
dicom_dir = "/Users/user/Desktop/Patient_01"
export_location = "/Users/user/Desktop/BMP_files"

# convert single DICOM file to numpy.ndarray for further use
img_data = dicom2jpg.dicom2img(dicom_img_01)

# convert single DICOM file to jpg format
dicom2jpg.dicom2jpg(dicom_img_01)  

# convert all DICOM files in dicom_dir folder to png format
dicom2jpg.dicom2png(dicom_dir)  

# convert all DICOM files in dicom_dir folder to bmp, to a specified location
dicom2jpg.dicom2bmp(dicom_dir, target_root=export_location) 

# convert DICOM ByteIO to numpy.ndarray
img_data = dicom2jpg.io2img(dicomIO)

dicom2jpg converts DICOM images to JPG/PNG/BMP/TIFF formats and to numpy.ndarray. It applies window center(level) and window width adjustment, or VOI LUT function to the images, which makes output files looks like what we see on standard DICOM viewers.

dicom2jpg.dicom2jpg(origin, target_root=None, anonymous=False, multiprocessing=True)

dicom2jpg.dicom2png(origin, target_root=None, anonymous=False, multiprocessing=True)

dicom2jpg.dicom2bmp(origin, target_root=None, anonymous=False, multiprocessing=True)

dicom2jpg.dicom2tiff(origin, target_root=None, anonymous=False, multiprocessing=True)

dicom2jpg.dicom2img(origin)

dicom2jpg.io2img(dicomIO)

  • origin can be a single DICOM file or folder contains DICOM files

  • target_root is would be the same root folder of the origin if not specified

  • exported files will be in

    target_root/Today/PatientID_filetype/StudyDate_StudyTime_Modality_AccNum/Ser_Img.filetype

  • anonymous file paths are

    target_root/Today/Patient_SerialNum/ModalitySerialNum_Modality/Ser_Img.filetype

Image examples

CT MR CXR

Todo

  • Support multi-frame images
  • Image compression
  • Support overlays

Performance

  • Environment: Windows10, Jupyter Notebook, Python 3.8.10
  • 598MB 1873 files {'CT': 1528, 'CR': 52, 'MR': 174, 'DX': 36}
  • Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz. 4 Cores (hyper-threading off)
  • Tested on Ramdisk (no physical HDD was tortured :P)
multiprocessing anonymous duration (seconds)
False True 154.6-159.7
True True 79.2-82.9
False False 157.9-162.8
True False 56-58.5

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dicom2jpg-0.1.1.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dicom2jpg-0.1.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file dicom2jpg-0.1.1.tar.gz.

File metadata

  • Download URL: dicom2jpg-0.1.1.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.10

File hashes

Hashes for dicom2jpg-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5210d3e5f6eac10e6e307fa249f929e45c4a528235427d13d697b1483e1b74fc
MD5 058a72151493f22dabc6d5cac3c4d3e6
BLAKE2b-256 e46b56671bd1008959f8bb15cf85771ee067a298ec4680747d911985b6fb1ca0

See more details on using hashes here.

File details

Details for the file dicom2jpg-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: dicom2jpg-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.10

File hashes

Hashes for dicom2jpg-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 36c297be9c62f0e121481fbfce9d0263becfe1a222ed9e000182579cc0e3d045
MD5 2b43b546b2937cd09a19767bd6cb0bdb
BLAKE2b-256 86d41c9fef9c3664b9fa7efed7e911a85337a222d7bf6f7c47fb06683b6b7983

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page