《Image Warping Using Few Anchor Points and Radial Function》论文实现
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了《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
- load Image
- get Anchor points by User Interactive
- Analysis source Point and target Point
- Controlling the affine component A(x) accoring to the number of anchor points,by Equation(3)
- determining the radial component R(x),by Equation(4),Equation(5)
- 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
//WarpingRBF.h
#ifndef WARPINGRBF_H
#define WARPINGRBF_H
#include<opencv2/opencv.hpp>
#include<QList>
#include<Eigen/Eigen>
#include"line.h"
class WarpingRBF
{
public:
enum GFuncType{
Gaussian_Radio_Function,
Thin_Plate_spline,//r^2log(r)
Gaussian_Radial
};
public:
WarpingRBF();
WarpingRBF(const QList<Line*> & lineList,
const int&N);
public:
void SolveRBF();
void SetImage(const cv::Mat &sourceImage);
void SetGFunc(const GFuncType &gfunctype);
protected:
void InitData();
void InitSourceAndTargetMaritrix(const QList<Line*> &list,
Eigen::MatrixXd &Source_M,
Eigen::MatrixXd &Target_M);
void InitImageMatrix(const cv::Mat &sourceImage,
const int&height,
const int &width,
Eigen::MatrixXd &Image_M);
void CalculateAffineMat(const Eigen::MatrixXd &Source_M,
const Eigen::MatrixXd &Target_M,
const int &N,
cv::Mat &Affine_Mat);
void AffineTranslate(const cv::Mat &srcImage,
const cv::Mat &Affine_Mat,
Eigen::MatrixXd &AfterAffine_M);
void RadioTranslate(const Eigen::MatrixXd &Image_M,
const Eigen::MatrixXd &Source_M,
const Eigen::MatrixXd &Target_M,
const GFuncType &gfunctype,
const cv::Mat &Affine_Mat,
const int &N,
const int &height,
const int &width,
Eigen::MatrixXd &AfterRadio_M);
void RBFTranslate(const Eigen::MatrixXd AfterAffine_M,
const Eigen::MatrixXd AfterRadio_M,
Eigen::MatrixXd Image_M);
void ApplyChangeOnImage(cv::Mat &dstImage,const Eigen::MatrixXd Image_M);
double GetEulaNorm(const Eigen::MatrixXd X_M);//(2*1)--(x,y)^T
private:
cv::Mat srcImage,dstImage,Affine_Mat;
int height,width;
Eigen::MatrixXd Image_M,Source_M,Target_M,AfterAffine_M,AfterRadio_M;
GFuncType gfunctype;
int N;//number of Anchor Points
QList<Line*> lineList;
};
- Line.h
```cpp
ifndef LINE_H
define LINE_H
include
《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
- load Image
- get Anchor points by User Interactive
- Analysis source Point and target Point
- Controlling the affine component A(x) accoring to the number of anchor points,by Equation(3)
- determining the radial component R(x),by Equation(4),Equation(5)
- 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
//WarpingRBF.h
#ifndef WARPINGRBF_H
#define WARPINGRBF_H
#include<opencv2/opencv.hpp>
#include<QList>
#include<Eigen/Eigen>
#include"line.h"
class WarpingRBF
{
public:
enum GFuncType{
Gaussian_Radio_Function,
Thin_Plate_spline,//r^2log(r)
Gaussian_Radial
};
public:
WarpingRBF();
WarpingRBF(const QList<Line*> & lineList,
const int&N);
public:
void SolveRBF();
void SetImage(const cv::Mat &sourceImage);
void SetGFunc(const GFuncType &gfunctype);
protected:
void InitData();
void InitSourceAndTargetMaritrix(const QList<Line*> &list,
Eigen::MatrixXd &Source_M,
Eigen::MatrixXd &Target_M);
void InitImageMatrix(const cv::Mat &sourceImage,
const int&height,
const int &width,
Eigen::MatrixXd &Image_M);
void CalculateAffineMat(const Eigen::MatrixXd &Source_M,
const Eigen::MatrixXd &Target_M,
const int &N,
cv::Mat &Affine_Mat);
void AffineTranslate(const cv::Mat &srcImage,
const cv::Mat &Affine_Mat,
Eigen::MatrixXd &AfterAffine_M);
void RadioTranslate(const Eigen::MatrixXd &Image_M,
const Eigen::MatrixXd &Source_M,
const Eigen::MatrixXd &Target_M,
const GFuncType &gfunctype,
const cv::Mat &Affine_Mat,
const int &N,
const int &height,
const int &width,
Eigen::MatrixXd &AfterRadio_M);
void RBFTranslate(const Eigen::MatrixXd AfterAffine_M,
const Eigen::MatrixXd AfterRadio_M,
Eigen::MatrixXd Image_M);
void ApplyChangeOnImage(cv::Mat &dstImage,const Eigen::MatrixXd Image_M);
double GetEulaNorm(const Eigen::MatrixXd X_M);//(2*1)--(x,y)^T
private:
cv::Mat srcImage,dstImage,Affine_Mat;
int height,width;
Eigen::MatrixXd Image_M,Source_M,Target_M,AfterAffine_M,AfterRadio_M;
GFuncType gfunctype;
int N;//number of Anchor Points
QList<Line*> lineList;
};
- Line.h
```cpp
ifndef LINE_H
define LINE_H
《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
- load Image
- get Anchor points by User Interactive
- Analysis source Point and target Point
- Controlling the affine component A(x) accoring to the number of anchor points,by Equation(3)
- determining the radial component R(x),by Equation(4),Equation(5)
- Apply T(x) to every pixel in this image
- load 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
//WarpingRBF.h
#ifndef WARPINGRBF_H
#define WARPINGRBF_H
#include<opencv2/opencv.hpp>
#include<QList>
#include<Eigen/Eigen>
#include"line.h"
class WarpingRBF
{
public:
enum GFuncType{
Gaussian_Radio_Function,
Thin_Plate_spline,//r^2log(r)
Gaussian_Radial
};
public:
WarpingRBF();
WarpingRBF(const QList<Line*> & lineList,
const int&N);
public:
void SolveRBF();
void SetImage(const cv::Mat &sourceImage);
void SetGFunc(const GFuncType &gfunctype);
protected:
void InitData();
void InitSourceAndTargetMaritrix(const QList<Line*> &list,
Eigen::MatrixXd &Source_M,
Eigen::MatrixXd &Target_M);
void InitImageMatrix(const cv::Mat &sourceImage,
const int&height,
const int &width,
Eigen::MatrixXd &Image_M);
void CalculateAffineMat(const Eigen::MatrixXd &Source_M,
const Eigen::MatrixXd &Target_M,
const int &N,
cv::Mat &Affine_Mat);
void AffineTranslate(const cv::Mat &srcImage,
const cv::Mat &Affine_Mat,
Eigen::MatrixXd &AfterAffine_M);
void RadioTranslate(const Eigen::MatrixXd &Image_M,
const Eigen::MatrixXd &Source_M,
const Eigen::MatrixXd &Target_M,
const GFuncType &gfunctype,
const cv::Mat &Affine_Mat,
const int &N,
const int &height,
const int &width,
Eigen::MatrixXd &AfterRadio_M);
void RBFTranslate(const Eigen::MatrixXd AfterAffine_M,
const Eigen::MatrixXd AfterRadio_M,
Eigen::MatrixXd Image_M);
void ApplyChangeOnImage(cv::Mat &dstImage,const Eigen::MatrixXd Image_M);
double GetEulaNorm(const Eigen::MatrixXd X_M);//(2*1)--(x,y)^T
private:
cv::Mat srcImage,dstImage,Affine_Mat;
int height,width;
Eigen::MatrixXd Image_M,Source_M,Target_M,AfterAffine_M,AfterRadio_M;
GFuncType gfunctype;
int N;//number of Anchor Points
QList<Line*> lineList;
};
- Line.h
```cpp
ifndef 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
!--more-->
以上是关于《Image Warping Using Few Anchor Points and Radial Function》论文实现的主要内容,如果未能解决你的问题,请参考以下文章
《PWC-Net:CNNs for Optical Flow Using Pyramid,Warping,and Cost Volume》论文笔记
图像变换DIBR-3D图像变换(3D Image Warping)matlab源码
DTW (Dynamic Time Warping) 动态时间规整