Search code examples
pythonnumpyopencvimage-resizing

Difference between opencv and numpy resize functions


It is not clear to me the difference between resizing a numpy array using numpy.resize or using cv2.resize.

While implementing a CNN for image processing, I had a massive memory leak when using Numpy's function to resize a 800x800 array to 10x10, which I managed to solve by using cv2.resize instead, so I wonder what is the different behavior of this function that may have solved the problem.


Solution

  • If you compare the documentation of cv2.resize with the one of np.resize you will realize that they do completely differen things. The numpy function rearranges the data to fit the give output shape, possibly repeating or discarding data. The opencv function on the other hand is for rescaling images to a different resolution. They basically have nothing in common.