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.3.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d7b54bb80fd667ee052e2eb520d9edf1c887a5cecc8cc42649895e1291cbdce |
|
MD5 | 1b810b5829618b2af44d3fa76b67e1bb |
|
BLAKE2b-256 | 5a99ce7025a2e60804e390b16fed8fdf1a7778bf86645153285dcd44b0e6e13a |
Hashes for pylibjpeg_openjpeg-2.3.0-cp312-cp312-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a40d44ed42598cc8eb1d90b3fbf85f6055fb38470439c8aa0ad07b566fbb3161 |
|
MD5 | f3ebe369733e4867606bda84d203070f |
|
BLAKE2b-256 | c1a7cf875013b221b36f8abe31b645b5dd21d2276ba96fdb050918df0e923196 |
Hashes for pylibjpeg_openjpeg-2.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75e2e37baa663ba6871ce6c402065ebc17044afac1222175cbc6bd191750e7d8 |
|
MD5 | faf80733577fad232e53a2eb48af7a4f |
|
BLAKE2b-256 | c63c7460870d4ed30920d6fcf410565fb4e5c7dca6d5e239972157b6430ad6a5 |
Hashes for pylibjpeg_openjpeg-2.3.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c81243889a5cf1732f13d100fd43fbd797e328677697922888986b4f7090bda |
|
MD5 | 9363c36ec40b8ca7b80b208651fe35dd |
|
BLAKE2b-256 | 457b9992b74e202ab29cfcafff8afb246d8faeb693a9a2f7339dbaf224e5e153 |
Hashes for pylibjpeg_openjpeg-2.3.0-cp312-cp312-macosx_14_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3498c60da3ce28a6020e29f5ba1954c9cebbf49772e0d13805f08e4968624257 |
|
MD5 | 30ff1aa4e765189579411edb9eeed49b |
|
BLAKE2b-256 | 20a8b30bccb0135de8794c4d68c5f20c62c93e2de3bdfed618a12bb2e601aa33 |
Hashes for pylibjpeg_openjpeg-2.3.0-cp312-cp312-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6b96cc06761bcc3f3e833059f64bb4ce339e8c11537512b4ac3cc1901559ef9 |
|
MD5 | abce98d648bb0f32a12e2bccd4c5ba34 |
|
BLAKE2b-256 | 448cbed1194a7567a54f04c0c4d16a2491ea98b2750cb9b7db19f2e5ece3099a |
Hashes for pylibjpeg_openjpeg-2.3.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b4eac8e839045c3c09e74820a316453789daa53f64d06a43e99f8cda1580b6c |
|
MD5 | b0e06e6503ab74cf41032a7d1e31e7c3 |
|
BLAKE2b-256 | 7ed401666d9866c1c32fd7714521652bae3cb789f49cc5b5007c245ec96522e8 |
Hashes for pylibjpeg_openjpeg-2.3.0-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e43cad5e3f489321a2463b63a9656f3923c784ee678bafed9e0e07eab7d81cc0 |
|
MD5 | d708a34ee9f10c733755515868cd095a |
|
BLAKE2b-256 | 312ec8988e990a45d231152b6d2532b29c9431831ce7629c8f1c20f247b1ae6e |
Hashes for pylibjpeg_openjpeg-2.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fdd6303be1c79fce74200a61e4fdbf61ceb7f1477bdf31447d34789246ac2eef |
|
MD5 | dcdc154a23d17b3057af9e7f2b66294f |
|
BLAKE2b-256 | 5cdbf9620da9cc8fc21b010a57d203cfbd4a85b10c0f0376159aeeba8727f7ae |
Hashes for pylibjpeg_openjpeg-2.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bacdae7ab99378b6f7c1763b40c97e0ef89f21a9dce0a61a97b0ad7a96a9d85a |
|
MD5 | a22eb8975a7b0b8227395299b967ec2a |
|
BLAKE2b-256 | 8271f663c08c9aaba2f08459bcf3044777d63b52e6c403c17f114f256d723a22 |
Hashes for pylibjpeg_openjpeg-2.3.0-cp311-cp311-macosx_14_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b3f614678a1dfda1f6ae8f433d02d1b67e7baabd0bee45cc67fcf75734725b2 |
|
MD5 | adabc9841a0f84b89fbc1daed71be017 |
|
BLAKE2b-256 | 0116391177fa7df86a9b6991b99b1799e75907c6ed36fcff4dcadec362fe2900 |
Hashes for pylibjpeg_openjpeg-2.3.0-cp311-cp311-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 849748ccadc03ce9403c25f3e0420185c0af6501a80c8185e5b16c6b70f97704 |
|
MD5 | da97a826596a24c7f016643d17d75131 |
|
BLAKE2b-256 | 38af89d98d44856ad1fae25922a62c7fab33d1af6268e89cc7b0d6aada3a5eef |
Hashes for pylibjpeg_openjpeg-2.3.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18d3c5235e61e177c0b6491a2889e9bdda858dba2a97e2081b90e5110011615d |
|
MD5 | abedf13c309dfa5b86bbb56f94ad2f1d |
|
BLAKE2b-256 | a78b2bfef65a116326ffc18850c38d8821e56b4767b048aba10dea714617ea83 |
Hashes for pylibjpeg_openjpeg-2.3.0-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab9fbec8633089e0b9fbf77d24ce50811981b84ef78a6c08d510a2aefd7b3551 |
|
MD5 | d14275c5c6c819e236f62f45b26e43b6 |
|
BLAKE2b-256 | 7d03a7de3e3d6f5927e8f658c962564508971307491f01d9444333bc3096642b |
Hashes for pylibjpeg_openjpeg-2.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2139587f183695442b717aa09e36497e9516cc65765b125713189519722da9c1 |
|
MD5 | 2cf99f34ad2dd2182c18cbeb471aa761 |
|
BLAKE2b-256 | d57b45ad76fc0a38c7809d086f513aeebeead7ef3e117cf6d6ab8e13c2c35f91 |
Hashes for pylibjpeg_openjpeg-2.3.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e54649a87ff83d1760589918ddffa52b51950933839a26d213a36ac62bb4c4b0 |
|
MD5 | e6befe3b5cf61bd05c80493b8d3fc6f2 |
|
BLAKE2b-256 | 0f3549dba3e1ec9090248ec9c30fb1d122c21c260a218515510ded9d318cd84e |
Hashes for pylibjpeg_openjpeg-2.3.0-cp310-cp310-macosx_14_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07f8ec82e564b9f3d4e3be29fe25e5aadcdb6c94fde4810bc490ccca47ae3fcf |
|
MD5 | 42b6fa9c402da233ce5a8f6a0f61e7e2 |
|
BLAKE2b-256 | 5f5d821846a3d0759a2d8af40e97b7cb2d06046f820d06b5b72f58d096e737ee |
Hashes for pylibjpeg_openjpeg-2.3.0-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03cdc2ab22e94c77f037a62df74f1d660abce185421658150dd0b43320f29afe |
|
MD5 | 928d82b2435d844a3fd49aae4efd2e74 |
|
BLAKE2b-256 | 7389cfa4409b44e5f3a5afa78378e9c76cafbfee54d283c0f099d5d980f7febe |
Hashes for pylibjpeg_openjpeg-2.3.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce9bc4fddda7031ed3d4ecc627900023882dd897a123591a8752ed55fc0518a4 |
|
MD5 | 9ef92a4f2d149196fbaf4ae673ba9f18 |
|
BLAKE2b-256 | 5d615d984a312ccead4c103fe694ff1f726fbee186437c16333b4a9a01095d3e |
Hashes for pylibjpeg_openjpeg-2.3.0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c943549e5f1c4508c4820d6f1f3e7dd992a60cb8e996b811f163668a4aa5806d |
|
MD5 | 59414f683f947ddfef23a045e985c0b7 |
|
BLAKE2b-256 | 51ff58ffc6bb18338fce4f1b5b3275f3f0280dac97d83cce81af5b85a6eafc2c |
Hashes for pylibjpeg_openjpeg-2.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46205c0ac003f78bca40dfdbf31e4232fdc338543af1bb2f48ac39ab070d02f8 |
|
MD5 | ac549c247eb556316b7533ea7cff3f50 |
|
BLAKE2b-256 | 30ce37ba03fa29b227de42a7ea85be1caccf9e717c5ea0d50769157eb523da87 |
Hashes for pylibjpeg_openjpeg-2.3.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5092da3a30679a54b8c556c81189d2eee5ece9bc30357ad22825a9a8ebd24cd6 |
|
MD5 | e541cdbb1ecbeb7b39b56b93c4222532 |
|
BLAKE2b-256 | ee27d49361d6e49ae0eec023e6f6b0684e015897f8b7ec2d5dc8fc7a1870a963 |
Hashes for pylibjpeg_openjpeg-2.3.0-cp39-cp39-macosx_14_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29f55cd51b45f8f4c2c575ee2e3c562a92d8aeb79f40ce3f49bf6ead04e4fac0 |
|
MD5 | 325604d5d6949c1c61132b8c7f6b9102 |
|
BLAKE2b-256 | 189dcd8fc158baf7147e562de7f754ac245dc14600d314e97ae43e50e13ebd47 |
Hashes for pylibjpeg_openjpeg-2.3.0-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a62d0fe010ccc18e2637d0bf4a0f9b31492ca2b35a3e5e0ba2e8881be1ee827 |
|
MD5 | 63f53fdfb3df9dfa10915a631faa59d5 |
|
BLAKE2b-256 | 1076230e746c4ba7cd5ed4fae198b4cbb271ff73171c69453cf9ecc0fcbe00c7 |
Hashes for pylibjpeg_openjpeg-2.3.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9781cc1085751ed6b636846d46dcac684dfe9b5dd35057d358cf6244ca3ddf4 |
|
MD5 | 42bdba9fc48ad2962253377b63d54165 |
|
BLAKE2b-256 | f8ce9810efd3d143d663e6e851f3e0da217861b0a9c91a1f455cc3851ef07dcb |
Hashes for pylibjpeg_openjpeg-2.3.0-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a59565dac59aca0efacbea5e79520d78b159829e201feaabdb34f9dd6a4ccb9 |
|
MD5 | fe66908ddcb6dbe18376f8892983e2db |
|
BLAKE2b-256 | 9ad32f94da0251552c8f777eb7bcf9adfea3f35e60b3b4b1d4acc190ab622db1 |
Hashes for pylibjpeg_openjpeg-2.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eef41f7268d2c07f8771f94724d49252d66bd8f81333c635d83dfa4c986146fc |
|
MD5 | 3b30ac484743b4698c803757f2784a6e |
|
BLAKE2b-256 | 0ef9ac89057105cf5cf6c08ee1770939226f99ad383694137fbed51c2b71f265 |
Hashes for pylibjpeg_openjpeg-2.3.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5d864e254c3f7faf86179590628067a3ede295608302d49322504e823bd03cc |
|
MD5 | 5f2da5ca28f58fc642ed5338995aa05e |
|
BLAKE2b-256 | 71bf5f8ab0299f10b6f401cbc0f0310c9d925aa2f92e8c52239c7abd455f5634 |
Hashes for pylibjpeg_openjpeg-2.3.0-cp38-cp38-macosx_14_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3cfd36f13784296fa409df59ccf49c2a2ed8ee50708aa018db9729e6de2f9256 |
|
MD5 | acd70b747b563be54856dd153538bfb4 |
|
BLAKE2b-256 | 6fcbf829d88cd848948a895a1b50926dc63d891676067197d9e97f3b8dd3757a |
Hashes for pylibjpeg_openjpeg-2.3.0-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 345f7b227c7bdc19715f5266bdab242a1dde588b62e5db18010e523d6cadc35c |
|
MD5 | 95d3ef711cebd89b9254bd08600b8d53 |
|
BLAKE2b-256 | 48148e1cf138da34be73a2f6660bdd9c998704e1c0c32790bcbcf3ef2ba3cf30 |