1

I use Tesseract OCR to to extract meter reading... tesseract needs to recognize right white background and black numbers.. I tried to threshold image

src := cvLoadImage(filename,CV_LOAD_IMAGE_GRAYSCALE);


dst := cvCreateImage(cvGetSize(src), IPL_DEPTH_8U, 1);


cvThreshold(src, dst, 50, 250, CV_THRESH_BINARY);

but i didn't get the right result.. what should I do? I use deplhi6 with Delphi-OpenCV https://github.com/Laex/Delphi-OpenCV

 image to convert

Zub
  • 808
  • 3
  • 12
  • 23
NMMA
  • 173
  • 1
  • 2
  • 13
  • please invest some time on learning the very basics of image processing. beside that a global threshold won't give you good results for this image your threshold value of 50 doesn't make any sense at all. – Piglet Nov 23 '17 at 08:17
  • Have you tried this answer ? https://stackoverflow.com/questions/9480013/image-processing-to-improve-tesseract-ocr-accuracy – Marc Guillot Nov 23 '17 at 14:32

1 Answers1

1

You can treat this image as follows:

  for jy:= 0 to bm.Height do
   for ix := 0 to bm.Width do
    begin
      cor:=bm.Canvas.Pixels[ix,jy];

      R:=GetRValue(Cor);
      G:=GetGValue(Cor);
      B:=GetBValue(Cor);

      if g>38 then
        bm.Canvas.Pixels[ix,jy]:=clWhite
      else
        bm.Canvas.Pixels[ix,jy]:=clBlack;
    end;
As an output I got the following image: enter image description here

Hope this helps.

Mylon
  • 115
  • 1
  • 2
  • 8