人脸对齐算法 [英] face alignment algorithm on images
问题描述
如何在二维图像上进行基本的脸部对准,假设我有嘴巴和眼睛的位置/坐标。
How can I do a basic face alignment on a 2-dimensional image with the assumption that I have the position/coordinates of the mouth and eyes.
有没有任何算法可以实现来纠正图像上的脸部对齐?
Is there any algorithm that I could implement to correct the face alignment on images?
推荐答案
面部(或图像)对齐是指将一个图像参考图像/面)。它也被称为图像配准。您可以使用外观(基于强度的注册)或关键点位置(基于功能的注册)来实现。第二类来自图像运动模型,其中一个图像被认为是另一个的移位版本。
Face (or image) alignment refers to aligning one image (or face in your case) with respect to another (or a reference image/face). It is also referred to as image registration. You can do that using either appearance (intensity-based registration) or key-point locations (feature-based registration). The second category stems from image motion models where one image is considered a displaced version of the other.
在您的情况下,地标位置(眼睛和鼻子的3个点)为简单的基于特征的注册提供了一个很好的参考集。假设您在两个2D图像中都有一组点的位置,则 x_1
和 x_2
x_1 $ c $的平面2D变换
S
c>到 x_2
。你可以另外添加反射,虽然对于面孔这很可能是不必要的。
In your case the landmark locations (3 points for eyes and nose?) provide a good reference set for straightforward feature-based registration. Assuming you have the location of a set of points in both of the 2D images, x_1
and x_2
you can estimate a similarity transform (rotation, translation, scaling), i.e. a planar 2D transform S
that maps x_1
to x_2
. You can additionally add reflection to that, though for faces this will most-likely be unnecessary.
估算可以通过形成正态方程并求解 x_1 = Sx_2 $ c的线性最小二乘法$ c>系统使用线性回归。对于5个未知参数(2旋转,2平移,1缩放),您将需要3个点(2.5是精确的)来求解5个方程。上述LS的解可以通过直接线性变换(例如通过应用SVD或矩阵伪逆)来获得。对于足够多的参考点(即自动检测)的情况,使用用于点滤波和不确定性消除的RANSAC型方法(尽管这不是您的情况)。
Estimation can be done by forming the normal equations and solving a linear least-squares (LS) problem for the x_1 = Sx_2
system using linear regression. For the 5 unknown parameters (2 rotation, 2 translation, 1 scaling) you will need 3 points (2.5 to be precise) for solving 5 equations. Solution to the above LS can be obtained through Direct Linear Transform (e.g. by applying SVD or a matrix pseudo-inverse). For cases of a sufficiently large number of reference points (i.e. automatically detected) a RANSAC-type method for point filtering and uncertainty removal (though this is not your case here).
在估计 S
之后,对第二个图像应用图像扭曲,整个 image 2
。变换将改变像素位置,但不会改变它们的外观。不可避免地, image 2
的一些变换区域将位于图像1
的网格之外,您可以决定
After estimating S
, apply image warping on the second image to get the transformed grid (pixel) coordinates of the entire image 2
. The transform will change pixel locations but not their appearance. Unavoidably some of the transformed regions of image 2
will lie outside the grid of image 1
, and you can decide on the values for those null locations (e.g. 0, NaN etc.).
有关详细信息:R. Szeliski,图像对齐和拼接:A教程(第4.3节几何注册)
For more details: R. Szeliski, "Image Alignment and Stitching: A Tutorial" (Section 4.3 "Geometric Registration")
在OpenCV中,请参阅:几何图像转换,例如 cv :: getRotationMatrix2D
cv :: getAffineTransform
和 cv :: warpAffine。
请注意,您应该估计和应用相似变换(仿射的特殊情况),以保留角度和形状。
In OpenCV see: Geometric Image Transformations, e.g. cv::getRotationMatrix2D
cv::getAffineTransform
and cv::warpAffine.
Note though that you should estimate and apply a similarity transform (special case of an affine) in order to preserve angles and shapes.
这篇关于人脸对齐算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!