0

I am applying the threshold value manually

I am trying to extract exact information of credit card.

I attached the sample images.

how can in extract credit card numbers exactly.

Image to analyze

import re

import cStringIO
import urllib

import cv2
import numpy as np
from matplotlib import pyplot as plt
from PIL import Image
from noiselevel import estimate_noise
import pytesseract
oriimage="sh.png"
newimage = cv2.resize(oriimage,(583,327))
newimage = newimage[150:250, 0:600]
  # valid_image = newimage[150:250, 0:600]
cv2.imwrite("moon.tif",newimage)
 # filter=ImageFilter.UnsharpMask(6.0,269,0)
 #  im=Image.open("moon.tif")
 # i=im.filter(filter)
 # i.save("l3.tif")
a=Image.open("moon.tif")
inputt="moon.tif"
img = cv2.imread(inputt,0)

ret1,th1 = cv2.threshold(img,120,254,cv2.THRESH_BINARY)
aberna
  • 5,594
  • 2
  • 28
  • 33

2 Answers2

0

You can use Adaptive Thresholding to binarise the image. Adaptive thresholding automatically determines the threshold value for given part of an image based on its surroundings. One advantage is that you do not have to hardcode the threshold. Another and more important advantage is that it gives a reasonable binarisation even when there is uneven lighting in the image.

ngalstyan
  • 637
  • 6
  • 14
0

i improve the accuracy by resize the cropped image.

cv2.resize(newimage,(583,150)