As I mentioned in my previous post, I need to do a application which takes frontal face image and make it as an animated image. In this the main part is to rotate the head part. I used this blog to rotate the image.
What I did is I selected the face area, saved it as an image and passed it to the rotation code. Then I copied the rotated image to the original image. The below is the rotated image.
What I actually need is to avoid the black area and make warping. How to avoid the black area with the code?
For this case you can use inpainting, I think it will work good.
But also take a look at thin plate spline (there are several implementations in web) and piecewise affine warp.
I mean next steps:
1) make grid uniform or face triangulation then rtansform grid nodes as you need (rotate nodes in face region).
2) apply transform (thin plate spline or piecewise affine warp).
Sorry for russian comments, it's too long for me translate them all :) if you will have troubles ask me, I'll try explain.
The wrapper for the triangle library:
My implementation of piecewise affine warper:
I have also TPS, but it slower than piecewise affine warper.