A Python wrapper for openjpeg, with a focus on use as a plugin for for pylibjpeg
Project description
pylibjpeg-openjpeg
A Python 3.8+ wrapper for openjpeg, with a focus on use as a plugin for pylibjpeg.
Linux, OSX and Windows are all supported.
Installation
Dependencies
Installing the current release
python -m pip install -U pylibjpeg-openjpeg
Installing the development version
Make sure Python, Git and CMake are installed. For Windows, you also need to install Microsoft's C++ Build Tools.
git clone --recurse-submodules https://github.com/pydicom/pylibjpeg-openjpeg
python -m pip install pylibjpeg-openjpeg
Supported JPEG Formats
Decoding
ISO/IEC Standard | ITU Equivalent | JPEG Format |
---|---|---|
15444-1 | T.800 | JPEG 2000 |
Encoding
Encoding of NumPy ndarrays is supported for the following:
- Array dtype: bool, uint8, int8, uint16, int16, uint32 and int32 (1-24 bit-depth only)
- Array shape: (rows, columns) and (rows, columns, planes)
- Number of rows/columns: up to 65535
- Number of planes: 1, 3 or 4
Transfer Syntaxes
UID | Description |
---|---|
1.2.840.10008.1.2.4.90 | JPEG 2000 Image Compression (Lossless Only) |
1.2.840.10008.1.2.4.91 | JPEG 2000 Image Compression |
1.2.840.10008.1.2.4.201 | High-Throughput JPEG 2000 Image Compression (Lossless Only) |
1.2.840.10008.1.2.4.202 | High-Throughput JPEG 2000 with RPCL Options Image Compression (Lossless Only) |
1.2.840.10008.1.2.4.203 | High-Throughput JPEG 2000 Image Compression |
Usage
With pylibjpeg and pydicom
from pydicom import dcmread
from pydicom.data import get_testdata_file
ds = dcmread(get_testdata_file('JPEG2000.dcm'))
arr = ds.pixel_array
Standalone JPEG decoding
You can also decode JPEG 2000 images to a numpy ndarray:
from openjpeg import decode
with open('filename.j2k', 'rb') as f:
# Returns a numpy array
arr = decode(f)
# Or simply...
arr = decode('filename.j2k')
Standalone JPEG encoding
Lossless encoding of RGB with multiple-component transformation:
import numpy as np
from openjpeg import encode_array
arr = np.random.randint(low=0, high=65536, size=(100, 100, 3), dtype="uint8")
encode_array(arr, photometric_interpretation=1) # 1: sRGB
Lossy encoding of a monochrome image using compression ratios:
import numpy as np
from openjpeg import encode_array
arr = np.random.randint(low=-2**15, high=2**15, size=(100, 100), dtype="int8")
# You must determine your own values for `compression_ratios`
# as these are for illustration purposes only
encode_array(arr, compression_ratios=[5, 2])
Lossy encoding of a monochrome image using peak signal-to-noise ratios:
import numpy as np
from openjpeg import encode_array
arr = np.random.randint(low=-2**15, high=2**15, size=(100, 100), dtype="int8")
# You must determine your own values for `signal_noise_ratios`
# as these are for illustration purposes only
encode_array(arr, signal_noise_ratios=[50, 80, 100])
See the docstring for the encode_array() function for full details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for pylibjpeg_openjpeg-2.4.0-cp313-cp313-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ab188bc25f9a40369b40f634d401ee53cde63167a171969bfb1ceeee7a4e16c |
|
MD5 | d8b979ec67e38c29ff24bbb608a18232 |
|
BLAKE2b-256 | 697b2aba91724fcc9fb34abfaa8537f7698934297b527986b7d239691ed01d9a |
Hashes for pylibjpeg_openjpeg-2.4.0-cp313-cp313-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91ba44272e0644203f6d16d6534a05430b9262e5fad95c942c5fbef0873c0b96 |
|
MD5 | aa33cbf62b63f1751aadf159076cdcb5 |
|
BLAKE2b-256 | 962c7cca02102ecfb0227f2ffd7d3f1419a4b7a4fd409063df337c7f046e39e1 |
Hashes for pylibjpeg_openjpeg-2.4.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f28a9caf88acf3d7c91b216d5447709e4867c59d683f1efe04caf68b3642993 |
|
MD5 | ddc7fcfdb0902669bf54297c7d7628f6 |
|
BLAKE2b-256 | ac7243271558f94f7d8a1ee61911ba3a01038c79782c08c637ea946666d1ec32 |
Hashes for pylibjpeg_openjpeg-2.4.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fcee9bea6371d7ff6351a56c2d5ca2eb0c83d2c28d5cc65ea2d69059e175c5bd |
|
MD5 | 5cecc570ebc86e0f7704ed99a3074b18 |
|
BLAKE2b-256 | ade4f43993a5f4041777939f53e763246f2e7c097979fbca376f73e02b6694a7 |
Hashes for pylibjpeg_openjpeg-2.4.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9b413302d19cdd487ea6674681c6bdb78aaa25f20b417570b839d453387ddaf |
|
MD5 | 181b9016087f79f6cd2015b171abbd29 |
|
BLAKE2b-256 | 795460e535375c01c74ac2ab75c76e146725616dfee77702f97e7d32e11549e4 |
Hashes for pylibjpeg_openjpeg-2.4.0-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63bf4cbe52fe48d4aeadadf7f0f391c41bc819c030e2b7c5d342e9efadc4b33b |
|
MD5 | 52367a651a0203ecc244bc507681e5c9 |
|
BLAKE2b-256 | 9b6a368230e433b99fe7c329b5dccfc4d5a5a95afef1fa40813900a8bf16f439 |
Hashes for pylibjpeg_openjpeg-2.4.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae5d57716fc8e397aec3af80183bfd2896f54bf0455a1d38c0839a0b5e24feaf |
|
MD5 | d449e73598d1ba669189c1a44e281fbc |
|
BLAKE2b-256 | c45c0317ad316723cffb476077e9b841ec9b2062364b04153f3bf1ce1a230eb1 |
Hashes for pylibjpeg_openjpeg-2.4.0-cp312-cp312-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc0302de682958d0b666892f362128ff87246d2816eac5a7841b46673e06e249 |
|
MD5 | caae0186dbdde7f42ad3bfca82a75d4d |
|
BLAKE2b-256 | 5473772949f88d3c88d5cdccd3a89dabeb7edfd5dc82f70d99e5caacffe48fb5 |
Hashes for pylibjpeg_openjpeg-2.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 423bb1ddb7237d2ff2bf8a231a22ce3a28e4d5375c9e714baa14df34521862da |
|
MD5 | 63b58bc8ecc398fec3adb235c71adf08 |
|
BLAKE2b-256 | b7d1490d5b8e43d50d8c988bd5b63604b35974b671a0068b773b48c0db2f7372 |
Hashes for pylibjpeg_openjpeg-2.4.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec316b7ef32c0300254ca87a50ad934d953f33b19db258638421260119269348 |
|
MD5 | ea3308d0bed734f61dc04c0c7c4e515c |
|
BLAKE2b-256 | b4d1175158b5c702e0108c54fdedfbfd461ec8dbadac6217ee2a2441a4b7a12d |
Hashes for pylibjpeg_openjpeg-2.4.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b42ea41fc4002624d55d421d26e0094fbeb35c0a6119ca0f61983f277cbc3285 |
|
MD5 | de13d2cbcdbcc8d1ffc58d2ea14ec111 |
|
BLAKE2b-256 | 2a6b581cda03a1e328d77ffa3440af9da7aa33b297ed49474e74ff43886e02b8 |
Hashes for pylibjpeg_openjpeg-2.4.0-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a35ef20c0c3541095e7d94e7fafc795718c5e28f6d27841e6154e0b0519f6d2 |
|
MD5 | 5a6bb3a0d1296b628fa1baad75be0504 |
|
BLAKE2b-256 | b25cea0aef0fd4964fb92e3025775a7d1ab9e076138fec0b4c061e6d0e634aad |
Hashes for pylibjpeg_openjpeg-2.4.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffbdc13b13a5760073168b3ca044083749ff00e9db23f390c6a8dd17659a2339 |
|
MD5 | a10f9cc4898ea98184ad85b087da1ee2 |
|
BLAKE2b-256 | 67049749e89e7d353e828a50ef0904ee9069a271305b92218c3e940a7f9e1bba |
Hashes for pylibjpeg_openjpeg-2.4.0-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13d43c710c003edbcb9de7e21e102482976590f258c624409cc7c2694502a676 |
|
MD5 | 279fc02b3f95b3a2e12a0122c34f49af |
|
BLAKE2b-256 | b764755a59ef8b28ffdd6ae6449158fd6c7f5d2181a526771bcd969c1465ea95 |
Hashes for pylibjpeg_openjpeg-2.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09071f255ca773196e5bde5b80a902e18b3a0a6342e46c88b109642e7aa4f36f |
|
MD5 | cb53e34f61cedd3243c753f0ad001aac |
|
BLAKE2b-256 | 6835223bb61b37f2d626af771c21924b72123a3527203bfd9072c9825b85e28b |
Hashes for pylibjpeg_openjpeg-2.4.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27f05f7ac316b95976097549b984b45a1d56710a5517fdf82cb103e3d5cf6d57 |
|
MD5 | 03f13a365c93cc88a55464b2e803aec2 |
|
BLAKE2b-256 | a615999c31a3efd31f838d7248355036805c6e17f86ecb30f26d209754192e47 |
Hashes for pylibjpeg_openjpeg-2.4.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 358fcc406fccdd8c5fa12755ad10027d0fca250feea809f5038b990269bdec2e |
|
MD5 | 46929703ece655bb53dada57af787164 |
|
BLAKE2b-256 | 362f5024d93409101f6ac8b395449557fbd43fd8ca876b7b2e59e9f02ce76834 |
Hashes for pylibjpeg_openjpeg-2.4.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18b50714ed1faf49e5bb67ba644791d18add81550dee1c66fee1eaa4eb97d92d |
|
MD5 | 750bc5a605ed78f3ba5cf10ac00bd792 |
|
BLAKE2b-256 | de4ffa9d5b9a3c4a4a1d8d4ab7949a718f01544ba250509f34e33db0f4e6cd64 |
Hashes for pylibjpeg_openjpeg-2.4.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c31078c304b3d96e91c5bf4e502dfe5cc925c2b1d8a5cb6aec0f70ee342d7648 |
|
MD5 | 8adbc637d4c2fdeb270386bdddc11281 |
|
BLAKE2b-256 | 2948ee668d1825fd7bf19b5497d34c7880558eb49bf4db01cf0cdbf40ec24746 |
Hashes for pylibjpeg_openjpeg-2.4.0-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c7d37488b0611af14d4b91dd2443615baee813c2db8f9e74fcad8a24c195635 |
|
MD5 | 78bd4910fc34998bb0004f879daa7adf |
|
BLAKE2b-256 | 7baa5cd554628ef47b3a4d4413bbedc96271e2c600b73ae80c8515b549817a1c |
Hashes for pylibjpeg_openjpeg-2.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7343760c6d3d3ecacfcf1efc761fe885375af860908c95853b60f0f08d792ea |
|
MD5 | d571af5ccfcbafde3e535605ff4c459d |
|
BLAKE2b-256 | d8c3e12609a6507fe36050fd75b86d6c961facae9aa1698745f8c7a8c810e0cb |
Hashes for pylibjpeg_openjpeg-2.4.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1efe666f70720495e67ecd77acb1b2ddc07b24d173420d959851b39650ac9e1c |
|
MD5 | b7d1022992cba7861b809e7df21a18a6 |
|
BLAKE2b-256 | 7a2b2a53a42026ef4114cd91c5f6587e3aeb87064cb56975d1d8774cc5c14a5b |
Hashes for pylibjpeg_openjpeg-2.4.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8583853e7df54e9dba13108715ba87b6c88773edadb577fb24efdd7540af5a4 |
|
MD5 | b892f9b9634509197ede21d5be08b223 |
|
BLAKE2b-256 | 65b6eaeef2cfde1b9e3a9c3ca643e82b833e1fc1273c667e986b9bf024f96c2c |
Hashes for pylibjpeg_openjpeg-2.4.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b20c8f173223e73628cd30bf9f9678aad57421c9115b21adbdc0d7a543b2c8d0 |
|
MD5 | 17f93df45df5b796e8090702e9517303 |
|
BLAKE2b-256 | b9d5081ce31a5fa163d6f6eacace99ea960d34833a29f86c4020f245d6bf1597 |
Hashes for pylibjpeg_openjpeg-2.4.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9764407a8435034a8327900f64acff9e2f4cbdeda658c99f2e69772b65cf71e5 |
|
MD5 | 2e75a10ad87bd3c71b0442d01fe6b6b7 |
|
BLAKE2b-256 | 98d0c98b9da733c4c6926e1f4bff78bcf9ae33544629c2ec2315ac56a3b413f1 |
Hashes for pylibjpeg_openjpeg-2.4.0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e562c63facc7638abda8438cad5f7745a15841c2c73365fdb9b0d813d4842e11 |
|
MD5 | ff1235efb54ded4fd5b20287d98e05e3 |
|
BLAKE2b-256 | 0fb96d47f347a1546258cd33bf9182aa89370bce568aa9b11eb3c1635733c9b6 |
Hashes for pylibjpeg_openjpeg-2.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c972f663fa1b3932beee9790fea0a469fbd702d0cd76e4343836416577dfbdc7 |
|
MD5 | c1d651e5bac483e210f3c981660a0288 |
|
BLAKE2b-256 | b8fbb380f89c3708654edad6fa875a28f3a31fff86de25d622de50cc7c827b57 |
Hashes for pylibjpeg_openjpeg-2.4.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1786cb158fdf47f988cf1a16ec6b722304b78ded400d9053749f0c21e55b3ae9 |
|
MD5 | efcee6ef28e9277a953b22cf80734f4a |
|
BLAKE2b-256 | 218ae35fd1fb42c843157aa952a39e9b67438e82c9bd1771fdf165de081a7e22 |
Hashes for pylibjpeg_openjpeg-2.4.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe5be11596188eacaa9fb60f4697f7faff131e40fb0e38142967febeb1175dfc |
|
MD5 | 665bc62c5fb33333dce4511e9ceee0cf |
|
BLAKE2b-256 | d86d5caa2ffb0a011245fe3c24aec6a4b23a70b9e444112c98d26e301414ee9a |
Hashes for pylibjpeg_openjpeg-2.4.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af9d2aaa2b4f540c6c6c0856e8473f68ca05af9ebca192c97e54a6999c1e7449 |
|
MD5 | b94a3f2f9aa0aaa0a3affbf29be4c10c |
|
BLAKE2b-256 | f547dddbc25dfc1847eda64ef36d1e79eacb646e1656adca34280f742cdcddb5 |