亮度增强

代码如下:

#新像素的亮度 P = old (P ) + 常量
import cv2
import numpy as np
img = cv2.imread('image0.jpg',1)
imgInfo = cv2.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]
        newb = int(b)+40
        newg = int(g)+40
        newr = int(r)+40
        if newb>255:
            newb = 255
        if newg>255:
            newg = 255
        if newr >255:
            newr = 255
        dst[i,j] = (newb,newg,newr)
cv2.imshow('dst',dst)
cv2.waitKey(0)

显示如下:
在这里插入图片描述

发布了39 篇原创文章 · 获赞 2 · 访问量 615

猜你喜欢

转载自blog.csdn.net/yuan_xiangjun/article/details/105662682