旋转变换、映射、parallel_for、parallel_for_ 、for的性能比较

opencv英文文档

Geometric Image Transformations

The functions in this section perform various geometrical transformations of 2D images. They do not change the image content but deform the pixel grid and map this deformed grid to the destination image. In fact, to avoid sampling artifacts, the mapping is done in the reverse order, from destination to the source. That is, for each pixel (x, y) of the destination image, the functions compute coordinates of the corresponding “donor” pixel in the source image and copy the pixel value:

The functions in this section perform various geometrical transformations of 2D images. They do not change the image content but deform the pixel grid and map this deformed grid to the destination image. In fact, to avoid sampling artifacts, the mapping is done in the reverse order, from destination to the source. That is, for each pixel (x, y) of the destination image, the functions compute coordinates of the corresponding “donor” pixel in the source image and copy the pixel value: .. math:

\texttt{dst} (x,y)= \texttt{src} (f_x(x,y), f_y(x,y))

In case when you specify the forward mapping \left<g_x, g_y\right>: \texttt{src} \rightarrow \texttt{dst} , the OpenCV functions first compute the corresponding inverse mapping \left<f_x, f_y\right>: \texttt{dst} \rightarrow \texttt{src} and then use the above formula.

convertMaps

Converts image transformation maps from one representation to another.

C++:  void  convertMaps (InputArray  map1, InputArray  map2, OutputArray  dstmap1, OutputArray  dstmap2, int  dstmap1type, bool  nninterpolation=false  )
Python:   cv2. convertMaps (map1, map2, dstmap1type [, dstmap1 [, dstmap2 [, nninterpolation ] ] ] ) → dstmap1, dstmap2
Parameters:
  • map1 – The first input map of type CV_16SC2 , CV_32FC1 , or CV_32FC2 .
  • map2 – The second input map of type CV_16UC1 , CV_32FC1 , or none (empty matrix), respectively.
  • dstmap1 – The first output map that has the type dstmap1type and the same size as src .
  • dstmap2 – The second output map.
  • dstmap1type – Type of the first output map that should be CV_16SC2 , CV_32FC1 , or CV_32FC2 .
  • nninterpolation – Flag indicating whether the fixed-point maps are used for the nearest-neighbor or for a more complex interpolation.

The function converts a pair of maps for remap() from one representation to another. The following options ( (map1.type(), map2.type()) \rightarrow (dstmap1.type(), dstmap2.type()) ) are supported:

  • \texttt{(CV\_32FC1, CV\_32FC1)} \rightarrow \texttt{(CV\_16SC2, CV\_16UC1)} . This is the most frequently used conversion operation, in which the original floating-point maps (see remap() ) are converted to a more compact and much faster fixed-point representation. The first output array contains the rounded coordinates and the second array (created only when nninterpolation=false ) contains indices in the interpolation tables.
  • \texttt{(CV\_32FC2)} \rightarrow \texttt{(CV\_16SC2, CV\_16UC1)} . The same as above but the original maps are stored in one 2-channel matrix.
  • Reverse conversion. Obviously, the reconstructed floating-point maps will not be exactly the same as the originals.
  • 第一个输出是dstmap_1 contains pairs (cvFloor(x), cvFloor(y))
  • 第二个输出dstmap_2 contains indices in a table of interpolation coefficients.
  • 输出一定都是(CV_16SC2,CV_16UC1)
  • remap

    Applies a generic geometrical transformation to an image.

    C++:  void  remap (InputArray  src, OutputArray  dst, InputArray  map1, InputArray  map2, int  interpolation, int  borderMode=BORDER_CONSTANT, const Scalar&  borderValue=Scalar() )
    Python:   cv2. remap (src, map1, map2, interpolation [, dst [, borderMode [, borderValue ] ] ] ) → dst
    C:  void  cvRemap (const CvArr*  src, CvArr*  dst, const CvArr*  mapx, const CvArr*  mapy, int  flags=CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS, CvScalar  fillval=cvScalarAll(0)  )
    Python:   cv. Remap (src, dst, mapx, mapy, flags=CV_INNER_LINEAR+CV_WARP_FILL_OUTLIERS, fillval=(0, 0, 0, 0) ) → None
    Parameters:
    • src – Source image.
    • dst – Destination image. It has the same size as map1 and the same type as src .
    • map1 – The first map of either (x,y) points or just x values having the type CV_16SC2 , CV_32FC1 , or CV_32FC2 . See convertMaps() for details on converting a floating point representation to fixed-point for speed.
    • map2 – The second map of y values having the type CV_16UC1 , CV_32FC1 , or none (empty map if map1 is (x,y) points), respectively.
    • interpolation – Interpolation method (see resize() ). The method INTER_AREA is not supported by this function.
    • 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 remap transforms the source image using the specified map:

    \texttt{dst} (x,y) =  \texttt{src} (map_x(x,y),map_y(x,y))

    where values of pixels with non-integer coordinates are computed using one of available interpolation methods. map_x and map_y can be encoded as separate floating-point maps in map_1 and map_2 respectively, or interleaved floating-point maps of (x,y) in map_1 , or fixed-point maps created by using convertMaps() . The reason you might want to convert from floating to fixed-point representations of a map is that they can yield much faster (~2x) remapping operations. In the converted casemap_1 contains pairs (cvFloor(x), cvFloor(y)) and map_2 contains indices in a table of interpolation coefficients.

    This function cannot operate in-place.


invertAffineTransform

Inverts an affine transformation.

C++:  void  invertAffineTransform (InputArray  M, OutputArray  iM )
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值