Skip to main content

DICOM -> JPG/PNG/BMP

Project description

dicom2jpg

Converts DICOM to JPG/PNG/BMP

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 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) 

dicom2jpg converts DICOM images to JPG/PNG/BMP formats. It also 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)

dicom2jpg.dicom2png(origin, target_root)

dicom2jpg.dicom2bmp(origin, target_root)

  • 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

Known issue

  • converting multi-frame such as fluoroscopic image array would result in error
error: OpenCV(4.0.1) C:\ci\opencv-suite_1573470242804\work\modules\imgcodecs\src\loadsave.cpp:667: error: (-215:Assertion failed) image.channels() == 1 || image.channels() == 3 || image.channels() == 4 in function 'cv::imwrite_'

Todo

  • Multiprocessing for speeding up
  • Support multi-frame images
  • Support TIFF format

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.0.7.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

dicom2jpg-0.0.7-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dicom2jpg-0.0.7.tar.gz
  • Upload date:
  • Size: 6.1 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.0.7.tar.gz
Algorithm Hash digest
SHA256 9b0aa2bb3a4048ef2c1c1ab875e0e3c438d8e3dfb454554654cdb49619aca0b4
MD5 69f0b45e04ad6c540b529f5d2744d5fb
BLAKE2b-256 a5d50b87a1f452728c5536154f26ca2e5765cc4c11a7d3c75465e0bf395eaa9f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dicom2jpg-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 6.7 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.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 b3a6ab1499ae6743d6a51aefcaf5d777cc57822bec301a30ce5298120fe7881b
MD5 5fe53b82097e5b7120ae9a65250e5b80
BLAKE2b-256 767a9f73e081a00effa30c9fe415841752a95111b9dcd29c1aa1e642ee7deea1

See more details on using hashes here.

Supported by

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