• INTER_NEAREST – a nearest-neighbor interpolation
• INTER_LINEAR – a bilinear interpolation (used by default)
• INTER_AREA – resampling using pixel area relation. It may be a preferred method for image decimation, as it gives moire’-free results. But when the image is zoomed, it is similar to theINTER_NEAREST method.
• INTER_CUBIC – a bicubic interpolation over 4×4 pixel neighborhood
• INTER_LANCZOS4 – a Lanczos interpolation over 8×8 pixel neighborhood

from the official docs.

I use this often when using cv2.resize method. For example,

import cv2

resized = cv2.resize(img, (100,100), interpolation=cv2.INTER_LINEAR)

reducing resize results

here is the default image.(50×50)

and here are the results of reducing it to 15×15 with various interpolation methods.

enlarge resize results

with the same default image used above, here are the results when it is enlarged to 100×100

Categories: python

makaros · June 3, 2019 at 9:50 pm

How exactly does nearest-neighbor interpolation behaves when you downscale an image from 50×50 to 15×15? How is this 15×15 images filled in with values ?

nkumar · September 26, 2019 at 3:48 pm

good discussion. are there any other method that retains the sharpness of edges when compressing? i feel edge detection is compromised when using the standard options.

Pierre · May 26, 2020 at 10:24 pm

That’s was useful ! Thanks 🙂

good comparision

Shraddha · February 2, 2021 at 7:08 am

Thank you for creating this and showing a clear difference. it was useful.

Ethan · April 30, 2021 at 9:14 pm

Great post! The example images really help you decide what type of interpolation you want.

Dan · May 7, 2021 at 8:14 pm

Which method is the fastest, INTER_LINEAR maybe?