实现图像逐渐增亮或渐暗
实现图像逐渐增亮
源代码:
import cv2
import numpy as np
a=cv2.imread('1.jpg')
i=0
x=1
while i<30:
if a[200,100,0]<=0:
break
M = np.ones(a.shape, dtype='uint8') *x
a = cv2.add(a, M)
# ss=a*x
cv2.imshow('1', a)
cv2.waitKey(200)
i+=1
x+=5
cv2.destroyAllWindows()
实现图像渐暗
源代码:
import cv2
import numpy as np
import os
a=cv2.imread('1.jpg')
i=0
x=1
while i<30:
if a[100,100,0]>=255:
break
M = np.ones(a.shape, dtype='uint8') *x
a = cv2.subtract(a, M)
cv2.imshow('1', a)
cv2.waitKey(200)
i+=1
x+=5
cv2.destroyAllWindows()
使用图片: