美文网首页
08亮度增强

08亮度增强

作者: 犬夜叉写作业 | 来源:发表于2019-07-18 22:41 被阅读0次

1、简单的加上一个固定值

# p = p+40  简单的加上一个固定值
import cv2
import numpy as np
img = cv2.imread('image0.jpg',1)
imgInfo = img.shape
height = imgInfo[0]
width = imgInfo[1]
cv2.imshow('src',img)

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 = int(b)+40
        gg = int(g)+40
        rr = int(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('dst',dst)
cv2.waitKey(0)

2、乘以一个数再加上一个数

# p = p+40
# p = p*1。2+40
# g+r P*piexl = new
import cv2
import numpy as np
img = cv2.imread('image0.jpg',1)
imgInfo = img.shape
height = imgInfo[0]
width = imgInfo[1]
cv2.imshow('src',img)
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 = int(b*1.3)+10
        gg = int(g*1.2)+15

        if bb>255:
            bb = 255
        if gg>255:
            gg = 255

        dst[i,j] = (bb,gg,r)
cv2.imshow('dst',dst)
cv2.waitKey(0)


相关文章

网友评论

      本文标题:08亮度增强

      本文链接:https://www.haomeiwen.com/subject/zufdlctx.html