Commit 359f84d3 authored by 吴升宇's avatar 吴升宇

wsy fix

parent 4258b130
......@@ -92,4 +92,8 @@ ENV/
# Intelija ID
.idea/
\ No newline at end of file
.idea/
.DS_Store
.vscode/
input/
output/
import cv2
import skin_detector
import os
def skin_to_white(img_path):
image = cv2.imread(img_path)
mask = skin_detector.process(image, thresh=0.5)
for i in range(0, mask.shape[0]):
for j in range(0, mask.shape[1]):
if mask[i, j] == 255:
image[i, j] = 255
img_path = img_path.replace('input', 'output')
cv2.imwrite(img_path, image)
def input_files():
files = os.listdir('input')
for file in files:
img_path = 'input/' + file
skin_to_white(img_path)
print(img_path)
if __name__ == '__main__':
input_files()
#
# image = cv2.imread(img_path)
# mask = skin_detector.process(image)
#
# img_path = img_path.replace('input', 'output')
#
#
#
#
#
# cv2.imwrite('abc.jpg', mask)
#
# mask = cv2.imread('abc.jpg')
#
#
#
# img_add = cv2.addWeighted(image, 0.1, mask, 0.9, 0)
#
# cv2.imwrite(img_path, img_add)
......@@ -147,3 +147,15 @@ def process(img, thresh=0.5, debug=False):
mask = grab_cut_mask(img, mask, debug=debug)
return mask
def skin_to_white(img_path):
image = cv2.imread(img_path)
mask = process(image, thresh=0.5)
for i in range(0, mask.shape[0]):
for j in range(0, mask.shape[1]):
if mask[i, j] == 255:
image[i, j] = 255
return image
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment