cv2.resize(src,dsize[,dst[,fx,[fy[,interpolation]]]])
image.png

  • 之前同一图片大小的时候用的numpy切割,会造成图像的部分的损失,而现在用resize的话,可以保证图像一样大小,且画面不损失。
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    #!/usr/bin/env python
    # -*- coding: UTF-8 -*-
    """
    @Project :Opencv学习
    @File :resize.py
    @IDE :PyCharm
    @Author :咋
    @Date :2023/1/12 21:26
    """
    import cv2
    import numpy as np
    test = cv2.imread("image.jpg")
    image = cv2.imread("Handsome.jpg")
    test = cv2.resize(test,(640,480))
    image = cv2.resize(image,(640,480))
    cv2.imshow("not_image",np.hstack((image,test)))
    cv2.waitKey(0)
    cv2.destroyAllWindows()

    image.png