Image scaling

In OpenCV, the function for image scaling is: cv2.resize(InputArray src, OutputArray dst, Size, fx, fy, interpolation)

Code path:

Parameter explanation:

InputArray srcInput image
OutputArray dstOutput image
SizeOutput image size
fx, fyScaling coefficients along the x-axis and y-axis
interpolationInterpolation method

Option interpolation method used:

INTER_NEARESTNearest neighbor interpolation
INTER_LINEARBilinear interpolation (default setting)
INTER_AREAResample using pixel area relations.
INTER_CUBICBicubic interpolation of 4x4 pixel neighborhood
INTER_LANCZOS4Lanczos interpolation of 8x8 pixel neighborhood

Note:

  1. The output size format is (width, height)

  2. The default interpolation method is: bilinear interpolation

The main code is as follows:

After execution, you can see that the image is 800*800

After execution, you can see that the image is 400*400, which is half the size

After execution, you can see that the image is 200*200, which is one quarter the size

Next, let's talk about matplotlib: Python's 2D drawing library.

Reference tutorial: https://www.runoob.com/numpy/numpy-matplotlib.html