OpenCV-Python是旨在解決計算機視覺問題的Python綁定庫。cv2.imshow()
方法用於在窗口中顯示圖像。窗口自動適合圖像尺寸。
用法: cv2.imshow(window_name, image)
參數:
window_name:一個字符串,代表要在其中顯示圖像的窗口的名稱。
image:它是要顯示的圖像。
返回值:它不會返回任何內容。
用於以下所有示例的圖像:
示例1:
# Python program to explain cv2.imshow() method
# importing cv2
import cv2
# path
path = r'C:\Users\Rajnish\Desktop\geeksforgeeks.png'
# Reading an image in default mode
image = cv2.imread(path)
# Window name in which image is displayed
window_name = 'image'
# Using cv2.imshow() method
# Displaying the image
cv2.imshow(window_name, image)
輸出:
示例2:
# Python program to explain cv2.imshow() method
# importing cv2
import cv2
# path
path = r'C:\Users\Rajnish\Desktop\geeksforgeeks.png'
# Reading an image in grayscale mode
image = cv2.imread(path, 0)
# Window name in which image is displayed
window_name = 'image'
# Using cv2.imshow() method
# Displaying the image
cv2.imshow(window_name, image)
輸出:
相關用法
- Python OpenCV cv2.imwrite()用法及代碼示例
- Python OpenCV cv2.ellipse()用法及代碼示例
- Python OpenCV cv2.putText()用法及代碼示例
- Python OpenCV cv2.blur()用法及代碼示例
- Python OpenCV cv2.rectangle()用法及代碼示例
- Python OpenCV cv2.circle()用法及代碼示例
- Python OpenCV cv2.line()用法及代碼示例
- Python OpenCV cv2.erode()用法及代碼示例
- Python OpenCV cv2.cvtColor()用法及代碼示例
- Python OpenCV cv2.copyMakeBorder()用法及代碼示例
- Python OpenCV cv2.arrowedLine()用法及代碼示例
- Python OpenCV cv2.imread()用法及代碼示例
注:本文由純淨天空篩選整理自Rajnis09大神的英文原創作品 Python OpenCV | cv2.imshow() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。