{"id":13476126,"url":"https://github.com/ykuo2/dicom2jpg","last_synced_at":"2025-03-27T02:31:31.551Z","repository":{"id":50066642,"uuid":"372441634","full_name":"ykuo2/dicom2jpg","owner":"ykuo2","description":"A simple Python function tool to convert DICOM files into jpg/png/bmp/tiff files and numpy.ndarray","archived":false,"fork":false,"pushed_at":"2023-01-03T17:44:55.000Z","size":32388,"stargazers_count":38,"open_issues_count":2,"forks_count":12,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-13T23:34:42.211Z","etag":null,"topics":["converter","dicom","dicom-files","dicom-images","image","image-processing","medical-image-processing","medical-imaging"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ykuo2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-31T08:50:28.000Z","updated_at":"2025-02-20T05:10:02.000Z","dependencies_parsed_at":"2023-02-01T08:31:03.528Z","dependency_job_id":null,"html_url":"https://github.com/ykuo2/dicom2jpg","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ykuo2%2Fdicom2jpg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ykuo2%2Fdicom2jpg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ykuo2%2Fdicom2jpg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ykuo2%2Fdicom2jpg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ykuo2","download_url":"https://codeload.github.com/ykuo2/dicom2jpg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245769359,"owners_count":20669164,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["converter","dicom","dicom-files","dicom-images","image","image-processing","medical-image-processing","medical-imaging"],"created_at":"2024-07-31T16:01:26.817Z","updated_at":"2025-03-27T02:31:31.221Z","avatar_url":"https://github.com/ykuo2.png","language":"Jupyter Notebook","funding_links":[],"categories":["Jupyter Notebook"],"sub_categories":[],"readme":"# dicom2jpg\nConverts DICOM to `JPG/PNG/BMP/TIFF` and `numpy.ndarray`\n\n\n\n# Installation\n```\npip install dicom2jpg\n```\n\n# Introdunction\n```\nimport dicom2jpg\n\ndicom_img_01 = \"/Users/user/Desktop/img01.dcm\"\ndicom_dir = \"/Users/user/Desktop/Patient_01\"\nexport_location = \"/Users/user/Desktop/BMP_files\"\n\n# convert single DICOM file to jpg format\ndicom2jpg.dicom2jpg(dicom_img_01)  \n\n# convert all DICOM files in dicom_dir folder to png format\ndicom2jpg.dicom2png(dicom_dir)  \n\n# convert all DICOM files in dicom_dir folder to bmp, to a specified location\ndicom2jpg.dicom2bmp(dicom_dir, target_root=export_location) \n\n# convert single DICOM file to numpy.ndarray for further use\nimg_data = dicom2jpg.dicom2img(dicom_img_01)\n\n# convert DICOM ByteIO to numpy.ndarray\nimg_data = dicom2jpg.io2img(dicomIO)\n\n```\n**dicom2jpg** \nconverts DICOM images to `JPG/PNG/BMP/TIFF` formats and to `numpy.ndarray`. \nIt piplines the lookup transformations by applying Modality LUT, VOI LUT, and Presentation LUT to the images,\nwhich makes output files looks like what we see on standard DICOM viewers.\n\n\n`dicom2jpg.dicom2jpg(origin, target_root=None, anonymous=False, multiprocessing=True)`\n\n`dicom2jpg.dicom2png(origin, target_root=None, anonymous=False, multiprocessing=True)`\n\n`dicom2jpg.dicom2bmp(origin, target_root=None, anonymous=False, multiprocessing=True)`\n\n`dicom2jpg.dicom2tiff(origin, target_root=None, anonymous=False, multiprocessing=True)`\n\n- origin can be a single DICOM file, a folder, or a list/tuple of file/folder\n- target_root would be the root folder of the first file/folder if not specified\n- exported files paths would be\n\n    \u003e *target_root / Today / PatientID_Filetype / StudyDate_StudyTime_Modality_AccNum / Ser_Img.Filetype* \n\n- anonymous files paths would be\n\n    \u003e *target_root / Today / Patient_SerialNum / ModalitySerialNum_Modality / Ser_Img.Filetype*\n\n\n`dicom2jpg.dicom2img(origin)`\n\n`dicom2jpg.io2img(dicomIO)`\n\n- converting dicom files or ByteIO to ndarray\n- ndarray is in 8 bit; RGB format if it's a color image\n\n\n\n# Image examples\n\n|   CT   |   MR    |CXR|\n|------------|-------------|------------|\n|\u003cimg src=\"https://user-images.githubusercontent.com/37744685/120668917-8724cc00-c4c1-11eb-957b-82e59ba03806.jpg\" width=\"250\"\u003e|\u003cimg src=\"https://user-images.githubusercontent.com/37744685/120668923-8855f900-c4c1-11eb-80fd-8c0c2235014b.jpg\" width=\"250\"\u003e|\u003cimg src=\"https://user-images.githubusercontent.com/37744685/120671666-32368500-c4c4-11eb-92fd-726dc02c966c.jpg\" width=\"250\"\u003e|\n\n\n\n# Todo\n- Support multi-frame images\n- Image compression\n- Support overlays\n   \n   \n# Performance\n- Environment: Windows10, Jupyter Notebook, Python 3.8.10\n- 598MB 1873 files {'CT': 1528, 'CR': 52, 'MR': 174, 'DX': 36}\n- Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz. 4 Cores (hyper-threading off)\n- Tested on Ramdisk (no physical HDD was tortured :P)\n\n| multiprocessing  |  anonymous |  duration (seconds) |\n|------------|-------------|------------|\n|False|True|154.6-159.7|\n|True|True|79.2-82.9|\n|False|False|157.9-162.8|\n|True|False|56-58.5|\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fykuo2%2Fdicom2jpg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fykuo2%2Fdicom2jpg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fykuo2%2Fdicom2jpg/lists"}