How i could make better this image for tesseract recognition?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

How i could make better this image for tesseract recognition?

Post by diegomage »

Image


convert dIsuln.png -unsharp 0x10 A_blur_unsharp0.jpg
convert A_blur_unsharp0.jpg -negate -lat 10x10+10% -negate jx8MPc9_kuw2_lat10-0.png
convert jx8MPc9_kuw2_lat10-0.png -fill white -opaque "#00ff00" balloon_white0.gif
tesseract -psm 10 balloon_white0.gif scanned2.txt


I have a simple image but I dont know How i could make better
Image


this command output an E instead 2
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How i could make better this image for tesseract recognition?

Post by fmw42 »

The image is too small and too even colored to do OCR. There are limits to what you can do by way of character size in the image and how thick it is. Is it a 2 or a Z? How will OCR know, I a person cannot tell the difference. I doubt you can do anything to improve this to get the OCR to read it accurately. But I do not know that much about OCR. Perhaps someone else can advise
diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

Re: How i could make better this image for tesseract recognition?

Post by diegomage »

But there is a way to remove that little point
diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

Re: How i could make better this image for tesseract recognition?

Post by diegomage »

The small point on the upper left margin
diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

Re: How i could make better this image for tesseract recognition?

Post by diegomage »

for output this

Image
diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

Re: How i could make better this image for tesseract recognition?

Post by diegomage »

My command works when there are no such small points that interferes in the image
diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

Re: How i could make better this image for tesseract recognition?

Post by diegomage »

I see one of your command for filter blob but I dont know how use this
convert balloon_white0.gif -define connected-components:area-threshold=40 -connected-components 4 -threshold 0 jx8MPc9_kuw2_lat10_cc30.png

how I could use this Please help
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How i could make better this image for tesseract recognition?

Post by fmw42 »

try

Code: Select all

convert 1FY60.png -channel red -separate +channel -threshold 70% result.png
diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

Re: How i could make better this image for tesseract recognition?

Post by diegomage »

thanks ; but not works how expected however this command works better ;
convert balloon_white0.gif -colorspace gray -colors 2 +dither -type bilevel imageout.tif
convert imageout.tif -define connected-components:area-threshold=77 -connected-components -4 -auto-level hh
Last edited by diegomage on 2017-03-16T19:12:43-07:00, edited 1 time in total.
diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

Re: How i could make better this image for tesseract recognition?

Post by diegomage »

but output a image with another colors Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How i could make better this image for tesseract recognition?

Post by fmw42 »

Each image will likely be different and require different approaches. I do not know one universal solution.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How i could make better this image for tesseract recognition?

Post by snibgo »

Input: 1FY60.png
Image

This image has an object with a background that extends to the edges of the image. So we can remove the background by making transparent all pixels that are within a certain fuzz percentage of any edge pixel. For this image, 6% works fine.

Windows BAT syntax.

Code: Select all

call %PICTBAT%edgeColsTrans 1FY60.png 1fy_x1.png . 6
1fy_x1.png:
Image

Code: Select all

%IM%convert ^
  1fy_x1.png ^
  -background White -layers Flatten ^
  -fill Black +opaque White ^
  -resize 300%% ^
  1fy_x2.png
1fy_x2.png:
Image

Code: Select all

tesseract 1fy_x2.png 1fy_x2 -psm 10
This gives the expected result, "2".
snibgo's IM pages: im.snibgo.com
diegomage
Posts: 205
Joined: 2017-03-08T10:12:28-07:00
Authentication code: 1151

Re: How i could make better this image for tesseract recognition?

Post by diegomage »

very thank you this help me so much
Post Reply