Welcome to Raspbot V2 repository
当製品の日本語版マニュアル資料は、こちらからご取得ください。
5. Smooth and whiten
5. Smooth and whiten
5.1. Smooth and whiten
OpenCV implements the function of smoothing and whitening images. The principle of implementation is basically the same as the principle of "1.20 OpenCV Image Brightness Enhancement", but here we do not need to process the r value, just follow this formula, p = p(x)*1.4+ y, where p(x) represents the b channel or g channel, and y represents the value to be increased or decreased. Similarly, after adding the value, we need to judge the value.
5.2 Actual effect display
Source code path:
/home/pi/project_demo/06.Open_source_cv_fundamentals_course/D.Image_Enhancement/05_Skin_Smoothing_and_Whitening.ipynb
x#图片的美白公式:p = P*1.4(a)+ b; Image whitening formula: p = P*1.4(a)+ b;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*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)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()
xxxxxxxxxx
import cv2import matplotlib.pyplot as plt
img = cv2.imread('yahboom.jpg',1)#cv2.imshow('src',img)dst = cv2.bilateralFilter(img,15,35,35)# 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()