Python + OpenCV 学习笔记(十)>>> 图像金字塔

版权声明:如需转载请标注 https://blog.csdn.net/weixin_40973138/article/details/88706743

具体请参见OpenCV 教程

import cv2 as cv 


def image_pyramid(image):
        src = cv.imread(image)
        #h, w, c = src.shape()

        tmp = src
        dst = tmp
        c = input()
        if c == 27:
                return 0
        if c == 1:
                dst = cv.pyrUp(tmp)
        if c == 0:
                dst = cv.pyrDown(tmp)

        cv.imshow('customary', src)
        cv.imshow('pyramid', dst)


image_pyramid('/home/pi/Desktop/m2.jpg')
cv.waitKey(0)
cv.destroyAllWindows()

向上:
在这里插入图片描述
向下:
在这里插入图片描述


def continue_pyramid(image):
        src = cv.imread(image)
        tmp = src
        dst = tmp
        for i in range(4):
                dst = cv.pyrDown(dst)
                cv.imshow('result' + str(i), dst)

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_40973138/article/details/88706743