https://github.com/tdiprima/dicom-image-converter
DICOM JPEG Decoding
https://github.com/tdiprima/dicom-image-converter
dcm4che dicom image-conversion pydicom
Last synced: 3 months ago
JSON representation
DICOM JPEG Decoding
- Host: GitHub
- URL: https://github.com/tdiprima/dicom-image-converter
- Owner: tdiprima
- License: mit
- Created: 2025-02-06T18:57:44.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-02-07T22:11:46.000Z (8 months ago)
- Last Synced: 2025-06-07T07:36:42.997Z (4 months ago)
- Topics: dcm4che, dicom, image-conversion, pydicom
- Language: Java
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DICOM Image Converter


This project aims to:
- Read DICOM files from a directory.
- Detect the image encoding (JPEG, JPEG 2000, etc.).
- Convert JPEG 2000 images to standard JPEG.
- Update the DICOM metadata to reflect the conversion.
- Save the processed DICOM files without modifying the originals.---
## Current Status
### Java Maven Code
- **What Works**:
- Reads DICOM files.
- Detects some image encodings correctly.
- **Known Limitations**:
- Re-encoding JPEG 2000 → JPEG isn't fully functional in Java due to missing codec support.
- Additional libraries (like [jai-imageio-jpeg2000](https://github.com/jai-imageio/jai-imageio-jpeg2000) or OpenCV-based plugins) may be required, but can still cause compatibility issues.### Getting Started
```sh
mvn clean package
java -jar target/dicom-image-converter-1.0-SNAPSHOT.jar ./img/
```### Python Scripts
- **Scripts**:
- `dicom_jpeg2000_to_jpeg.py` – Decodes JPEG/JPEG 2000 DICOM images to `.jpg` files.
- `dicom_jpeg2000_to_jpeg_dicom.py` – Re-encodes JPEG 2000 DICOMs into standard JPEG DICOMs.
- **Dependencies**:
- [pydicom](https://pydicom.github.io/)
- [pylibjpeg](https://github.com/pydicom/pylibjpeg)
- [pylibjpeg-openjpeg](https://github.com/pydicom/pylibjpeg-openjpeg)
- [Pillow](https://pillow.readthedocs.io/en/stable/)The Python solution is currently the most reliable way to re-encode JPEG 2000 DICOMs to JPEG.
---
## Future Plans
1. **Java Codec Improvements**
Investigate or add the necessary dcm4che Image I/O or JAI ImageIO plugins to fully support JPEG 2000 → JPEG conversion in Java.2. **Refinement & Testing**
Expand test coverage with multi-frame DICOMs, 16-bit grayscale images, and color images.3. **Documentation**
Provide step-by-step usage instructions for both the Java code and the Python scripts.---
## Getting Started (Python)
1. **Install Dependencies**:
```bash
pip install pydicom pillow pylibjpeg pylibjpeg-openjpeg
```2. **Run the Conversion**:
```bash
python dicom_jpeg2000_to_jpeg_dicom.py
```This will read `.dcm` files from `../img` by default and save re-encoded DICOM files in a new `processed/` folder.
---
## License
[MIT](LICENSE)