Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use much more time vs opencv and python image.resize(). #19

Open
zhaocc1106 opened this issue Oct 31, 2024 · 2 comments
Open

Use much more time vs opencv and python image.resize(). #19

zhaocc1106 opened this issue Oct 31, 2024 · 2 comments

Comments

@zhaocc1106
Copy link

zhaocc1106 commented Oct 31, 2024

I resize one image to 448 * 448:
7172d7a46e2703e0bd5eabda22f8d8ac70025c76

pillow-resize use 32382 us.
opencv resize use 337 us.
python image.resize() use 7209 us.

codes like:

// pillow resize
cv::Mat thumbnail_img = PillowResize::resize(image, cv::Size(image_size, image_size),
                                                 PillowResize::InterpolationMethods::INTERPOLATION_BICUBIC);

// opencv resize
cv::Mat thumbnail_img;
    cv::resize(image, thumbnail_img, cv::Size(image_size, image_size), cv::INTER_CUBIC);

// py image resize
thumbnail_img = image.resize((image_size, image_size))
@zhaocc1106
Copy link
Author

Any updates?

@marcov868
Copy link
Contributor

I made the tests with the image you shared and I got quite different results:

  • pillow-resize: 26448 μs
  • OpenCV (4.10.0): 2755 μs
  • PIL (python 3.12 + PIL 11.0.0): 29189 μs

In my environment, the results between pillow-resize and PIL seem comparable, which makes sense since they are based basically on the same code. OpenCV is way faster for me too, but for "only" one order of magnitude. I never dug too much inside the OpenCV code, so I'm not sure the reason behind this difference. I guess it is because of a more optimized code and probably due to the non-exact antialiasing algorithm.

Back to your case, I can't explain your results since they are quite different from mine. Can you share more details about the environment and the compilation methods of the scripts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants