Search code examples
pythonopencvimage-processingscikit-image

Equivalent of cv2.INTER_AREA in SkImage


I am trying to reproduce a result from OpenCV using SkImage. In OpenCV we have:

img1 = cv2.resize(img, (w, h), interpolation=cv2.INTER_AREA)

In SkImage, my best shot so far is:

img2 = skimage.transform.resize(img, (w, h))

However, I am still not able to get the same result as OpenCV. I read the documentation on cv2.INTER_AREA and this article, but I am still unsure of how to reproduce this result in SkImage.

What is missing from the skimage implementation? A PIL.Image implementation could work too. Suggestions on how to diagnose the problem are appreciated.

Examples of the difference between img1 (OpenCV) and img2 (SkImage) are as follows:

enter image description here

enter image description here

enter image description here


Solution

  • You are using the width and height in skimage in wrong order. It should be reversed like below:

    img2 = skimage.transform.resize(img, (h, w))

    Then compare the result. Usually skimage produce better result compared to OpenCV.