2 Star 7 Fork 1

cbwang505/IITG-Captcha-Solver-OpenCV-TensorFlow

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
th.py 1.39 KB
一键复制 编辑 原始数据 按行查看 历史
cbwang505 提交于 2017-03-03 21:01 +08:00 . 2017030306
import cv2
import numpy as np
import urllib
from matplotlib import pyplot as plt
# img9 = cv2.imread('test/c1.png', 0)
img5 = cv2.imread('test/c1.png')
GrayImage = cv2.cvtColor(img5, cv2.COLOR_BGR2GRAY)
tmp = cv2.medianBlur(GrayImage, 1)
# ret2, zh = cv2.threshold(GrayImage, 170, 255, cv2.THRESH_BINARY_INV)
ret, img = cv2.threshold(tmp, 170, 255, cv2.THRESH_BINARY_INV)
kernel = np.ones((2, 2), np.uint8)
img = cv2.dilate(img, kernel, iterations=1)
img = cv2.erode(img, kernel, iterations=1)
img = cv2.dilate(img, kernel, iterations=1)
img = cv2.erode(img, kernel, iterations=1)
img = cv2.medianBlur(img, 1)
img = cv2.dilate(img, kernel, iterations=1)
# medianBlur for removing salt and pepper noise
ret, img = cv2.threshold(img, 127, 255, cv2.THRESH_BINARY_INV)
ret, thresh1 = cv2.threshold(GrayImage, 255, 127, cv2.THRESH_BINARY)
ret, thresh2 = cv2.threshold(GrayImage, 170, 255, cv2.THRESH_BINARY_INV)
ret, thresh3 = cv2.threshold(GrayImage, 127, 255, cv2.THRESH_TRUNC)
ret, thresh4 = cv2.threshold(GrayImage, 170, 0, cv2.THRESH_TOZERO)
ret, thresh5 = cv2.threshold(GrayImage, 170, 255, cv2.THRESH_TOZERO_INV)
titles = ['Gray Image', 'BINARY', 'BINARY_INV', 'TRUNC', 'TOZERO', 'TOZERO_INV']
images = [GrayImage, thresh1, thresh2, thresh3, thresh4, thresh5]
for i in range(6):
plt.subplot(2, 3, i + 1), plt.imshow(images[i], 'gray')
plt.title(titles[i])
plt.xticks([]), plt.yticks([])
plt.show()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/cbwang505/IITG-Captcha-Solver-OpenCV-TensorFlow.git
git@gitee.com:cbwang505/IITG-Captcha-Solver-OpenCV-TensorFlow.git
cbwang505
IITG-Captcha-Solver-OpenCV-TensorFlow
IITG-Captcha-Solver-OpenCV-TensorFlow
master

搜索帮助