Skip to main content

dicom2jpg

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

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)

dicom2jpg.dicom2png(origin, target_root=None)

dicom2jpg.dicom2bmp(origin, target_root=None)

dicom2jpg.dicom2tiff(origin, target_root=None)

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

Image examples

CT MR CXR

Installation

pip install dicom2jpg

Todo

  • Multiprocessing for speeding up
  • Support multi-frame images
  • More naming choices, including anomynous file names
  • Image compression
  • Support overlays

Metadata

Release files for dicom2jpg 0.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dicom2jpg 0.0.9
File Size Uploaded Provenance Actions
dicom2jpg-0.0.9.tar.gz 6.8 kB Without provenance Details for dicom2jpg-0.0.9.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dicom2jpg 0.0.9
File Interpreter ABI Platform Actions
dicom2jpg-0.0.9-py3-none-any.whl Python 3 none any Details for dicom2jpg-0.0.9-py3-none-any.whl

Total release size: 14.3 kB

Release files / dicom2jpg-0.0.9.tar.gz

Download URL dicom2jpg-0.0.9.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6b8bd0ac7997a3299569233ef5fc1fb3c5cf105f4d015ac79a860aa555a8958d
BLAKE2b-256 checksum
How to use checksums
363e0f6d93185b73e4e77b51e470ecb006c6e19e305698d2ade6a0973958f50d
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / dicom2jpg-0.0.9-py3-none-any.whl

Download URL dicom2jpg-0.0.9-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a86ed93d719b4dbdc700e3d94f16e8ca8cf6e4873a5f251925b602bf549c23ef
BLAKE2b-256 checksum
How to use checksums
e5b2d36c7cfeb7f2b3369ad648df9354d421211a4228bf007e50a7b9c5e086fe
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for dicom2jpg 0.0.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page