Welcome to Raspbot V2 repository
当製品の日本語版マニュアル資料は、こちらからご取得ください。
4. Brightness enhancement
4. Brightness enhancement
4.1. Brightness enhancement
Implementation process: Amplify the three-channel values of each pixel synchronously while keeping the channel values between 0-255. In fact, it is to traverse each pixel, add or subtract values to them, and then determine whether the three channels RGB are in the range of 0-255. If they are greater or less than 255, they are taken as 255 or 0.
4.2 Actual effect display
Source code path:
/home/pi/project_demo/06.Open_source_cv_fundamentals_course/D.Image_Enhancement/04_Brightness_Enhancement.ipynb
x
import cv2import numpy as npimport matplotlib.pyplot as plt
img = cv2.imread('yahboom.jpg',1)imgInfo = img.shapeheight = 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)img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)dst = cv2.cvtColor(dst, cv2.COLOR_BGR2RGB)plt.figure(figsize=(14, 6), dpi=100) #设置绘图区域的大小和像素 Set the size and pixels of the drawing areaplt.subplot(121) # 一行二列第一个 The first row and second columnplt.imshow(img)plt.subplot(122) # 一行二列第二个 The second row, second columnplt.imshow(dst)plt.show()