zurutech / pillow-resize

Porting of Pillow resize method in C++ and OpenCV.
Apache License 2.0
123 stars 16 forks source link

resize using INTERPOLATION_BICUBIC has problem #11

Closed Rainy000 closed 1 year ago

Rainy000 commented 1 year ago

I using the resize method at INTERPOLATION_BICUBIC mode, the result is diffrent with python api。

c++ code : cv::Mat src = cv::imread("sample.jpg") int new_w = 736; int new_h = 391; cv::Size resize_size = cv::Size(new_w, new_h); PillowResize::InterpolationMethods interpolation = PillowResize::InterpolationMethods::INTERPOLATION_BICUBIC; cv::Mat cpp_resize= PillowResize::resize(src, resize_size, interpolation);

python code: src = cv2.imread("sample.jpg") new_w = 736 newh = 391 src = Image.fromarray(src) resizedimage= src.resize((new_w, new_h), Image.BICUBIC)

image

marcov868 commented 1 year ago

You're right. I noticed that there are differences in case the destination size is not multiple of the input. So, when a stretch is needed.

To be more robust, we added some tests following your hint. We took an image and resized it with all the different methods from Python and then we compare the results with the images generated with the library (pixel-wise).

During the tests, I also spotted another bug with the nearest interpolation that now should be fixed.

The changes are currently under review and they will be ready soon.

Rainy000 commented 1 year ago

it's so great, I will try again later, thank you!