Incorrect value of pixels when use resize method

System information (version)
  • OpenCV => 4.2.0.32
  • Operating System / Platform => win10
  • Compiler => PyCharm 2019.3.4
Detailed description

Hello! When I resize a picture in seemingly one way I get different results.

Steps to reproduce
image = np.ones((10, 10))
image1 = cv2.resize(image, (2, 2), cv2.INTER_AREA)
[[1. 1.] 
[1. 1.]]
image2 = cv2.resize(image, (2, 2), interpolation=cv2.INTER_AREA)
[[0.99999998 0.99999998]
[0.99999998 0.99999998]]

I will be glad for your help!
Thanks you!

Issue submission checklist
  • I report the issue, it’s not a question
  • I checked the problem with documentation, FAQ, open issues,
    forum.opencv.org, Stack Overflow, etc and have not found solution

  • I updated to latest OpenCV version and the issue is still there
  • There is reproducer code and related data files: videos, images, onnx, etc

1 possible answer(s) on “Incorrect value of pixels when use resize method

  1. image1 = cv2.resize(image, (2, 2), cv2.INTER_AREA)

    If you see the documentation below you will see the third argument resize function expects is fx and not interpolation so in your code image1 is interpolated by cv2.INTER_LINEAR which is the default technique hence you are getting different output in image2 you are forcefully passing interpolation = cv2.INTER_AREA hence it is interpolated AREA wise and getting different output

    image

    You can reproduce the same output by
    image