How to prepare image to recognize by tesseract OCR

对着背影说爱祢 提交于 2019-12-08 04:38:56

问题


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


回答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:

Hope this helps.



来源:https://stackoverflow.com/questions/47450223/how-to-prepare-image-to-recognize-by-tesseract-ocr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!