Search code examples
alignmentface-recognition

How to align Face Images using Matlab?


I'm looking for a face image alignment code in matlab.Can somebody please help?

Thanks.


Solution

  • This is the method that I used, may be not the only way but this is what I can think about:

    1. Select an image as reference.
    2. Apply points feature algorithm. As an example, three points on left eye and three points on right eye. So now, we have reference = [x1,y1; x2,y2; x3,y3;.....;x6,y6];
    3. Next, loop all the images one by one, and get the points feature which are exactly at the same place as reference image. move = [X1,Y1; X2,Y2; X3,Y3;.....;X6,Y6]
    4. Calculate geometric transformation using: [tform,inlierPtsDistorted,inlierPtsOriginal] = estimateGeometricTransform(move,reference,'similarity');.

    5. Then, warp the two images as follow: outputView = imref2d(size(referenceImage)); Ir = imwarp(probeImage,tform,'OutputView',outputView);

    This is image shows the points between reference image and probe image are matched:

    enter image description here

    Reference (1st image) and the outputs:

    enter image description hereenter image description hereenter image description hereenter image description here

    This method also crop out the background and hair, since my reference image does not contain background and hair part.