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.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c2adcc985eb1126d01ecc52074470ccd23f7fb2d340dd5b9ba430693859f757 |
|
MD5 | 8bc87703aa3eafe936ed4a75f978ea6b |
|
BLAKE2b-256 | 7d0d25c366969592e71e5d78b72a35ebafb22e0fa12929776fcfb124ec8a5b5b |
Hashes for pylibjpeg_openjpeg-2.1.0-cp312-cp312-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad26e18c46cb1b6bc9403d069498056afe552a80fa83a6b10e384a1c3fc8bed7 |
|
MD5 | e64cf634860ee475b9c2bebbe2fdd65a |
|
BLAKE2b-256 | ef31247d90a719815b9537e9fb6e603fa6a2e055a1671f013034d5e2759a7e08 |
Hashes for pylibjpeg_openjpeg-2.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2eaa94139b3f6522b3f98359af1c83fe3e9012ebb4ac22397ea705f47c477b96 |
|
MD5 | 26f5a3b88e9adb672b1796e1082ae7ff |
|
BLAKE2b-256 | 74e4568c6749e3847bd6fabaac4c6d02095414ca8bbc1c290e5fb54a45b9ab94 |
Hashes for pylibjpeg_openjpeg-2.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a755ad950e55ff25b68cc266c3cb83fe010e6478219411a11e0ee8bb649bf96 |
|
MD5 | b2c647a73bbd774dd4a9f84e47f13b8e |
|
BLAKE2b-256 | 2516696b2ae52ee71d876b86ddee124bc258ce9aaada62221783e929b2083cc1 |
Hashes for pylibjpeg_openjpeg-2.1.0-cp312-cp312-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97ef5a9ac8c1c31ebbcd2ffb29533beb65d5cf4b1b9129eb9467bc1dc130cd2d |
|
MD5 | 43ae06c9150df35b0167e14aa178e99b |
|
BLAKE2b-256 | a8091516e7a99d4eceef857a144094f6b33a9bcd10d07b0c27a1c123b2c68ac2 |
Hashes for pylibjpeg_openjpeg-2.1.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9021cf7ca3506639ec9b19959336d59082480f69aa16b927c90cc7522e44f801 |
|
MD5 | b9757ccb6611b5f48b87b03ebde5e0a5 |
|
BLAKE2b-256 | 42d127ecd6e41b20b3ba83a37074bf54937ce8985091b14e73e92d803f6bb3cb |
Hashes for pylibjpeg_openjpeg-2.1.0-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c1142d7f98ddb0a660bc296732519cb70e9887f25ab2c5f8554214a42189514 |
|
MD5 | e6e836b1062b6ca36bd6876b2099f0de |
|
BLAKE2b-256 | e97280e316554c9151110d5ebcebd2ffc208a5a4824ed0e1e83a18f4c34202e8 |
Hashes for pylibjpeg_openjpeg-2.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d00d49f31145a4ec111f03f49e01ac75c9bb9af6da59006ac95ab9e5b88a371 |
|
MD5 | e55ef66c21040225eaa26a93857591d7 |
|
BLAKE2b-256 | 26cafde0ed9a9109e60a0385e199eede6f85a4e92ce45a19b25e37756dc44e28 |
Hashes for pylibjpeg_openjpeg-2.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e49c1ffeb91ddb8308d33ca67225479f39691aedefb7a3fd61d2f91db43c84db |
|
MD5 | 04bebf37b2f03f3ac2493a8c2c51952f |
|
BLAKE2b-256 | a028e80a59b3978b2b31a02cffb24297557b307da00c5ee69c88121cb6b47148 |
Hashes for pylibjpeg_openjpeg-2.1.0-cp311-cp311-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf4aa695a5b592935b1a0322d27ba269d5e18e00839eefca177a9086167cf878 |
|
MD5 | eca11ad25134f16ba4833962b77faa07 |
|
BLAKE2b-256 | ff952d93b059c5d89a57b01d9bf1d5d702993b95d99f2e22a3588d8371bf1f55 |
Hashes for pylibjpeg_openjpeg-2.1.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13e8a4df31863acb7b7fcb657435ff60aea1787e6979679335a009193b5ab51c |
|
MD5 | ce9b8902032c054ea693ccdbbd1c9817 |
|
BLAKE2b-256 | 54b66f64ea7e127a72b9a478edf2b3e0a152f128474a1241cc558954f580c08e |
Hashes for pylibjpeg_openjpeg-2.1.0-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19757f295e83f6ca4ece22d68b638a161baf3efe131bc76a7f693b903a577d70 |
|
MD5 | ef5eaf4355c8668941e0034d9204bc97 |
|
BLAKE2b-256 | 5daeb5645b0904db6448c4a9aa9f32b1ca37680c3bc2d2cf8fb42690acd01f41 |
Hashes for pylibjpeg_openjpeg-2.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c249ecb761ec4f02c0ac4e931c3a835c0d88970aa1d98c310be01bfdd16025f |
|
MD5 | ff0c8671755e5c20c941610d7d3e3512 |
|
BLAKE2b-256 | d4e31c30fd1a78db6461e9f318eab14cb3c75604d95c74a99094bdfdb58856cd |
Hashes for pylibjpeg_openjpeg-2.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0d9b790d50c9aadea3bbf7175d3f89d8d9184836cfb26b06033ceca2b38de26 |
|
MD5 | fd065283ede50ece1dd3e5694b0db03c |
|
BLAKE2b-256 | c9d6a984857d5bf2c63666c15d87d26b1f643c244bbb47d3a960affd1e29d86b |
Hashes for pylibjpeg_openjpeg-2.1.0-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b79eebde738b2a8ed9f9fbce710319f81651095b1d16ffce2f6bf6cb5504d592 |
|
MD5 | 84ccbe0617b73f36f31412d85bed589a |
|
BLAKE2b-256 | 98d5de25f26dfd23220c869dcf95405e5b7a3c57782656a79d395e51c79b2c07 |
Hashes for pylibjpeg_openjpeg-2.1.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68d447e6086e11aa31b1600ea5c8fa97a1ca6ef0bbb01189ccb4cb06130fbb49 |
|
MD5 | d3074bc0d4647b623bf4611f4fdc54ea |
|
BLAKE2b-256 | 77e6fcb6c43f85bd43437850bc5cf70ceb402f93cf20e57686a6cd1f3476e3f0 |
Hashes for pylibjpeg_openjpeg-2.1.0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45139817cd14a5cd6760268ad494cb3651c2133251f3fb294f0bc99cab34c60d |
|
MD5 | fe074bea4cff5927e84b6f7e4f886ff8 |
|
BLAKE2b-256 | f5470688a5ce55b4a9da13de9066d8a23ed30aefd49c16e9f40dc2b735729090 |
Hashes for pylibjpeg_openjpeg-2.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2228ecffa30b1b52be7e60b931dcd0ea886504e28e9129f78874a7617658c8b9 |
|
MD5 | 13c60a8f258896e817d38726eb8a70c2 |
|
BLAKE2b-256 | d339172cb3de688ff0b9d9eaa37d1b1a819abf5c5fc40034e6b158eaa9925ea9 |
Hashes for pylibjpeg_openjpeg-2.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8ee0e93fe495e8aa626398ba3c153e710d9ede7d17faad81124a77316b0575b |
|
MD5 | 29964461d610df7e32a1944be363b730 |
|
BLAKE2b-256 | e57c5c7c8672a016ab144f33e9e3eebed08dc2622f44c3b85aa6a1583982646f |
Hashes for pylibjpeg_openjpeg-2.1.0-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30f2d2dd8fe294fadd5370ad5fafd146bd7896a70f16ac5dc173756d7349c10e |
|
MD5 | 51a4e749f878d0828828c2e6b082247a |
|
BLAKE2b-256 | 895a15f1bc7b5d4207f10e76b7e3668be65045552dde2a6ce95b79aa3257ce5e |
Hashes for pylibjpeg_openjpeg-2.1.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 976a118d5e92a8ff6d01fc6917705cf79203a36d62ea2a3c4571d83900e9d112 |
|
MD5 | c1f7edc62a3a065ad6bd6cbe6363b3ba |
|
BLAKE2b-256 | 55ee53c316ce986916017533e23d262186ad7b4dcfa936db78f2671c0b9d0105 |
Hashes for pylibjpeg_openjpeg-2.1.0-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03bdf5483c4c2458909807ed55202f9af8e84433d455e70fe203c236a9bc9467 |
|
MD5 | dcaac6fc07d383a48128922432a5a7be |
|
BLAKE2b-256 | 9d0f9d44f5b142100100093fe19f35152ca32df8bf57c641e9d6695cd24cec70 |
Hashes for pylibjpeg_openjpeg-2.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5da7840854fe58d1662ef213e1eeedd464b51d3c11d5a1fd2dbffff97d8924bf |
|
MD5 | ff7ea1561b50598dbf131611147a34bf |
|
BLAKE2b-256 | 41a8393db8a5cd65fcd029ff5fe59a5838d95a8216a83cf8af7c744b040e2f6a |
Hashes for pylibjpeg_openjpeg-2.1.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24cfb0779cae4be6ca8d1061b458bd6accd50a2decb1e76bf12f61ac1b069499 |
|
MD5 | 8f05296f9ccc6a4020eed68f73868154 |
|
BLAKE2b-256 | dafdccb6bcca44fb0515f1993c242f7a85c8fc8318a043cc44d7ce39ca07e6cf |
Hashes for pylibjpeg_openjpeg-2.1.0-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bee2210a6c6f0f9d07442fb60b46b1a807bc2f1c0827e07bb521ced1aeb80a26 |
|
MD5 | 9ddc5ab9f2e550a10b297ebb82aa3e8c |
|
BLAKE2b-256 | 3d29d93715b0da4a48e348cacb10c8f5d2c0b6f22deec5e60923e9141c9d0f99 |