python opencv 图像二值化并显示

#!/usr/bin/python
from urllib import *
import cv2
import io

imgStr = urlopen("http://www.btbu.edu.cn/cms/modules/showimage.jsp").read()
fp = io.open('out.jpg', 'wb')
fp.write(imgStr)
fp.close()
image = cv2.imread('out.jpg')
image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
cv2.threshold(image, 140, 255, 0, image)

cv2.namedWindow("Image")
cv2.imshow("Image", image)
cv2.waitKey(0)


你可能感兴趣的:(python)