OpenCV - 适用于薄板花键扭曲实现 [英] OpenCV - suitable implementation for Thin - Plate Spline Warping

查看:951
本文介绍了OpenCV - 适用于薄板花键扭曲实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个面部的形状,与该面部的重建一起,我想对初始形状的相应图像建模。

基本上,我想要以将点从原始形状移动到由面部的重建指示的位置。我试图这样做通过使用薄板样条扭曲,这种实现: http: //ipwithopencv.blogspot.ro/2010/01/thin-plate-spline-example.html



但是,它不工作,因为我想要。我想让图像的角落固定,只是移动定义面部的对应点。我可以用2张图片说明这一点。在第一张图片我有重建的形状的原始脸的形状。



在这里我有我要修改的图片和结果的图片通过使用从上面提到的链接的代码。绿色的点标记原始的面部点,蓝色的点标记他们的新位置,我想重新放置他们和拉伸我的脸。





我只想将绿点移动到蓝点,使它看起来变形。

解决方案

固定角落很容易。只需为四个图像角添加四个附加对应关系即可。在你的例子:

  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));

当然, width height 是图片高度


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.

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.

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?

解决方案

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

这篇关于OpenCV - 适用于薄板花键扭曲实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆