OpenCV python 图像向下采样

OpenCV python 图像向下采样

处理图像[source.jpg]
OpenCV python 图像向下采样_第1张图片

import cv2


def main():

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

    # 2.执行向下采样
    img_result1 = cv2.pyrDown(img_src)
    img_result2 = cv2.pyrDown(img_result1)
    img_result3 = cv2.pyrDown(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 图像向下采样_第2张图片
结果图片[img_result2.jpg]
OpenCV python 图像向下采样_第3张图片
结果图片[img_result3.jpg]
在这里插入图片描述

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