I'm trying to detect digits from a digital meter. The problem I'm facing right now is the images have a lo tof noise and even after adding many filters, I'm unable to remove the noises without distorting the digits. This is what I've acheived till now:
img = cv2.imread(image_path)
img = cv2.resize(img , (280 , 70))
gamma = 2.5
# apply gamma correction and show the images
gamma = gamma if gamma > 0 else 0.1
img = adjust_gamma(img, gamma=gamma)
img = applyClahe(img)
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
img = cv2.GaussianBlur(img, (3, 3), 0)
dst = cv2.fastNlMeansDenoising(img,None,3,10,21)
thresh = cv2.adaptiveThreshold(dst,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,\
cv2.THRESH_BINARY,11,2)
kernel = np.ones((1,2), np.uint8)
thresh = cv2.erode(thresh, kernel, iterations=1)
thresh = cv2.fastNlMeansDenoising(thresh,None,30,15,30)
connectivity = 4
thresh = cv2.medianBlur(thresh, 3)
Is there any more aggressive algorithm which can filter out these noises ?
Try to use niBlackThreshold. I'm running this example with result:
Not bad?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.