大佬教程收集整理的这篇文章主要介绍了字符识别改进的降噪?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用 KNN 来检测字符,但是,它对背景噪声很敏感。该图像基本上是我正在使用的图像,并且我开发了一个迷你脚本来尝试获得最佳阈值图像。有没有人有任何建议/改变以获得更好的结果?使 X 更易于查看。 (附加版本的当前输出和输入是什么)
import cv2
import numpy as np
image = cv2.imread("resize.png")
img = image
img = cv2.blur(img,(5,5))
imgGray = cv2.cvtcolor(img,cv2.color_BGR2GRAY) # get grayscale image
imgBlurred = cv2.GaussianBlur(imgGray,(11,11),5) # blur
# cv2.imshow("test",imgBlurred)
imgThresh = cv2.adaptiveThreshold(imgBlurred,# input image
255,# make pixels that pass the threshold full white
cv2.ADAPTIVE_THRESH_GAUSSIAN_C,# use gaussian rather than mean,seems to give better results
cv2.THRESH_BINARY_INV,# invert so foreground will be white,BACkground will be black
13,# size of a pixel neighborhood used to calculate threshold value
2) # constant subtracted from the mean or weighted mean
imgThreshcopy = imgThresh.copy() # make a copy of the thresh image,this in necessary b/c findContours modifIEs the image
kernel = np.ones((3,3),np.uint8)
kernel2 = np.ones((7,7),np.uint8)
kernel3 = np.ones((1,1),np.uint8)
imgThreshcopy = cv2.morphologyEx(imgThreshcopy,cv2.MORPH_OPEN,kernel)
imgThreshcopy = cv2.morphologyEx(imgThreshcopy,cv2.MORPH_CLOSE,kernel2)
imgThreshcopy = cv2.dilate(imgThreshcopy,kernel3,iterations=150)
res = imgThreshcopy
cv2.imwrite("test.jpg",res)
cv2.imshow("image",res)
cv2.waitKey(0)
output input
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的字符识别改进的降噪?全部内容,希望文章能够帮你解决字符识别改进的降噪?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。