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
arr = np.random.randint(low=0, high=65535, size=(100, 100, 3), dtype="uint8")
encode(arr, photometric_interpretation=1) # 1: sRGB
Lossy encoding of a monochrome image using compression ratios:
import numpy as np
from openjpeg import encode
arr = np.random.randint(low=-2**15, high=2**15 - 1, size=(100, 100), dtype="int8")
# You must determine your own values for `compression_ratios`
# as these are for illustration purposes only
encode(arr, compression_ratios=[2, 4, 6])
Lossy encoding of a monochrome image using peak signal-to-noise ratios:
import numpy as np
from openjpeg import encode
arr = np.random.randint(low=-2**15, high=2**15 - 1, size=(100, 100), dtype="int8")
# You must determine your own values for `signal_noise_ratios`
# as these are for illustration purposes only
encode(arr, signal_noise_ratios=[50, 80, 100])
See the docstring for the encode() 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.1.1-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e25a94741a7ac0b763adcdfd612342ff9eab82c20f6e8a9ba3a43055860d725 |
|
MD5 | 4feee8ff8b93b6a080dabfced349edca |
|
BLAKE2b-256 | d0570ef53e9878e5943d05f2afb31bd9d46190a6f8c26c6add47b084aadd91a5 |
Hashes for pylibjpeg_openjpeg-2.1.1-cp312-cp312-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57d1fe3e713e2c46c9d6268cd30ab934659a08cbe105056834607d7b19c9f95f |
|
MD5 | 9fd881d24d55cb78f1d1101a61b23e75 |
|
BLAKE2b-256 | 999a99b978f1721f2a1a320003ec865af96d075122d0f4734db5cf24ddd7a0e9 |
Hashes for pylibjpeg_openjpeg-2.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f7a91d8bb05581059a43c19736b84b752f86dc685bbe3058dc2982ccc788a5f |
|
MD5 | 5aed812dbdcebe9c464926ccf4cc780e |
|
BLAKE2b-256 | 37cb060e3ce0fec75cca9e9b40bfc7ae86028305994cd81855111de5d984a90f |
Hashes for pylibjpeg_openjpeg-2.1.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84b1782ca23fb016f25c7e9bffe043461739bce9764647203539acea5b358d66 |
|
MD5 | 098ab8c731ccf47391eea810d7fe2d0e |
|
BLAKE2b-256 | 9075da0426ada86af33485542ef24dcd2b10f775536571eb24837fb32b916a83 |
Hashes for pylibjpeg_openjpeg-2.1.1-cp312-cp312-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0804daabfc4c75919763d8b39aa88a80854c4517c4d06d70fb6f678d25998d56 |
|
MD5 | c5d948989ea0e41b4a2f0dacb2d27c59 |
|
BLAKE2b-256 | 075ba03b79a49b1fd04f69cb5b87f3751d7622f556b0dcdf09d942c39d3d7c19 |
Hashes for pylibjpeg_openjpeg-2.1.1-cp312-cp312-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e3f57f0910a525c920b1f8da79e7cf1c20d1130a37f39bfae50cdbd49ca3ec4 |
|
MD5 | 750ac751a0979de84f8385275be3d82e |
|
BLAKE2b-256 | a701b6fe7108d688273203c5991f5202f76dce7117c2a593d39d7910b5d3ee0e |
Hashes for pylibjpeg_openjpeg-2.1.1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69a65ac65042ff08013e1d5d3671fab47cdfa75ffd37cb8d92546133a6e65ca2 |
|
MD5 | 1de63e2136fef19c77d08e850455ac14 |
|
BLAKE2b-256 | 8c09aa77fd4714d571b27854e2f17744820e0a0a94f0ee88e3188d6c3fd97e6c |
Hashes for pylibjpeg_openjpeg-2.1.1-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2e98bca8eb98ae98271852267f7cd04f1898ecde714428380a593cfea98bf4a |
|
MD5 | cc0eafa4709de6a98f6ea6cee816c9e9 |
|
BLAKE2b-256 | edec0e9c95b2a8f2247d2f79ff68662ff9f03a8e060d1f16d9934ddf55422765 |
Hashes for pylibjpeg_openjpeg-2.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 022258a548f6b9105441e1e47b04c03fc740e2f1079b9edf7a0a280bba64c9c1 |
|
MD5 | c9fc31d300574ae6b5b33c0054a4c9ab |
|
BLAKE2b-256 | af9de10947ca0169a41a5a7e505ea80eeee9aa3084e91cc44340fd8213bc6df9 |
Hashes for pylibjpeg_openjpeg-2.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0dbb1907b9c4f2d2d5c62fef6fdd87984735f69cb97550d3d28bfbc184c1417 |
|
MD5 | 4b7b961bb8d2f77c1b2df4daf7dd0729 |
|
BLAKE2b-256 | accbb368e368f841e48215126b0bed5c32688b7084c4d126e1229aefed5173d4 |
Hashes for pylibjpeg_openjpeg-2.1.1-cp311-cp311-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d90cd994bde1268527a1e15d80479876815ec25a3c43f316cb62515f801dd72 |
|
MD5 | f53b68677df4e46f8c744e0c47bf8024 |
|
BLAKE2b-256 | 0029ebc69685120f04c9e54f95854209b2893889a9bab6175193d79c73b3169d |
Hashes for pylibjpeg_openjpeg-2.1.1-cp311-cp311-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8dc6a2ebe472143ed97b0b3a5d5c74c850298310bf1cef7bc0f6a9d097ca3c77 |
|
MD5 | 8ecfbe6ac87875cb5ebdd06a8862ecd9 |
|
BLAKE2b-256 | 5947a9463d02ecf86c34f12dbc812257dd952510c5a152adf7bf9acca09f5d61 |
Hashes for pylibjpeg_openjpeg-2.1.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c94e9f89440ef2ab4ca88eed790c7d0a6c9a37ab4764b0d9b238d52cc1442322 |
|
MD5 | 7058bfe8dfd9473ba710eab415e751c6 |
|
BLAKE2b-256 | 1ca8eb305ef6426d15e795f1000177c19547096761c680aee49be290bd277c82 |
Hashes for pylibjpeg_openjpeg-2.1.1-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68b9e6ac6fa8ef0ff2b7c5a1ea2d44ee01517d575b9d318d260ba9be9e78beeb |
|
MD5 | 5a6b86d8286bfba0aae810b9b47c5a71 |
|
BLAKE2b-256 | 8ce760841f3cdc47f2e174d079e2b7566854179134edf89fb432d64e16f24b2a |
Hashes for pylibjpeg_openjpeg-2.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ee5817a3769524641f33d792bdf63a0543b2d218ca9035bf94722650df3741a |
|
MD5 | ea54552bf910d1d2baa7ecb5fc8999d3 |
|
BLAKE2b-256 | fd65afe794d284471ffc7c5f51561ba50daeb0593403a06d5d5829bd0dfb2501 |
Hashes for pylibjpeg_openjpeg-2.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 495a8e01806eeb41c54ecb2c8fbe56b2c0a5e7a971b61efce481c7e63ed10134 |
|
MD5 | 2a3ffecd2ac68630ad3c9f3a087ebe93 |
|
BLAKE2b-256 | feb6fd7aeb34a12b74e0aea58423978bbbf845cd8b1a1031b4bdc4ca7093a4b1 |
Hashes for pylibjpeg_openjpeg-2.1.1-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49490d788e61732cf2b506dc92226091648a85b21f34a0a9359d73279f2a07d7 |
|
MD5 | b1a301c0a598a1aedeebb06955b9efd8 |
|
BLAKE2b-256 | 4679e92ce6ee6e8657e65ada1b863b5ac8ffe2519de5dd3fa7bfb79ce7cfd0d6 |
Hashes for pylibjpeg_openjpeg-2.1.1-cp310-cp310-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4483f1ca4d41311bcfaf451dd377590fc03e8243dbe6b6e79525c48ed9947af |
|
MD5 | 1f92db76651435210b711f3061849903 |
|
BLAKE2b-256 | d2d3f7e1a3fa8d0d747d9358d18763836d6c0d2d91fc9644dc695385fc75eb99 |
Hashes for pylibjpeg_openjpeg-2.1.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 909a1f661ada1a394b10527f44ac739cf7578f3238ea00a52f8ceede3468dfdd |
|
MD5 | 9f2826ccf863ab1223d84a9599089d5e |
|
BLAKE2b-256 | 767b58687d03e98fadd0c3439ec4016a30360bc3503be071f5330470e5ea8ba1 |
Hashes for pylibjpeg_openjpeg-2.1.1-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4e190fa6b8fe211eb3df13be6213933a2537c3cc6539bd982a579757142b6b5 |
|
MD5 | fcbe1766ce4dd96d7c09d6821b62d7c4 |
|
BLAKE2b-256 | 7c90c53e1656a43f83c3518a002f607dec6986d00f3b054aadfbd38fa4a300f9 |
Hashes for pylibjpeg_openjpeg-2.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b7a8a3004b31914c7a7201bcef305a502c3aa791e6d436426c915aa6a9771c7 |
|
MD5 | a108c6239dbab7dcb26a5a65f03158ad |
|
BLAKE2b-256 | a15ef98db5e842b9f81007be98ffd961843ad6ed82cc0840bc668ad2e128ce20 |
Hashes for pylibjpeg_openjpeg-2.1.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cc22d743744f031ef47be8a898bf1bf5b4ea30eb178f845743919a7348db8fa |
|
MD5 | 24172d66da32a921afc5e3a2c066d81d |
|
BLAKE2b-256 | 09d8fda3a65c95c57211f447062007c384d105f3d804deefc31d5eaf241a1500 |
Hashes for pylibjpeg_openjpeg-2.1.1-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2262526ed6df5a0f00abb29ee1ff4334d466c2d1111b5a4e776247c61b74f180 |
|
MD5 | f975d743b029e4d6d560e059c919631d |
|
BLAKE2b-256 | 87f0dbf0c8f7ecc8a0cb83b4657ba20795551b18e062e6f246f329cb642c9cf5 |
Hashes for pylibjpeg_openjpeg-2.1.1-cp39-cp39-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a4c87e4be0e614339da9fdc8c31f005d84db4b7979459cc301ecf2bdb80b1fd |
|
MD5 | 3a4d7b674323f26e75ffdf0b352ddc19 |
|
BLAKE2b-256 | 5b156467f046976263b8183ab9903d2d9c32676b165643aa9039e28b98a27f38 |
Hashes for pylibjpeg_openjpeg-2.1.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30583f2744d8f97c4b3b6d3cd31fcbc5ff62be49f2fe34d58a6d2d4ba4018297 |
|
MD5 | cd0e28fbdb24a81f78c083995d478a4e |
|
BLAKE2b-256 | 9a64660e48869a83405b11c5c0e33830d76eebe7ab7aa74ee72473e45691cc94 |
Hashes for pylibjpeg_openjpeg-2.1.1-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7edd1b990bba0957d509bfe4f71e32fa47568b1db42a8790ee7923370eeed06a |
|
MD5 | d2530120f32c59ac6d907ece2232f407 |
|
BLAKE2b-256 | 7064a80e98c48c0156dcc1cf766a884c0407ca8182fb67560b04ea578f6f93b2 |
Hashes for pylibjpeg_openjpeg-2.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f200e14e95857092da3c5b554be51aff810f8b6869eb3f453d7325cddca72e4 |
|
MD5 | bfd54fc515fdfed53000cbd773035e21 |
|
BLAKE2b-256 | 7032e12a0e45e6cc210d709033607a25b1c6c488dca9e2c9549ca820dd8d0df1 |
Hashes for pylibjpeg_openjpeg-2.1.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f424fff4d61886b7d656c1402f7c6b8aed6d3836d73bc3c39f2f73fccb7a3c8 |
|
MD5 | dba609f6cd4510156f875a3852d5b709 |
|
BLAKE2b-256 | 79075d2d1f4aa39ae26c109bad319cd48491d366eb8c997ed4d1d04cfbe30154 |
Hashes for pylibjpeg_openjpeg-2.1.1-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8513fca7b5c02ae0b9f14f7f4a5a4a913d480eed75fca67a438ca86e9f76a2b2 |
|
MD5 | 2b9b13781753e30c45803c6b4fb4b363 |
|
BLAKE2b-256 | 4f5fa850caaf4a8617e1eac40072a90ea4cc812ca6cace3639b1742b8d1fa7fa |
Hashes for pylibjpeg_openjpeg-2.1.1-cp38-cp38-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06dac38fee9f569b94c34b2361745fa7ecdc6d965c22a6e4bd7563dc55a0c59f |
|
MD5 | 38d096846f38a773ebf06eafd60fcaed |
|
BLAKE2b-256 | a0f69048d69cdb639eb46f28edae253b50b3a9f5d015f7c4fee3603ae4ec4104 |