A Python 3.8+ wrapper for Thomas Richter's libjpeg, with a focus on use as a plugin for pylibjpeg.
Linux, MacOS and Windows are all supported.
Installing the current releasepip install pylibjpeg-libjpegInstalling the development version
Make sure Python and Git are installed. For Windows, you also need to install Microsoft's C++ Build Tools.
git clone --recurse-submodules https://github.com/pydicom/pylibjpeg-libjpeg python -m pip install pylibjpeg-libjpeg
Encoding of JPEG images is not currently supported
Supported Transfer Syntaxes UID Description 1.2.840.10008.1.2.4.50 JPEG Baseline (Process 1) 1.2.840.10008.1.2.4.51 JPEG Extended (Process 2 and 4) 1.2.840.10008.1.2.4.57 JPEG Lossless, Non-Hierarchical (Process 14) 1.2.840.10008.1.2.4.70 JPEG Lossless, Non-Hierarchical, First-Order Prediction (Process 14 [Selection Value 1]) 1.2.840.10008.1.2.4.80 JPEG-LS Lossless 1.2.840.10008.1.2.4.81 JPEG-LS Lossy (Near-Lossless) Image Compression With pylibjpeg and pydicomfrom pydicom import dcmread from pydicom.data import get_testdata_file ds = dcmread(get_testdata_file('JPEG-LL.dcm')) arr = ds.pixel_array
You can also decode JPEG images to a numpy ndarray:
from libjpeg import decode with open('filename.jpg', 'rb') as f: # Returns a numpy array arr = decode(f.read()) # Or simply... arr = decode('filename.jpg')
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4