首页 > 代码库 > 《Image Warping Using Few Anchor Points and Radial Function》论文实现

《Image Warping Using Few Anchor Points and Radial Function》论文实现

《Image Warping Using Few Anchor Points and Radial Functions》achive based OpenCv 、Eigen and Qt

  • (vector blod)
  • paper
    [paper Download](Image Warping Using Few Anchor Points and Radial Functions "paper Download")
  • Tools
    • Eigen
    • OpenCV
  • Concepts
    • radial basic function transformation(RBFT)
    • affine transformation
    • radial transformation
    • radial basic function
    • Euclidean
    • thin-plate spline
    • Gaussians function
  • Important Equation
    • T(xi)=yi for i=1,2,3,……N.——** Equation(1) **
    • T(x)=A(x)+R(x)——** Equation(2) **
    • A(x)=Mx+b ,2D Affine transformation,M is 2 x 2 real Matrix—— ** Equation(3) **
    • R(x)=(Rx(x),Ry(x)),Rx and Ry are both radial functions of the form 技术分享
      g:is aunivariate function,termed the radial basis function
      ||·||:Euclidean norm
      ai & bi: is determined by Anchor Points——** Equation(4) **
    • R(xi)=yi-A(xi),i=1,2,3,……N.——** Equation(5) **
    • 技术分享——** Equation(6) **
    • Gaussian function:技术分享——** Equation(7) **
    • thin-plate spline:技术分享——** Equation(8) **
  • Thinking
    1. load Image
      技术分享
    2. get Anchor points by User Interactive
      技术分享
    3. Analysis source Point and target Point
    4. Controlling the affine component A(x) accoring to the number of anchor points,by Equation(3)
    5. determining the radial component R(x),by Equation(4),Equation(5)
    6. Apply T(x) to every pixel in this image
      技术分享
  • Question and Answer(Q&A)
    • Q1:How to save Image?
    • A1:Translate cv::Mat to Eigen::MatrixXd(3,width*height).
    • Q2:How to save "M" Matrix in Equation(3)?
    • A2:Using Eigen::MartrixXd(2,3).
    • Q3:How to Calcualte "R" Matrix in Equation(2)?
    • A3:Reference Equation(4) and Equation(5).
    • Q4:How to calculate g(x) in Equation(4)?
    • A4:thin-plate spline or Gaussian function.
    • Q5:How to save coordinate before transform?
    • A5:Using MatrixXd(2,1).
    • Q6:How to save coordinate after transform?
    • A6:Using MatrixXd(2,1).
    • Q7:How to save source points and target points?
    • A7:Using Eigen::MatrixXd(2,N)
    • Q8:How to save corespondence between source coordinate and target coordinate?
    • A8: Qt::QList<Line*> lineList;Line is line for start point to end point for anchor pairs.
  • Achieve
    • WarpingRBF.h
  1. //WarpingRBF.h
  2. #ifndef WARPINGRBF_H
  3. #define WARPINGRBF_H
  4. #include<opencv2/opencv.hpp>
  5. #include<QList>
  6. #include<Eigen/Eigen>
  7. #include"line.h"
  8. class WarpingRBF
  9. {
  10. public:
  11. enum GFuncType{
  12. Gaussian_Radio_Function,
  13. Thin_Plate_spline,//r^2log(r)
  14. Gaussian_Radial
  15. };
  16. public:
  17. WarpingRBF();
  18. WarpingRBF(const QList<Line*> & lineList,
  19. const int&N);
  20. public:
  21. void SolveRBF();
  22. void SetImage(const cv::Mat &sourceImage);
  23. void SetGFunc(const GFuncType &gfunctype);
  24. protected:
  25. void InitData();
  26. void InitSourceAndTargetMaritrix(const QList<Line*> &list,
  27. Eigen::MatrixXd &Source_M,
  28. Eigen::MatrixXd &Target_M);
  29. void InitImageMatrix(const cv::Mat &sourceImage,
  30. const int&height,
  31. const int &width,
  32. Eigen::MatrixXd &Image_M);
  33. void CalculateAffineMat(const Eigen::MatrixXd &Source_M,
  34. const Eigen::MatrixXd &Target_M,
  35. const int &N,
  36. cv::Mat &Affine_Mat);
  37. void AffineTranslate(const cv::Mat &srcImage,
  38. const cv::Mat &Affine_Mat,
  39. Eigen::MatrixXd &AfterAffine_M);
  40. void RadioTranslate(const Eigen::MatrixXd &Image_M,
  41. const Eigen::MatrixXd &Source_M,
  42. const Eigen::MatrixXd &Target_M,
  43. const GFuncType &gfunctype,
  44. const cv::Mat &Affine_Mat,
  45. const int &N,
  46. const int &height,
  47. const int &width,
  48. Eigen::MatrixXd &AfterRadio_M);
  49. void RBFTranslate(const Eigen::MatrixXd AfterAffine_M,
  50. const Eigen::MatrixXd AfterRadio_M,
  51. Eigen::MatrixXd Image_M);
  52. void ApplyChangeOnImage(cv::Mat &dstImage,const Eigen::MatrixXd Image_M);
  53. double GetEulaNorm(const Eigen::MatrixXd X_M);//(2*1)--(x,y)^T
  54. private:
  55. cv::Mat srcImage,dstImage,Affine_Mat;
  56. int height,width;
  57. Eigen::MatrixXd Image_M,Source_M,Target_M,AfterAffine_M,AfterRadio_M;
  58. GFuncType gfunctype;
  59. int N;//number of Anchor Points
  60. QList<Line*> lineList;
  61. };
  • Line.h
    ```cpp

ifndef LINE_H

define LINE_H

include

class Line
{
public:
Line();
Line(QPoint start,QPoint end);
void SetStart(QPoint start);
void SetEnd(QPoint End);
QPoint end,start;
private:
};

endif // LINE_H

```

  • Reference
    [1]Image Warping by Radial Basis Function-Application to Facial Expressions
    [2]Image Warping Using Few Anchor Points and Radial Functions


来自为知笔记(Wiz)


《Image Warping Using Few Anchor Points and Radial Function》论文实现