2024-10-01 19:14:49 发布
网友
我想用在这里打开简历是原始图像
当前I'm doing
然后使用OpenCV应用non-photorealistic rendering。这是最终输出 我想生成统一颜色的脸(同时去除光反射),而不影响眼睛、嘴。如何通过调整当前代码或opencv(python)中的其他可能方法来实现这一点
{基于}
下面是一个代码,它可以满足您的需要:
import cv2 import numpy as np from sklearn.cluster import MiniBatchKMeans n = 32 # read image and convert to gray img = cv2.imread('./obama.jpg',cv2.IMREAD_COLOR) img = cv2.resize(img, (0,0), fx=.2, fy=.2) img = cv2.cvtColor(img, cv2.COLOR_BGR2LAB) (h, w) = img.shape[:2] img =np.reshape(img, (img.shape[0]* img.shape[1], 3)) clt = MiniBatchKMeans(n_clusters=n) labels = clt.fit_predict(img) quant = clt.cluster_centers_.astype("uint8")[labels] quant = np.reshape(quant, (h,w,3)) img = np.reshape(img, (h,w,3)) quant = cv2.cvtColor(quant, cv2.COLOR_LAB2BGR) img = cv2.cvtColor(img, cv2.COLOR_LAB2BGR) double = np.hstack([img, quant]) while True: cv2.imshow('img', double) k = cv2.waitKey(30) & 0xff if k == 27: break
您可以使用本教程仅将颜色量化应用于包含面的框。在
https://realpython.com/face-recognition-with-python/
{基于}
下面是一个代码,它可以满足您的需要:
您可以使用本教程仅将颜色量化应用于包含面的框。在
https://realpython.com/face-recognition-with-python/
相关问题 更多 >
编程相关推荐