2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > opencv cv2.flip()函数(图像翻转 镜像 颠倒)(沿x轴翻转0 沿y轴翻转【正值】

opencv cv2.flip()函数(图像翻转 镜像 颠倒)(沿x轴翻转0 沿y轴翻转【正值】

时间:2023-06-03 16:35:27

相关推荐

opencv cv2.flip()函数(图像翻转 镜像 颠倒)(沿x轴翻转0 沿y轴翻转【正值】

def flip(src, flipCode, dst=None): # real signature unknown; restored from __doc__"""flip(src, flipCode[, dst]) -> dst. @brief Flips a 2D array around vertical, horizontal, or both axes.围绕垂直轴,水平轴或两个轴翻转2D数组。. . The function cv::flip flips the array in one of three different ways (row. and column indices are 0-based):函数cv :: flip以三种不同的方式之一翻转数组(行和列索引均基于0):. \f[\texttt{dst} _{ij} =. \left\{. \begin{array}{l l}. \texttt{src} _{\texttt{src.rows}-i-1,j} & if\; \texttt{flipCode} = 0 \\. \texttt{src} _{i, \texttt{src.cols} -j-1} & if\; \texttt{flipCode} > 0 \\. \texttt{src} _{ \texttt{src.rows} -i-1, \texttt{src.cols} -j-1} & if\; \texttt{flipCode} < 0 \\. \end{array}. \right.\f]. The example scenarios of using the function are the following:以下是使用该函数的示例方案:. * Vertical flipping of the image (flipCode == 0) to switch between. top-left and bottom-left image origin. This is a typical operation. in video processing on Microsoft Windows\* OS.图像的垂直翻转(flipCode == 0)以在左上和左下图像原点之间切换。 这是Microsoft Windows \ * OS上视频处理中的典型操作。. * Horizontal flipping of the image with the subsequent horizontal. shift and absolute difference calculation to check for a. vertical-axis symmetry (flipCode \> 0).图像的水平翻转以及随后的水平移位和绝对差计算,以检查垂直轴对称性(flipCode \> 0)。. * Simultaneous horizontal and vertical flipping of the image with. the subsequent shift and absolute difference calculation to check. for a central symmetry (flipCode \< 0).同时进行图像的水平和垂直翻转,以及随后的偏移和绝对差计算,以检查中心对称性(flipCode \ <0)。. * Reversing the order of point arrays (flipCode \> 0 or. flipCode == 0).反转点数组的顺序(flipCode \> 0或flipCode == 0)。. @param src input array.. @param dst output array of the same size and type as src.. @param flipCode a flag to specify how to flip the array; 0 means. flipping around the x-axis and positive value (for example, 1) means. flipping around y-axis. Negative value (for example, -1) means flipping. around both axes.用于指定如何翻转数组的标志; 0表示绕x轴翻转,正值(例如1)表示绕y轴翻转。 负值(例如-1)表示围绕两个轴翻转。. @sa transpose , repeat , completeSymm"""pass

公式1:

示例代码:

# -*- coding: utf-8 -*-"""@File : 0119_测试图片镜像.py@Time : /1/19 16:27@Author : Dontla@Email : sxana@@Software: PyCharm"""import cv2# 读取图像img = cv2.imread('girl-3421489_1920.jpg')# print(img.shape) # (1280, 1920, 3)# 沿x轴翻转cv2.imshow('win1', cv2.flip(img, 0))# 沿y轴翻转cv2.imshow('win2', cv2.flip(img, 1))# 沿x轴y轴翻转cv2.imshow('win3', cv2.flip(img, -1))cv2.waitKey(0)

结果:

参考文章:opencv3+python3完成图片镜像实现

opencv cv2.flip()函数(图像翻转 镜像 颠倒)(沿x轴翻转0 沿y轴翻转【正值】 同时沿x轴y轴翻转-【负值】)

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。