-4

Imagine that I want to improve a picture of a thermal impression paper, I am usin JAVA CV but my image gets all black.

I put here an example:

enter image description here

Here is the code:

CvScalar min = cvScalar(100, 100, 130, 0);//BGR-A
CvScalar max= cvScalar(140, 110, 255, 0);//BGR-A
cvInRangeS(image, min, max, imgThreshold);

UPDATE:

I am trying to convert the image to grayscale without success.

IplImage image = cvLoadImage("example6.jpg");

IplImage imgThreshold = cvCreateImage(cvGetSize(image), 8, 1);
 cvInRangeS(image, cvScalar(hueLowerR, 100, 100, 0), cvScalar(hueUpperR, 255, 255, 0), imgThreshold);
   cvSaveImage("test1.jpg", imgThreshold););
John
  • 1,697
  • 4
  • 27
  • 53
  • 2
    Can you elaborate what you want to do exactly? – Jeru Luke Mar 22 '17 at 15:41
  • Thank you. I want to extract the info from the ticket. Imagine that I do have a kfc ticket and I want to extract the fiscal number – John Mar 22 '17 at 15:51
  • @John Let me ask it in this way - you know that OCR isn't on the level of human vision yet. What makes you think that what you want is possible with the state of the art of current technologies? – sashoalm Mar 22 '17 at 15:55
  • @ sashoalm I already can parse the image, but I am with some issues at some words and numbers, so I am trying to improve the image before OCR. – John Mar 22 '17 at 16:51
  • Have you tried anything to improve OCR detection? – Jeru Luke Mar 22 '17 at 17:56
  • " ...I am with some issues at some words and numbers... " Tell us about your issues (these issues). It may be, it's not the image that needs improvement but the algorithm that works on it. – NoDataDumpNoContribution Mar 23 '17 at 12:58

1 Answers1

0

If you want to improve the accuracy of OCR detection, you must improve the quality of the image you are feeding.

  1. You can try Contrast Limited Adaptive Histogram Equalization (I have done the following using python):

enter image description here

  1. You could have applied binary threshold on the gray scale image:

enter image description here

You might be wondering how I obtained the suitable threshold value... Well have a look at THIS ANSWER I posted a while ago.

Community
  • 1
  • 1
Jeru Luke
  • 20,118
  • 13
  • 80
  • 87
  • I am trying to convert the image to grayscale without success. \n IplImage image = cvLoadImage("example6.jpg"); IplImage imgThreshold = cvCreateImage(cvGetSize(image), 8, 1); cvInRangeS(image, cvScalar(hueLowerR, 100, 100, 0), cvScalar(hueUpperR, 255, 255, 0), imgThreshold); cvSaveImage("test1.jpg", imgThreshold);); – John Mar 23 '17 at 14:23
  • The result image is all black – John Mar 23 '17 at 15:58
  • Did you calculate the median as given in the answer I posted? – Jeru Luke Mar 23 '17 at 16:24