No project description provided
Project description
PyNVJPEG2K
PyNVJPEG2K is a work in progress Python library to accelerate decompression and compression of JPEG2000 encoded images. Python bindings have not yet been implemented, but there is support for accelerated decoding using a standaclone C++ program. Only decompression of single channel inputs has been implemented.
Usage
Encoding
Only 16 bit grayscale inputs are supported. Only lossless encoding is supported. Number of frames must be divisible by the batch size.
Encoding a 8x512x512 3D volume w/ batch size 8
import pynvjpeg as pynv
num_frames, rows, cols = 8, 512, 512
batch_size = 4
data = np.random.randint(0, 1024, (num_frames, rows, cols), dtype=np.uint16)
encoded = pynv.encode_jpeg2k(x, batch_size)
assert len(encoded) == num_frames
assert all(isinstance(f, bytes) for f in encoded)
Decoding
Only 16 bit grayscale images are supported. Number of frames must be divisible by the batch size. The decoding process assumes that the output image dimensions (rows, columns, number of frames) are known ahead of time. For DICOMs, this information will be present in the metadata.
Single frame decoding
import pynvjpeg as pynv
decoded = pynv.decode_jpeg2k(frame, len(frame), rows, cols)
Multi-frame batched decoding
import pynvjpeg as pynv
# number of decoded frames must be divisible by batch size.
# it is assumed that the number of frames is known ahead of time
batch_size = 4
decoded = pynv.decode_frames_jpeg2k(data, len(data), rows, columns, 4)
Troubleshooting
If you have problems building, try the following:
- Make sure you have
PythonX.YZ-dev
installed - Verify that CUDA is installed properly
TODO
- Can we relax the constraint that image dimensions are known ahead of time without much performance hit?
- Can we relax the constraint that batch size be a divsior of the number of frames?
- Can we accelerate JPEG Lossless transfer syntaxes?
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
File details
Details for the file pynvjpeg2k-1.0.0.tar.gz
.
File metadata
- Download URL: pynvjpeg2k-1.0.0.tar.gz
- Upload date:
- Size: 108.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2b8d8f757c3118b137a3861a25810bb3824fb01b3853016d82ae29a280b38ca |
|
MD5 | cb75c77d7387b68f1359a830d51a129d |
|
BLAKE2b-256 | 0243ff81bf5c112777b1fbb3ef3d412abcc5f93fbe609c9c9f5daadc08be382d |