openCV 扩图

发布时间:2019-05-06 22:15:36编辑:auto阅读(2068)

    1、扩图

    import cv2
    import numpy as np
    img=cv2.imread('Test2.jpg',1)
    width=img.shape[0]
    height=img.shape[1]
    dst=np.zeros((200,200,3),np.uint8)
    for i in range(200):
        for j in range(200):
            if i>30 and j>30 and i<190 and j<120:
                print(i,j)
                dst[i,j]=img[i-30,j-30]
            else:
                dst[i,j]=(111,111,111)
    
    cv2.imshow('dst',dst)
    cv2.imshow('src',img)
    redst=cv2.resize(dst,(64,128))
    cv2.imwrite('34.jpg',redst,[cv2.IMWRITE_JPEG_QUALITY,100])
    cv2.waitKey(0)

     

关键字