fast_image_resize
fast_image_resize copied to clipboard
how does the speed compare with opencv?
how does the speed compare with opencv?
I have not yet done a benchmark to measure the speed of opencv. I plan to do that after I add multithreading support. Because, as I understand it, opencv already has this feature.
@Cykooz hoping for it!
It would be nice to add a comparison with libvips.
I would also love to see comparison with libvips
(not only raw performance, but also peak memory usage)
With threads turned off, the results look like this:
benchmark code: https://github.com/bend-n/imenchmark/blob/main/benches/resizing.rs
@bend-n Thank you for your work.
@bend-n I have only one note about your opencv benchmark. OpenCV doesn't have Lanczos3 implementation. It has only Lanczos4. Lanczoz4 is more complicated (requires more calculations) than Lanczos3.
Oh yeah i forgot to rename the field to lanczos
.
re: libvips, i cant seem to be able to get it to work properly.
I have found out that OpenCV returns incorrect results if we downscale image with different interpolations. All results, except INTER_AREA, look like INTER_NEAREST. With such results I'll can't make any correct benchmarks.
Image bellow is result of downscaling with different interpolations (result was upscaled x2 for better pixels visibility).
Why is that? Is opencv bugged? How is it for upscaling?
Upscaling looks better. I don't know why downscaling is so bad.
I've understood the reason. OpenCV uses "convolution" with fixed kernel size (it is essentially just Affine Transformations). In this case, downscaling very big image into very small one looks like a result of nearest "interpolation".
fast_image_resize uses convolution with adaptive kernel size. It requires more computations but makes more beter result.
It seems that only INTER_AREA in OpenCV uses real convolution with Box filter and minimal kernel size 1x1px.
@negezor I've done first comparison of libvips
with fast_image_resize
.
I've used libvips
v8.12.1 from Ubuntu 22.04 repository.
libvips
was tested in single-threaded mode with disabled caches.
Nearest | Box | Bilinear | CatmullRom | Lanczos3 | |
---|---|---|---|---|---|
libvips | 21.64 | 193.67 | 51.93 | 78.48 | 104.58 |
fir rust | 0.86 | 61.49 | 97.43 | 165.89 | 232.39 |
fir avx2 | - | 20.23 | 21.74 | 28.14 | 41.13 |