hzhao1997 / HF-Avatar

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

手部黑色如何解决

wusidong opened this issue · comments

你好,作者,生成的三维模型手的地方的黑色问题该如何解决呢?
image

我看了论文附件的内容,生成的纹理图的手是没有黑色的,这是怎么解决的呢?目前我生成的纹理贴图是下巴、手臂、还是手的位置是黑色的
image
image

论文中手部黑色是后处理统一填充为平均肤色的

感谢回复,那问下这是根据软件解决的呢?还是通过代码呢?

论文中手部黑色是后处理统一填充为平均肤色的

感谢回复,那问下这是根据软件解决的呢?还是通过代码呢?

这个之前写的,通过膨胀手部颜色来填充黑色,你可以稍微研究下

hand_mask
def _dilate(img, iter):
    for i in range(iter):
        img = cv2.dilate(img, np.ones((3, 3), np.uint8))
    return img

def postprocess_tex(img):
    target = np.array([[[0, 0, 0]]])
    value = np.sqrt(np.sum(np.square(img-target), axis=2 ))
    # threshold =
    mask = np.zeros([img.shape[0], img.shape[1]])
    mask[np.where(value<200)] = 1
    dilated_mask = copy.deepcopy(mask)

    hand_mask = cv2.imread('../results/hand_mask.png')
    hand_mask = cv2.resize(hand_mask, (img.shape[0], img.shape[1]))
    dilated_hand_mask = cv2.dilate(hand_mask, kernel=np.ones((3, 3), np.uint8))

    mask[np.where(hand_mask[:, :, 0] == 0)] = 0
    dilated_mask[np.where(dilated_hand_mask[:, :, 0] == 0)] = 0
    img[np.where(mask == 1)] = [0, 0, 0]

    hand_img = np.zeros_like(img)
    hand_img[np.where(hand_mask==255)] = img[np.where(hand_mask==255)] #
    hand_img[:, :, 0] = _dilate(hand_img[:, :, 0], 50)
    hand_img[:, :, 1] = _dilate(hand_img[:, :, 1], 50)
    hand_img[:, :, 2] = _dilate(hand_img[:, :, 2], 50)
    img[np.where(dilated_mask == 1)] = hand_img[np.where(dilated_mask == 1)]

    return img