OpenCV python 图像向下向上采样

OpenCV python 图像向下向上采样

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

import cv2


def main():

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

    # 2.执行向下采样 向上采样
    img_down = cv2.pyrDown(img_src)
    img_up = cv2.pyrUp(img_down)

    # 3.原图片与采样差值
    img_diff = img_up - img_src

    # 4.显示结果
    cv2.imshow("img_src", img_src)
    cv2.imshow("img_down", img_down)
    cv2.imshow("img_up", img_up)
    cv2.imshow("img_diff", img_diff)

    cv2.waitKey()
    cv2.destroyAllWindows()


if __name__ == '__main__':
    main()

结果图片[img_down.jpg]
OpenCV python 图像向下向上采样_第2张图片
结果图片[img_up.jpg]
OpenCV python 图像向下向上采样_第3张图片
结果图片[img_diff.jpg]
OpenCV python 图像向下向上采样_第4张图片

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