Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV - suitable implementation for Thin - Plate Spline Warping

Tags:

c++

opencv

I have the shape of a face with together with the reconstruction of that face and I want to model the corresponding image of the initial shape.

Basically, I want to move the points from the original shape to the position indicated by the reconstruction of the face. I have tried to do this by using thin plate spline warping, this implementation of it : http://ipwithopencv.blogspot.ro/2010/01/thin-plate-spline-example.html.

However, it's not working as I would want. I want to have the corners of the image fixed and just to move the corresponding points which define the face. I can illustrate this with 2 pictures. In the first picture I have the shape of the original face with the reconstructed shape. enter image description here

In here I have the picture which I want to modify and the resulted picture by using the code from the link mentioned above. The green points mark the original face points and the blue points mark their new position and where I want to reposition them and stretch my face.

enter image description here

All I want is just to move the green points to the blue points so that it looks deformed. Do you know of any method to do this which you have tested?

like image 645
Simon Avatar asked Oct 10 '12 04:10

Simon


1 Answers

Getting the corners fixed is quite easy. Just add four additional correspondencies for the four image corners. In terms of your example:

iP.push_back(cv::Point(0, 0));
iiP.push_back(cv::Point(0, 0));
iP.push_back(cv::Point(0, height-1));
iiP.push_back(cv::Point(0, height-1));
iP.push_back(cv::Point(width-1, 0));
iiP.push_back(cv::Point(width-1, 0));
iP.push_back(cv::Point(width-1, height-1));
iiP.push_back(cv::Point(width-1, height-1));

Where, of course, width is the image width and height is the image height

like image 196
AD-530 Avatar answered Nov 18 '22 12:11

AD-530