jbaiter / jpegtran-cffi

Fast, (mostly) lossless JPEG transformations with Python
http://jpegtran-cffi.readthedocs.org
MIT License
145 stars 23 forks source link

how fast is it compared to opencv resize ? #36

Open rom1504 opened 3 years ago

rom1504 commented 3 years ago

Would be useful to add that to the benchmark

rom1504 commented 3 years ago

also compared to pillow simd https://python-pillow.org/pillow-perf/

sebasi commented 3 years ago

Until this gets to the benchmark I did some simple benchmarks myself. Perhaps this helps someone...

jpegtran was the fastest in all situations, but unfortunately also presents the worst image quality due to be limited to the NEAREST algorithm (similar to pillow-nearest). A real boost was to use pillow-simd. For my usecase (downscaling images) performance is about 3x better than default pillow.

Method Resampling filter performance
jpegtran 110
pillow-simd NEAREST 96
pillow-simd BOX 77
pillow-simd BILINEAR 71
pillow-simd HAMMING 70
pillow-simd BICUBIC 64
cv2 53
pillow NEAREST 33
pillow BOX 26
pillow BILINEAR 24
pillow HAMMING 23
pillow BICUBIC 19
pillow LANCZOS 17

Versions used: Pillow-7.2.0, Pillow_SIMD-7.0.0.post3, jpegtran-cffi 0.5.2, opencv-python 4.4.0.46

Values indicate the avg amount of images processed per second (on a single core VM) - so just take the value for basic comparison.

cbm755 commented 3 years ago

Thanks @rom1504 and @sebasi

@sebasi What is the benchmark problem? (I assume downscaling, but is it same problem mentioned in the readme?)

The README file mentioned: "Benchmark source: https://gist.github.com/jbaiter/8596064". If either of you feel like modifying that script to include pillow-simd (to start with), I'd be happy to help get that merged.


Caveat: I'm a co-maintainer of this but haven't had a chance to do much with it!