日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

發布時間:2025/3/20 编程问答 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 opencv cv2.flip()函数(图像翻转、镜像、颠倒)(沿x轴翻转0、沿y轴翻转【正值】、同时沿x轴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 : 20200119_測試圖片鏡像.py @Time : 2020/1/19 16:27 @Author : Dontla @Email : sxana@qq.com @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轴翻转-【负值】)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。