【问题标题】:Extracted Facial Region using DLIB contain noise使用 DLIB 提取的面部区域包含噪声
【发布时间】:2022-01-13 19:52:57
【问题描述】:

您好, 我一直在尝试从脸上提取一些区域 在这种情况下(上唇)使用 Dlib,问题是在提取 ROI(看起来很完美)之后,我意识到 ROI 周围有一些噪音 无法弄清楚我做错了什么,以及如何解决这个问题。 这是使用的 Python 代码:

import cv2
import numpy as np
import dlib
import os 
from scipy import ndimage, misc
import time

def extract_index_nparray(nparray):
    index = None
    for num in nparray[0]:
        index = num
        break
    return index
img = cv2.imread( 'input_facial_image.jpg')
img=cv2.resize(img,(512,512))
img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
mask = np.zeros_like(img_gray)
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor("/facial-landmarks-recognition/shape_predictor_68_face_landmarks.dat")
# Face 1
faces = detector(img_gray)
for face in faces:
    landmarks = predictor(img_gray, face)
    landmarks_points = []
    for n in [48,49,50,51,52,53,54,64,63,62,61,60]:
        x = landmarks.part(n).x
        y = landmarks.part(n).y
        landmarks_points.append((x, y))
   points = np.array(landmarks_points, np.int32)
   convexhull = cv2.convexHull(points)
   # cv2.polylines(img, [convexhull], True, (255, 0, 0), 3)
   cv2.fillConvexPoly(mask, convexhull, 255)

   face_image_1 = cv2.bitwise_or(img, img, mask=mask)
   cv2.imwrite('extracted_lips.jpg', face_image_1 )

提取的图像如下所示: upper lips extracted image 但在我工作的进一步步骤中,我意识到上唇周围有噪音,所以我检查并发现unclean_upperlip 有什么方法可以在 ROI 提取过程中消除噪音,或者有什么图像处理技术可以绕过这个问题? 提前致谢

【问题讨论】:

    标签: opencv computer-vision feature-extraction dlib facial-landmark-alignment


    【解决方案1】:

    对于和我遇到同样问题的人来说,这很简单。只需将输出格式更改为png。 JPG压缩是这里的问题。 我希望这会有所帮助

    【讨论】:

      猜你喜欢
      • 2015-06-07
      • 2018-07-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-24
      • 1970-01-01
      • 2015-05-24
      相关资源
      最近更新 更多