1. Image resizing

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

The code is running on jupyter lab

Parameter explanation:

InputArray srcInput image
OutputArray dstOutput picture
SizeOutput image size
fx, fyScaling factors along the x-axis, y-axis
interpolationinsertion method

Interpolation method used by the interpolation option:

INTER_NEARESTNearest neighbor interpolation
INTER_LINEARBilinear interpolation (default setting)
INTER_AREAResampling using pixel area relationships.
INTER_CUBICBicubic interpolation of 4x4 pixel neighborhoods
INTER_LANCZOS4Lanczos interpolation of 8x8 pixel neighborhoods

Notice:

  1. The output size format is (width, height)
  2. The default interpolation method is: bilinear interpolation

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

After execution, you can see that the image is 400*400, scaled by half.

After execution, you can see that the image is 200*200, scaled by a quarter.

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

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