12345678910111213141516 |
- import cv2
- def test22():
- src = cv2.imread("test1.jpg")
- # 灰度图片转换
- gray = cv2.cvtColor(src, cv2.COLOR_BGR2GRAY)
- # 二进制阈值化处理
- r, b = cv2.threshold(gray, 155, 255, cv2.THRESH_BINARY)
- # 显示图像
- cv2.imshow("src", src)
- cv2.imshow("result", b)
- print(r)
- if cv2.waitKey(0) == 27:
- cv2.destroyAllWindows()
- test22()
|