6

I am trying to create an app that can read text from image. But i'm having problem in clearing background. I want results like :

Input Image 1 : enter image description here

Output Image 1 : enter image description here

This is the code I have tried:

cvtColor(org, tmp, CV_BGR2GRAY); 
normalize(tmp, tmp, 0, 255, NORM_MINMAX); 
threshold(tmp, dst, 0, 255, CV_THRESH_OTSU);
Jeru Luke
  • 20,118
  • 13
  • 80
  • 87
patrick
  • 357
  • 6
  • 20

1 Answers1

0

The lines that interest you are oriented at either 0 or 90 degrees, with a small variance in either direction. Lines in the background patterns are slanted. You can identify the lines with the canny algorithm, then check orientation. You'll be left with some gaps where the vertical and horizontal lines meet, depending on the font. Then return to the original image and use a watershed based on color, or use connected components, or whatever to avoid losing those connecting regions.

Nick M
  • 1
  • Actually it is not necessary that background is always filled with lines. It can be anything. I want some thing generic. – patrick Mar 26 '15 at 09:50
  • @HemantKumar You say you want something generic. How representative is your example image? Are the digits always going to have higher intensity than the rest of the image? You should be clear as to what you expect. – beaker Apr 03 '15 at 16:30
  • @beaker No, It's not necessary. Digits may have lower intensity. – patrick Apr 06 '15 at 06:08