StupidBeauty
Read times:857Posted at:Tue May 14 19:58:15 2013
- no title specified

转载Cv图像处理

可使用GetPerspectiveTransform计算透视变换矩阵,使用WarpPerspective来真正进行透视变换。

http://www.opencv.org.cn/index.php/Cv%E5%9B%BE%E5%83%8F%E5%A4%84%E7%90%86

亮点:

WarpPerspective

对图像进行透视变换

void cvWarpPerspective( const CvArr* src, CvArr* dst, const CvMat* map_matrix,

int flags=CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS,

CvScalar fillval=cvScalarAll(0) );

src

输入图像.

dst

输出图像.

map_matrix

3×3 变换矩阵

flags

插值方法和以下开关选项的组合:

  • •.CV_WARP_FILL_OUTLIERS - 填充所有缩小图像的象素。如果部分象素落在输入图像的边界外,那么它们的值设定为 fillval.

  • •.CV_WARP_INVERSE_MAP - 指定 matrix 是输出图像到输入图像的反变换,因此可以直接用来做象素插值。否则, 函数从 map_matrix 得到反变换。

fillval

用来填充边界外面的值

函数 cvWarpPerspective 利用下面指定矩阵变换输入图像: dst(x',y') \leftarrow src(x,y)dst(x',y') \leftarrow src(x,y)
  • •.如果没有指定 CV_WARP_INVERSE_MAP , (x',y')^T=map\_matrix \cdot (x,y,1)^T(x',y')^T=map\_matrix \cdot (x,y,1)^T
    ,
    ,
  • •.否则, (x, y)^T=map\_matrix \cdot (x',y',1)^T(x, y)^T=map\_matrix \cdot (x',y',1)^T

要变换稀疏矩阵,使用 cxcore 中的函数 cvTransform 。

[编辑]

WarpPerspectiveQMatrix

用4个对应点计算透视变换矩阵

CvMat* cvWarpPerspectiveQMatrix( const CvPoint2D32f* src,

const CvPoint2D32f* dst,

CvMat* map_matrix );

src

输入图像的四边形的4个点坐标

dst

输出图像的对应四边形的4个点坐标

map_matrix

输出的 3×3 矩阵

函数 cvWarpPerspectiveQMatrix 计算透视变换矩阵,使得:

(tix'i,tiy'i,ti)T=matrix•(xi,yi,1)T

其中 dst(i)=(x'i,y'i), src(i)=(xi,yi), i=0..3.

[编辑]

GetPerspectiveTransform

由四边形的4个点计算透射变换

CvMat* cvGetPerspectiveTransform( const CvPoint2D32f* src, const CvPoint2D32f* dst,

CvMat* map_matrix );

#define cvWarpPerspectiveQMatrix cvGetPerspectiveTransform

src

输入图像的四边形顶点坐标。

dst

输出图像的相应的四边形顶点坐标。

map_matrix

指向3×3输出矩阵的指针。

函数cvGetPerspectiveTransform计算满足以下关系的透射变换矩阵:

(t_ix'_i,t_iy'_i,t_i)^T=map\_matrix\cdot(x_i,y_i,1)^T(t_ix'_i,t_iy'_i,t_i)^T=map\_matrix\cdot(x_i,y_i,1)^T

这里,dst(i) = (x'i,y'i),src(i) = (x i,y i),i = 0..3.

两侧是美景,中间是土匪

Your opinions
Your name:Email:Website url:Opinion content:
Recent comments
2017年4月~2019年4月垃圾短信排行榜Posted at:Thu Sep 26 04:51:48 2024
Qt5.7文档翻译:QWebEngineCookieStore类,QWebEngineCookieStore ClassPosted at:Fri Aug 11 06:50:35 2023盲盒kill -9 18289 Grebe.20230517.211749.552.mp4