OpenCV python 图像向上采样

OpenCV python 图像向上采样

在这里插入图片描述

import cv2


def main():

    # 1.导入图片
    img_src = cv2.imread("source1.jpg")

    # 2.执行向下采样
    img_result1 = cv2.pyrUp(img_src)
    img_result2 = cv2.pyrUp(img_result1)
    img_result3 = cv2.pyrUp(img_result2)

    # 3.打印图片结果
    print("img_src=", img_src.shape)
    print("img_result1=", img_result1.shape)
    print("img_result2=", img_result2.shape)
    print("img_result3=", img_result3.shape)

    # 4.显示结果
    cv2.imshow("img_src", img_src)
    cv2.imshow("img_result1", img_result1)
    cv2.imshow("img_result2", img_result2)
    cv2.imshow("img_result3", img_result3)

    cv2.waitKey()
    cv2.destroyAllWindows()


if __name__ == '__main__':
    main()

处理结果图片[img_result1.jpg]
OpenCV python 图像向上采样_第1张图片
处理结果图片[img_result2.jpg]
OpenCV python 图像向上采样_第2张图片

处理结果图片[img_result3.jpg]
OpenCV python 图像向上采样_第3张图片

你可能感兴趣的:(Opencv-python)