Welcome to DOGZILLA-Lite repository
5. Skin whitening
5. Skin whitening
5.1. Skin whitening
OpenCV implements the function of skin whitening for 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/DOGZILLA_Lite_class/4.Open Source CV/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 pltimg = 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()
xxxxxxxxxximport cv2import matplotlib.pyplot as pltimg = 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()