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.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f78122044d16a5f60af1f92b3827afff829c6ee5b0741b95bad2703c5b164100 |
|
MD5 | f0b95b402794a412103b3694c9f542f1 |
|
BLAKE2b-256 | 6f5c8ca2ed7a181b5b65cc23e33ca45e59b5013463bea64cb1f5111d459f8df4 |
Hashes for pylibjpeg_openjpeg-2.2.0-cp312-cp312-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cfcfe5880e88573d2774b383f835e1080797b011a409056ba4eeaeb52b855e2e |
|
MD5 | 347aae1064c57474ba9c354433c213d4 |
|
BLAKE2b-256 | be1dae0e1bf3835f08bb2ea7ac1bfb0e0875ab1bd0327e8f901cc7c168f5e7d5 |
Hashes for pylibjpeg_openjpeg-2.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad430df2cfc416f08546d59d922f19ab2ef31ec1408337752eaf63f4b15c4427 |
|
MD5 | d930c2f36208fe6f23863805900516ba |
|
BLAKE2b-256 | e92393a602076424d048e526e2c66468c9de8070a5bea636d821cfec0dad65d6 |
Hashes for pylibjpeg_openjpeg-2.2.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f40170d9ae6555497b972922758ae4f10f5ffe9ee0c4823a27066927a229549a |
|
MD5 | f6ab480e1f4ecc42480d3ad88d96da7b |
|
BLAKE2b-256 | e114eaf9398785f307a3d0718ec6722d4b2edcdf5dbeb3efcb050b5491e1cb56 |
Hashes for pylibjpeg_openjpeg-2.2.0-cp312-cp312-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48506e4583436de89ae8396f5f7584450026587b547a5d74a3039b4cf4e27df7 |
|
MD5 | ab8c916ddd0ae11715a0d645b4e37459 |
|
BLAKE2b-256 | 9d23bc01ebd2510909c3de7a0175d6f565624ab9f6a2918fd4a6eef3a6de201b |
Hashes for pylibjpeg_openjpeg-2.2.0-cp312-cp312-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe05daf8c9df72a98a59fd410a1677a6275c3aa283c30c996997830fb80482e6 |
|
MD5 | 00fae763adfcba759b62c4475b37f4c2 |
|
BLAKE2b-256 | a59465190f2959179e8677c0dc45d2e8b749c932790138d91556e90e60b124a0 |
Hashes for pylibjpeg_openjpeg-2.2.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee7f07bd9b9de6be86726118e1b3cf59df76bdee4da440ad7d5b67d6fbbad5a1 |
|
MD5 | d2adb9a00043b21bc3d2d038e6742a92 |
|
BLAKE2b-256 | 123e6227ecc918fd357fb4c277fb46e7739ce2fa78c4efeed2adb42927003ffc |
Hashes for pylibjpeg_openjpeg-2.2.0-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4dde34d1aa7989a7ea821d2269630de08c1c208f946780358121bcaf6988344 |
|
MD5 | 06bfec888eae592ba4a50d2222dca915 |
|
BLAKE2b-256 | 7aa585677068a3c05d7ad2ab6dfc5077ff83fdc55e77cb3db43890793bf9b4f6 |
Hashes for pylibjpeg_openjpeg-2.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4e01884e1992f76e4992c53ddd063c1750c7661b92bdb31fc1bd9c503834e87 |
|
MD5 | 62a9f1d13118602dcc24211548b053b2 |
|
BLAKE2b-256 | 08fc19e8893428f4aa5e0dcadeb71acc1e2b8b5964533c79e2bc7635a2698aec |
Hashes for pylibjpeg_openjpeg-2.2.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b50e814ade39befd52068d85d2720ed10dbdbb34f5b353aaf023e9d1bd3db3a0 |
|
MD5 | d9ff1bdbb511bdceef62f3a06d92baa7 |
|
BLAKE2b-256 | 3159110ecf0f169a232227a4fc4eca5fd03a6236fed4196af29320e512782d6c |
Hashes for pylibjpeg_openjpeg-2.2.0-cp311-cp311-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6404bd8fc1dd793cc81c502700f20ee9dc911578b6099cb780898aa880028942 |
|
MD5 | 06fc703d98b4e686099e6afcf5cd941b |
|
BLAKE2b-256 | 9f5c6fc247ceb9f8240a67fbeeb6768da22bad372bb8212fc465e1c2d3a79b79 |
Hashes for pylibjpeg_openjpeg-2.2.0-cp311-cp311-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29dbc3e10366f42814e111633796bc15b09aa07bf3303a94d17a98452181a604 |
|
MD5 | c21c4d97e45d2257d985605d1191ce20 |
|
BLAKE2b-256 | b2fa7f22b5faafe7fa1631a09d940ebf7324a630c27dd78def8c8200b1d840aa |
Hashes for pylibjpeg_openjpeg-2.2.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec7fca8a4adbd2d88ce7612588830fb54750d6438fed0cb7787d3ac64c2f1ce0 |
|
MD5 | fc49d2cbe2a0da418a129384ba75eddd |
|
BLAKE2b-256 | a3af97a9e94343defe8845135adc6caf7c3ab4cf39fd505c2bfc044eee738b14 |
Hashes for pylibjpeg_openjpeg-2.2.0-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 345894fd662ce0ac89e066759bf693146bee63957067d59782aaf11f953a74c9 |
|
MD5 | 1ab16e200583311558084891bcfe0488 |
|
BLAKE2b-256 | e161adb6002334d948ec081f6f5c44aeed7083ba5cbf6a4a242ac6b09849a2df |
Hashes for pylibjpeg_openjpeg-2.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11ad5ff9354f1c23e009ec36a34c52f6da78912b3792ac6dade4d6516dbc6a42 |
|
MD5 | 4eceef522374aa3a3aa96f4a47b191c0 |
|
BLAKE2b-256 | 488ac64d320dacdef7eb69f704d185b27151219597090b40a29225ec93a8cbe6 |
Hashes for pylibjpeg_openjpeg-2.2.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a72d49d892b4d76502c33027bb491f9bda5fd4590f903f24f91a544d60a31b4c |
|
MD5 | 1f8a7b22ff5ff3734e861caee1ab0728 |
|
BLAKE2b-256 | 0e67e306c7314afb811592920dc0eba59028f5488edc909065ed6acc73025b85 |
Hashes for pylibjpeg_openjpeg-2.2.0-cp310-cp310-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9c2f8ca7d84c03d89eb7e7ef697f1775395741618b7c8f715f9452e2b2ebe64 |
|
MD5 | 639fd837d6aefc53a17457ea07401ba9 |
|
BLAKE2b-256 | 853d5d469700b9b08f830b4dde891c9a30bc0ff4b0e005e458519dfc8f26a02e |
Hashes for pylibjpeg_openjpeg-2.2.0-cp310-cp310-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94ddadff1715bb75c94b5bc8383777911bcc7fd76d850f4867067962b2fe09af |
|
MD5 | 1f83ed3dbde23b7869680f7e08d845a4 |
|
BLAKE2b-256 | 926aadefd1916e5a9f97f5be57ea8dfabbfae7889bbb192123110769801bc0a9 |
Hashes for pylibjpeg_openjpeg-2.2.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4971362f723f0ba4f1ddd576309de7f391b5ac076389767531cc7147a1a0d7a2 |
|
MD5 | 2404341cf60c5625c316dd4a93b33588 |
|
BLAKE2b-256 | 568a29a9e7775c2608469455646ce89fc575fc5c1bed717608b44d8c7ac69291 |
Hashes for pylibjpeg_openjpeg-2.2.0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29c1fd8e2ead20ed15c12eb7e5803db65aead58a9058d6870f047439e7f2de07 |
|
MD5 | 352b165b936e5bbd40b520882fb3badc |
|
BLAKE2b-256 | 7b05bf1e70ce935a6676d5da1976be3c747a8b98eecd61b03b7f054e4060c774 |
Hashes for pylibjpeg_openjpeg-2.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02ae91a08e4ed66a6dba01b92a54eb4d8ed7c6f1e5a52acc8ebe69cdc71f09d9 |
|
MD5 | 90af531a1b261ecd175816302473d568 |
|
BLAKE2b-256 | 0534d51d15629e5236f09bc5fbba5f75994b3e8460bb315848273a8b2edced0d |
Hashes for pylibjpeg_openjpeg-2.2.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b791deb303a2ac888af2ca19a92d22783c27ee224f46f97822d9913033be4c3 |
|
MD5 | 13957f3bfa2aad8eb8231d54a456a180 |
|
BLAKE2b-256 | e0446993921594cd7bfe918d54839fb8339c4daea08cec58058908c41894f2a3 |
Hashes for pylibjpeg_openjpeg-2.2.0-cp39-cp39-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4f351b0a10472ff5f4b6074d90b4758b88445c0049dacd6bfade64ff558d4c0 |
|
MD5 | 6c421f04483b04b02a971380c71b479a |
|
BLAKE2b-256 | 375eea91430e6725393238cc6cc2149f1fbb60f32705d6ccb291e8e3cfc99553 |
Hashes for pylibjpeg_openjpeg-2.2.0-cp39-cp39-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea475739c4245f65c9778ea3008daaf61de7af0bf4301a733b9d80c90cdcf5b5 |
|
MD5 | 9f235a4b439878d11af97f5322981dfc |
|
BLAKE2b-256 | 8874289375c8d17dfcfbf83a53edf1389c9eb0cd31f5c0cf8b8c85040d041bf0 |
Hashes for pylibjpeg_openjpeg-2.2.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b542e36ffe0259587e4e9a1dc2e01888599daf90a38ec8454e7e6c2872a540a0 |
|
MD5 | 739d62fbb0a8ff5daa08b1755ec3eb89 |
|
BLAKE2b-256 | 160c3700eca4c350a181924cac53221959fefdcdd496f120b4c1eb952b7fe6f4 |
Hashes for pylibjpeg_openjpeg-2.2.0-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f776ca06f858041402677e2c7d60e96548c8dbd5debf1db9b2da1c609e83dc36 |
|
MD5 | 31353efe96e7e4a526573a51153f47a1 |
|
BLAKE2b-256 | ad177a594704f3567da0539ba842ac516edae5f2e1860cc4fe1b53c847e16e22 |
Hashes for pylibjpeg_openjpeg-2.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0a5e44ef5533d8986fcabd9ae5bf14604b56f48f664cd731563424594067bc3 |
|
MD5 | a47230fb8166a71371758479d1fbab6e |
|
BLAKE2b-256 | b0cedc077af4cc1dd531a6c25faa91f93e67f364402f8a8f98b01503093e0ca2 |
Hashes for pylibjpeg_openjpeg-2.2.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5306f6ac0f810d8c0f097fb8c53a5a0bd8cd8ea1185bf37cb5702d950768358d |
|
MD5 | 3cb5e2d9562dcd87c7ce87e3a49f2c9d |
|
BLAKE2b-256 | c596b64122537064216ecd690013c549b5a9230af1478a456d8ae25f3e233764 |
Hashes for pylibjpeg_openjpeg-2.2.0-cp38-cp38-macosx_12_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af340d37d10b4b3e3068306e34a36ff02817e918b60048f01ca29f9acda8b6ed |
|
MD5 | 547f7703cab8ac08c1965e4f9f8e3b9c |
|
BLAKE2b-256 | 4c1ac4ebb0f650fca6d3faa06f09f004fa61a3abf73ad3e0b840da682d69a2da |
Hashes for pylibjpeg_openjpeg-2.2.0-cp38-cp38-macosx_12_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e58e504d017e0442885adfc56e66a711b08eac362e8259e1c23c7822e815b6ff |
|
MD5 | 7d9c59303c08668084856d6205eef608 |
|
BLAKE2b-256 | 6096fd655dc7b7f74a304a47d87bd6f3a708c0f87797f2e9e206f6c5ae4d6e06 |