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.2.1-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc0b9133873bef865ff4c7f175a1d3556ca7a3b0ccded48ba6464b72fc975022 |
|
MD5 | 72f93911dd9fabd98d9078322bc54720 |
|
BLAKE2b-256 | b6e0b5788f77973ca260465ca3ab1d2ae05329925f3b29ae4ddbf92048421d84 |
Hashes for pylibjpeg_openjpeg-2.2.1-cp312-cp312-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4beed38a7c0e2f7f222f89d06e5f788237f3fc74dba8c69ab587142df1ac8dd3 |
|
MD5 | 3dc0fa65d3a6b060e6f186e014088e40 |
|
BLAKE2b-256 | e53f21abaf1305b368b2d57f1bf47310d60a5875d7a0839f2df141dd683c2793 |
Hashes for pylibjpeg_openjpeg-2.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 502941d0fdd1e2f9b5bc51f2d1738e067da7a04e193bbf8b4dcc1879fdf81d80 |
|
MD5 | d5f1b5f058bc6891080a930ed0a5edf7 |
|
BLAKE2b-256 | d6812d33d2fa4d6a546801592acc70d67d8a54eae52a517638074a1b0e86b1ea |
Hashes for pylibjpeg_openjpeg-2.2.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7df7346c32b54230ce787e79067cd3adf4f932d1a0b6229b1e7295138993f633 |
|
MD5 | 8963f062b4ffe885481b79229568612a |
|
BLAKE2b-256 | dfdf3762085ada62e4ebd9d3efe4097bb468af259af9feb955178bd2a6489526 |
Hashes for pylibjpeg_openjpeg-2.2.1-cp312-cp312-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e0e5a86e6df2f0250479c964a95fdec6fde3a82dd86a3d21aa7f4b21b76b64f |
|
MD5 | baf22b477af4cf7ca9be46ae605cdca5 |
|
BLAKE2b-256 | ed4507eaabef966c05ebbd878c854d441da9914dc04c2313b2301f2e8d98b68b |
Hashes for pylibjpeg_openjpeg-2.2.1-cp312-cp312-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47f9c8ade97c451a3210139bb560c75be2beed69555e56fa2b268185e1c5e6a8 |
|
MD5 | b192db9e1dae908be46da210b655b648 |
|
BLAKE2b-256 | e5ce0edad3943b3a15f34cf2a846d2036cf1bc62149c49cc9e86516351ee8e76 |
Hashes for pylibjpeg_openjpeg-2.2.1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0c13a77e3327015c7564d64a8999499f81c1d00e96c87daf3a80ee44e469826 |
|
MD5 | f52f4d60987c6274468ab04cfbf98309 |
|
BLAKE2b-256 | d430c93a97d278187d7bbce5686211f7f63cca64b12a945be5b31b3816e9c4f5 |
Hashes for pylibjpeg_openjpeg-2.2.1-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d63d4a16c4df358255e55ef05ecd08e1ed7b4dd30d1c35d0e7e36e8f713c754 |
|
MD5 | aa369d2044a57112796c388811ed07b6 |
|
BLAKE2b-256 | fe1ab2c0088f4bb65c616b994179c748b18c154e464d1b319cedcaa9ad4fe8e6 |
Hashes for pylibjpeg_openjpeg-2.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ec3be3ee8ca10da019587b5f32839b29e1d7e009411d3b773d1a6054a96e2f1 |
|
MD5 | 0b95ca73a487017f2e883d9d19a14e00 |
|
BLAKE2b-256 | 5396fbdd17a3dbe45ba549a44311c54da132a732d1f42f5bc0abf70369348962 |
Hashes for pylibjpeg_openjpeg-2.2.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81b3039b4ef600a259814fea4765f977db477c7f5307e0f1283fdfaa7231bc27 |
|
MD5 | c87dde252f6e4f4b44cc3e88c8f6fd76 |
|
BLAKE2b-256 | 1eb51c8e026e7dacffe9602742abd6995dc8ee0ef928a18815f556bec487c98d |
Hashes for pylibjpeg_openjpeg-2.2.1-cp311-cp311-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6b5ca65c796bf70ddea0a8740ab638dc364a087099d5650db84e46e5a6359cd |
|
MD5 | 22a86139b09748c35cfafcafab587a74 |
|
BLAKE2b-256 | 76fc7d45da45ea048ee43facae49da6bc0a6875572fc2f5953df003f692723ee |
Hashes for pylibjpeg_openjpeg-2.2.1-cp311-cp311-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be7256e0ffd6f2095bf8cd5d6d0a6445dee2f3a51ecec817ed2a65b0fbbe3d27 |
|
MD5 | 23f59cbaa06332e18fa9f06cc60ea9b4 |
|
BLAKE2b-256 | fb1278718f5d173e55adf28831a29a5ee6cf60876c4211026d750b63fea9e55a |
Hashes for pylibjpeg_openjpeg-2.2.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e7a316f21aaf2a4b68948fb7b7bc96933f90909da2fbf338c760db7d5e98078 |
|
MD5 | eeeea54b7ef7abd18b0d97e152ce58f1 |
|
BLAKE2b-256 | b5b303bb611941b7f91fd10fc4594fc51e06c1d4b4126467b15a5405afc10c4e |
Hashes for pylibjpeg_openjpeg-2.2.1-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f4952e9b4edb694ff4b5a34f323d229d1401c6b39f2509342d53cf51a0175ed |
|
MD5 | 294283952b5fd5887d5a7f4e69ef1bf2 |
|
BLAKE2b-256 | 03a37a38c196adedc2e4eba4fadbaac0248ae77e778f999f620daf7747470e15 |
Hashes for pylibjpeg_openjpeg-2.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78978b5c860891e300d4dad353044a1f5f9094bbc16846b007232b2ff3c2630d |
|
MD5 | c62953af9c0c44f189c548c153e718d1 |
|
BLAKE2b-256 | 6065adc77401721e678e15d58f20ada864cf5650d8e635431470b091f15f74e7 |
Hashes for pylibjpeg_openjpeg-2.2.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2823a930cc88263efb4af9d98e3fa29c91790cff9fec4e36cf0799eb2a6af59 |
|
MD5 | 6491021f32e2d32364bf312300d8edb5 |
|
BLAKE2b-256 | 3c1033638cf47e9d2eb8a9ab00d44bc36e6364a7831b0d3775a6895a0291a714 |
Hashes for pylibjpeg_openjpeg-2.2.1-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8abccab4c3559ede12f51df49a1b834754707d9bf607194b130a87015182221f |
|
MD5 | 4adfb0750534466cb23cbfa0b3957894 |
|
BLAKE2b-256 | d8115f9834cc24b861491fa6f6ea6f592dd021d5451febd073e318ecd34920fe |
Hashes for pylibjpeg_openjpeg-2.2.1-cp310-cp310-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2478ab0b999ccd89b4fb72dffe5bba4447497501df3fbf3a96c1a27b2fefa68 |
|
MD5 | faa834657d18eec0c851ad77d9cc4039 |
|
BLAKE2b-256 | 35c981506ef4f2bf1ef0b69932335810947c4d3cb6f4c768751e168c5af06f7b |
Hashes for pylibjpeg_openjpeg-2.2.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3088140e4d5ac632c6c6eadaeebd4451ff83aeaa17ff4faa99cc681e6327ee8 |
|
MD5 | 3af96365373bec1e7acd5a53d5d38492 |
|
BLAKE2b-256 | c054afe97773809ccb448844615ca8c0235a499594a2fda4396d8204de48565a |
Hashes for pylibjpeg_openjpeg-2.2.1-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f9cce27d21e2e0b5fa852c0ed6c5d754cc93c084e0ac6cd768a01d03ce733f9 |
|
MD5 | d8e578ab6bc48d6de4a54884311e4e58 |
|
BLAKE2b-256 | 8958c0ffb7826bd0c09f77b21e95ae031c2f40fe30fccc8e9b698edd17aea120 |
Hashes for pylibjpeg_openjpeg-2.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf151111948a39e8c68ed8b569511e310d77d42bde581982cec6deaf5ade9eed |
|
MD5 | 80f4e84b3be74c1315268522323e4b9e |
|
BLAKE2b-256 | eb3eef6403dee30de872ca7bd9005c99e54b0782be531e1a7b0e4b3abb93bbdf |
Hashes for pylibjpeg_openjpeg-2.2.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5892c3769d4269d8895bf276052ef92aebeeb0d78fc6efb82e762041a9ff666 |
|
MD5 | 49b700b2c58d2783a232b8a63c618433 |
|
BLAKE2b-256 | cadc5fa9a07bd9117ed49ddfb7f760f3e60e7b153d148a8577532e5375ec9c96 |
Hashes for pylibjpeg_openjpeg-2.2.1-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f15856bfb081ed053f0548bae50eba74ea3be3b0f1dd6d5f10868f27faf07d5e |
|
MD5 | 782294017275c0711e169b7ba817291b |
|
BLAKE2b-256 | 3663965545ac0feb74bf25852f673727940627ad7895d15d58b886df72885dba |
Hashes for pylibjpeg_openjpeg-2.2.1-cp39-cp39-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de825e375fc4267de6b0bf109eb1bb0eacc0eb187d7d622fe8c0361f3e0522af |
|
MD5 | f1ef70332ef977753e3404ae737f9ec6 |
|
BLAKE2b-256 | 5bdf1d6a4af78fc0f82101f358d9c1c86c6538b12b7eebe12d234f0b2b129d87 |
Hashes for pylibjpeg_openjpeg-2.2.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d56a3e8c79e307485753291fc7c4786c161106e849a696ba058995781336636d |
|
MD5 | bfe55aa143d8c9e9f91abcc7dd384951 |
|
BLAKE2b-256 | ba867e580e89f90aa18a83ba1bea9b2fd9a68261e9e23b2a56d3bdb0283f3a71 |
Hashes for pylibjpeg_openjpeg-2.2.1-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9686026457437e0016d38de29d86463c5016f2ba3ec1a99eee02dd3fe98e73bd |
|
MD5 | 8a4fa7c21fe39d566ce2b697fe2e863f |
|
BLAKE2b-256 | acfe0f5f62a8989eaba4d4797443ea7f548b0b2e0bd2a2f7938ece5ecebf38e8 |
Hashes for pylibjpeg_openjpeg-2.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb22e04cfb3461c066156bc9ee010e343e102db605f15250e4bbcbf7db38661c |
|
MD5 | cf0325680f43878d4f9b85da101ac3f3 |
|
BLAKE2b-256 | feb5e6d18218e9920a3538618483cdff014ccbfb6730507b5cb2e39baf30a63b |
Hashes for pylibjpeg_openjpeg-2.2.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54e97fd7a541adb816a8fbba81062582c81efd8b424de211b7366266397537b0 |
|
MD5 | d6e1782673d28992e5cbd2ad494eb7a7 |
|
BLAKE2b-256 | 34491df453710939b451377ec7b89d035668a206d54c07558f8a41ad552b96fc |
Hashes for pylibjpeg_openjpeg-2.2.1-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0e3bf729fd715cf478d650814c1a3c3971c1e1049171a3601b150b9e976d4a2 |
|
MD5 | e527c049e7bea7ea47942d9318dcd11e |
|
BLAKE2b-256 | eb439264f76441747ca3dd8cb01f2d41a69e140f942978fa7e1d5814b120e039 |
Hashes for pylibjpeg_openjpeg-2.2.1-cp38-cp38-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fbfc67656eee4ecec409e0ee40deabb4f2ffb9a107d3f267fab29ffb0ca873da |
|
MD5 | 963aa02e3f6ee266b261215d8f1d8ee7 |
|
BLAKE2b-256 | 1cbb1c0d9abfdcf35f81b3d3640eb9f150b484f96404c4c69459bc4604ec53ed |