6.Image zoom

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

Code path:/home/yahboom/Dofbot/4.opencv/02_OpenCV Transform/01 pixel operation.ipynb

Parameter explanation:

InputArray srcEnter image
OutputArray dstOutput Image
SizeOutput image size
fx, fyScaling coefficients along the x-axis, y-axis
interpolationInsertion method

Interpolation method used by options:

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

Notice:

1.Output size format is (width, height)

  1. The default interpolation method is: bilinear interpolation

The main code is as follows:

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

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

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

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

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