【OpenCv 学习ing】warpPerspective用法

文档说明:


Applies a perspective transformation to an image.

C++:  void  warpPerspective (InputArray  src, OutputArray  dst, InputArray  M, Size  dsize, int  flags=INTER_LINEAR, int borderMode=BORDER_CONSTANT, const Scalar&  borderValue=Scalar() )
Python:   cv2. warpPerspective (src, M, dsize [, dst [, flags [, borderMode [, borderValue ] ] ] ] ) → dst
C:  void  cvWarpPerspective (const CvArr*  src, CvArr*  dst, const CvMat*  mapMatrix, int  flags=CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS, CvScalar  fillval=cvScalarAll(0)  )
Python:   cv. WarpPerspective (src, dst, mapMatrix, flags=CV_INNER_LINEAR+CV_WARP_FILL_OUTLIERS, fillval=(0, 0, 0, 0) ) → None
Parameters:
  • src – Source image.
  • dst – Destination image that has the size dsize and the same type as src .
  • M – 3\times 3 transformation matrix.
  • dsize – Size of the destination image.
  • flags – Combination of interpolation methods (see resize() ) and the optional flag WARP_INVERSE_MAP that means that Mis the inverse transformation ( \texttt{dst}\rightarrow\texttt{src} ).
  • borderMode – Pixel extrapolation method (see borderInterpolate() ). When borderMode=BORDER_TRANSPARENT , it means that the pixels in the destination image that corresponds to the “outliers” in the source image are not modified by the function.
  • borderValue – Value used in case of a constant border. By default, it is 0.

The function warpPerspective transforms the source image using the specified matrix:

\texttt{dst} (x,y) =  \texttt{src} \left ( \frac{M_{11} x + M_{12} y + M_{13}}{M_{31} x + M_{32} y + M_{33}} ,     \frac{M_{21} x + M_{22} y + M_{23}}{M_{31} x + M_{32} y + M_{33}} \right )

when the flag WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with invert() and then put in the formula above instead of M . The function cannot operate in-place.



===========================译:=================================================

功能: 对图像进行透视变换。

参数:

src 输入图像

dst 目标图像

map_matrix 3*3变换矩阵

flags   CV_INTER_LINEAR 填充所有目标图像的像素,如果部分图像落在边界外,那么它们的值将被设定为fillval

        CV_WARP_FILL_OUTLIERS  指定map_matrix是目标图像的输入图像的反变换

fillval 用于填充边界之外的像素的值




猜你喜欢

转载自blog.csdn.net/Just_Yu/article/details/40509831