This code demonstrates JPEG 2000 Image decoding using nvJPEG2000 library.
Image Decoding from nvJPEG2000 Library
SM 6.0 SM 6.1 SM 7.0 SM 7.2 SM 7.5 SM 8.0
Linux, Windows
x86_64
- Recent NVIDIA drivers.
- CUDA toolkit.
- CMake (3.17 or later).
- Install nvJPEG2000.
$ mkdir build
$
$ cd build
$
$ export CUDACXX=/usr/local/cuda/bin/nvcc
$
$ cmake .. -DCMAKE_BUILD_TYPE=Release
# Use -DNVJPEG2K_PATH, if nvJPEG2000 is not installed at the default location.
# example cmake .. -DCMAKE_BUILD_TYPE=Release -DNVJPEG2K_PATH=/opt/libnvjpeg_2k
#
$ make
./nvjpeg2k_decode_sample -h
Usage: ./nvjpeg2k_decode_sample -i images_dir [-b batch_size] [-t total_images] [-w warmup_iterations] [-o output_dir] Parameters:
images_dir : Path to single image or directory of images
batch_size : Decode images from input by batches of specified size
total_images : Decode these many images, if there are fewer images
in the input than total images, decoder will loop over the input
warmup_iterations: Run these many batches first without measuring performance
output_dir : Write decoded images in BMP/PGM format to this directory
Example:
Sample example output on GV100, Ubuntu 16.04, CUDA 11.0
$ ./nvjpeg2k_decode_sample -i ../images/2k_image_lossless/2k_lossless.jp2 -o .
3 channel images are written out as bmp files and 1 channels images are written out as .pgm files
Decoding images in directory: ../images/2k_image_lossless/2k_lossless.jp2, total 1, batchsize 1
Total decoding time: 0.029807
Avg decoding time per image: 0.029807
Avg images per sec: 33.5492
Avg decoding time per batch: 0.029807
$ ./nvjpeg2k_decode_sample -i ../images/medical_image_lossless/MG_MLO-001.jp2 -o .
3 channel images are written out as bmp files and 1 channels images are written out as .pgm files
Decoding images in directory: ../images/medical_image_lossless/MG_MLO-001.jp2, total 1, batchsize 1
Total decoding time: 0.0498233
Avg decoding time per image: 0.0498233
Avg images per sec: 20.0709
Avg decoding time per batch: 0.0498233