mi-task/test/plugins/qrcode/threshold.py

13 lines
286 B
Python
Raw Permalink Normal View History

import cv2
# 读取图像(灰度)
image = cv2.imread('qrcode-A1.jpg', 0)
# 设置阈值
threshold_value = 100
# 进行二值化处理
_, binary_image = cv2.threshold(image, threshold_value, 255, cv2.THRESH_BINARY)
# 保存结果
cv2.imwrite('binary_qrcode-A1.jpg', binary_image)