Welcome to Raspberry Pi 4B repository
1.Picture Zoom
Picture Zoom
In OpenCV, the function to achieve picture zoom:
cv2.resize(InputArray src, OutputArray dst, Size, fx, fy, interpolation)
Code:
About parameter:
InputArray src | Input picture |
OutputArray dst | Output picture |
Size | Size of output picture |
fx, fy | Zoom factor along x-axis and y-axis |
interpolation | Interpolation method |
The interpolation method used by the interpolation option:
INTER_NEAREST | Nearest neighbor interpolation |
INTER_LINEAR | Bilinear interpolation(default setting) |
INTER_AREA | Using the pixel region relationship to complete to re-sampling |
INTER_CUBIC | Bicubic interpolation of 4x4 pixel neighborhood |
INTER_LANCZOS4 | Lanczos interpolation of 8x8 pixel neighborhood |
Note:
1.Size format: (width, height)
2.The default interpolation method: bilinear interpolation
|
After the program is executed, we can see that the image is 800 * 800. As shown below.
|
After the program is executed, we can see that the image is 400 * 400. zoom 1/2 As shown below.
|
After the program is executed, we can see that the image is 200 * 200, zoom 1/4. As shown below.
Next, we will introduce matplotlib: 2D plotting library for Python
Tutorial: https://www.runoob.com/numpy/numpy-matplotlib.html
|