点击上方
“
小白学视觉
”,选择加"
星标
"或“
置顶
”
重磅干货,第一时间送达
1.cv2.imread() — 用于读取图像文件并将其存储为 NumPy 数组。
import cv2
# Read an image file and store it as a NumPy array
image = cv2.imread('image.jpg')
-
cv2.imshow() — 用于在屏幕上显示图像。
import cv2
# Read an image file and store it as a NumPy array
image = cv2.imread('image.jpg')
# Display the image on the screen
cv2.imshow('Image', image)
# Wait for the user to press any key before closing the window
cv2.waitKey(0)
# Destroy the window
cv2.destroyAllWindows()
-
cv2.cvtColor() — 用于将图像从一种颜色空间转换为另一种颜色空间。
import cv2
# Read an image file and store it as a NumPy array
image = cv2.imread('image.jpg')
# Convert the image from BGR to grayscale
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
-
import cv2
# Read an image file and store it as a NumPy array
image = cv2.imread('image.jpg')
# Resize the image to half its original size
resized_image = cv2.resize(image, (int(image.shape[1]/2), int(image.shape[0]/2)))
-
cv2.GaussianBlur() — 用于使用高斯内核模糊图像。
import cv2
# Read an image file and store it as a NumPy array
image = cv2.imread('image.jpg')
# Blur the image using a Gaussian kernel with a kernel size of 5x5
blurred_image = cv2.GaussianBlur(image, (5,5), 0)
-
cv2.Canny() — 用于使用 Canny 边缘检测算法检测图像中的边缘。
import cv2
# Read an image file and store it as a NumPy array
image = cv2.imread('image.jpg')
# Detect edges in the image using the Canny edge detection algorithm
edges = cv2.Canny(image, 100, 200)
-
cv2.threshold() — 用于对图像应用阈值处理,将其转换为二值图像。
import cv2
# Read an image file and store it as a NumPy array
image = cv2.imread('image.jpg')
# Apply thresholding to the image, turning it into a binary image
_, thresholded_image = cv2.threshold(image, 127, 255, cv2.THRESH_BINARY
下载1:OpenCV-Contrib扩展模块中文版教程
在「小白学视觉」公众号后台回复:扩展模块中文教程,即可下载全网第一份OpenCV扩展模块教程中文版,涵盖扩展模块安装、SFM算法、立体视觉、目标跟踪、生物视觉、超分辨率处理等二十多章内容。在「小白学视觉」公众号后台回复:Python视觉实战项目,即可下载包括图像分割、口罩检测、车道线检测、车辆计数、添加眼线、车牌识别、字符识别、情绪检测、文本内容提取、面部识别等31个视觉实战项目,助力快速学校计算机视觉。