opencv图像加密

import cv2
import numpy as np
cat = cv2.imread(‘3.jpg’)
rows,colmns,channel = cat.shape
img_key = np.random.randint(0,256,(rows,colmns,channel),np.uint8)

def encode(img,img_key):
result = img = cv2.bitwise_xor(img,img_key)
return result
#加密
result = encode(cat,img_key)
cv2.imwrite(‘1.jpg’,result)
#解密
result = encode(result,img_key)
cv2.imwrite(‘2.jpg’,result)

你可能感兴趣的:(opencv,计算机视觉,python)