原理:将所有像素点的值加上一个常数
import cv2
import numpy as np
img = cv2.imread('D:/pythonob/imageinpaint/img/flower.jpg',1)
cv2.imshow('src',img)
imgInfo = img.shape
height = imgInfo[0]
width = imgInfo[1]
dst = np.zeros((height,width,3),np.uint8)
for i in range(0,height):
for j in range(0,width):
(b,g,r) = img[i,j]
bb = b+40
gg = g+40
rr = r+40
if bb>255:
bb = 255
if gg>255:
gg = 255
if rr>255:
rr = 255
dst[i,j]=(bb,gg,rr)
cv2.imshow('afterImg',dst)
cv2.waitKey(0)
效果图: