Skip to content

Instantly share code, notes, and snippets.

@zhangdxchn
Last active November 30, 2019 07:48
Show Gist options
  • Save zhangdxchn/ae7d50f9def6e8c4504ec8925ce8d031 to your computer and use it in GitHub Desktop.
Save zhangdxchn/ae7d50f9def6e8c4504ec8925ce8d031 to your computer and use it in GitHub Desktop.
Python
# python
def beauty_face(img):
'''
Dest =(Src * (100 - Opacity) + (Src + 2 * GuassBlur(EPFFilter(Src) - Src + 128) - 256) * Opacity) /100 ;
https://my.oschina.net/wujux/blog/1563461
'''
dst = np.zeros_like(img)
#int value1 = 3, value2 = 1; 磨皮程度与细节程度的确定
v1 = 3
v2 = 1
dx = v1 * 5 # 双边滤波参数之一
fc = v1 * 12.5 # 双边滤波参数之一
p = 0.1
temp4 = np.zeros_like(img)
temp1 = cv2.bilateralFilter(img,dx,fc,fc)
temp2 = cv2.subtract(temp1,img)
temp2 = cv2.add(temp2,(10,10,10,128))
temp3 = cv2.GaussianBlur(temp2,(2*v2 - 1,2*v2-1),0)
temp4 = cv2.add(img,temp3)
dst = cv2.addWeighted(img,p,temp4,1-p,0.0)
dst = cv2.add(dst,(10, 10, 10,255))
return dst
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment