JPEG-2K compression ratio vs PSNR
JPEG-2K compression ratio vs PSNR
Overview
This article presents an experiment evaluating the relationship between compression ratio and Peak Signal-to-Noise Ratio (PSNR) for JPEG 2000 compression. Using two open-source JPEG 2K libraries, OpenJPH (v0.10.5) and OpenJPEG (v2.5.2), we compressed an 8K resolution image and analyzed how different compression parameters affect image quality and file size. Understanding this trade-off is critical for applications demanding high-quality image compression.
Test Context & Method
The source image used was an 8K RGB 24-bit per pixel image at 7,680 × 4,320 resolution (see Figure 1). For OpenJPEG, the image was in BMP format (132,710,454 bytes), while OpenJPH used a PPM format (99,532,863 bytes). Compression parameters were carefully selected to align between both libraries, focusing on:
- Number of Discrete Wavelet Transform (DWT) decompositions
- Code block size
- Precinct size
- Progression order
- Quantization step or target PSNR
After compression, images were decoded, and PSNR values were computed using Python scripts in Jupyter Lab. Compression and decompression times were also recorded on an Intel i7 @ 3.5 GHz with 32GB RAM.
Approach
Both OpenJPEG and OpenJPH were configured with similar parameters to ensure a fair comparison. Key parameters included:
n/num_decomps: 5 DWT decompositionsb/block_size: 64×64 code block sizec/precincts: [128,123],[256,256] for OpenJPEG; {128,128},{256,256} for OpenJPHp/prog_order: CPRL progression orderq(OpenJPEG): target PSNR valuesqstep(OpenJPH): quantization step sizes- Color transform enabled:
-mct 1for OpenJPEG,colour_trans truefor OpenJPH
We varied the target PSNR and quantization step sizes to observe their impact on compression ratio and image quality.
Results
The tables below summarize the compression results for each library, showing compressed sizes, compression ratios, and PSNR values for average and individual color channels:
- OpenJPEG (selected data points):
-q 54: 18.8 MB, 6.99× compression, PSNR_AVG 51.63 dB-q 50: 14.3 MB, 9.24× compression, PSNR_AVG 48.20 dB-q 46: 9.7 MB, 13.61× compression, PSNR_AVG 44.90 dB-q 37: 3.06 MB, 33.30× compression, PSNR_AVG 36.86 dB-q 32: 1.36 MB, 97.3× compression, PSNR_AVG 31.81 dB-q 27: 452 KB, 293.7× compression, PSNR_AVG 26.65 dB- Compression time: ~5404 ms; decompression time: ~2609 ms
- OpenJPH (selected data points):
-qstep 0.004: 19.4 MB, 5.12× compression, PSNR_AVG 52.97 dB-qstep 0.007: 13.7 MB, 7.24× compression, PSNR_AVG 49.36 dB-qstep 0.01: 10.9 MB, 9.14× compression, PSNR_AVG 47.05 dB-qstep 0.05: 3.27 MB, 30.46× compression, PSNR_AVG 36.98 dB-qstep 0.1: 1.76 MB, 56.64× compression, PSNR_AVG 32.86 dB-qstep 0.5: 268 KB, 371.7× compression, PSNR_AVG 24.61 dB- Compression time: ~404 ms; decompression time: ~179 ms
Analysis
The experiment clearly shows the typical inverse correlation between compression ratio and PSNR: higher compression ratios result in lower PSNR values, indicating reduced image fidelity. OpenJPEG tends to achieve higher compression ratios at comparable PSNR values but requires significantly more compression and decompression time. OpenJPH, on the other hand, offers faster processing times with slightly lower compression efficiency at equivalent PSNR levels.
Differences in source image formats and minor parameter variations may influence the results, but the overall trends are consistent with the inherent trade-offs of wavelet-based compression. The color transform applied in both libraries helps improve PSNR, especially in the green and blue channels.
Practical Guidance / Do’s & Don’ts
- Do select compression parameters based on your application’s quality and storage requirements.
- Do factor in compression and decompression times when choosing a library for production use.
- Don’t rely solely on PSNR; visual quality assessment remains important.
- Do test with your own images to find the best balance for your use case.
Observations
Running this experiment reminded me of early trade-offs in embedded system design, where balancing performance and power consumption was critical. Similarly, JPEG 2000 compression forces us to balance image quality and file size. At TrigoPi, we enjoy pushing such boundaries, exploring how parameter tuning can unlock optimal performance in complex systems.
Call to Action
If you are working with high-resolution images and need to understand JPEG 2000 compression trade-offs, we encourage you to experiment with different libraries and parameters. At TrigoPi, our curiosity-driven culture motivates us to explore these challenges deeply — reach out if you want to discuss how these insights can support your imaging projects.



