how to extract text from very small image using python opencv

asked 2018-02-07 08:17:15 -0600

python openCV gravatar image

updated 2018-02-08 05:17:58 -0600

Hi All,

I'm new bee for python openCV, can you help me to extract text from small image.Can you check my uploaded image.

i have tried Below code, But i'm not getting expected result.

import sys
import cv2 
import numpy as np
import pytesseract

img = Image.open("TestImge.PNG")  
pytesseract.pytesseract.tesseract_cmd = 'F:\\Python27\\Tesseract-OCR\\tesseract'
print(pytesseract.image_to_string(img))

my Expected output Is

Show the following Claims

But i'm getting

Sltowvcololovangccrno

my image

alt text

my second image

alt text

Help me to done.

Thanks,

edit retag flag offensive close merge delete

Comments

1

You should try first with synthetic image : write "Show the following Claims" using a small font and use png format to save your image. Don't use jpg format

LBerger gravatar imageLBerger ( 2018-02-07 08:33:27 -0600 )edit

To ask a better formatted question in the future, please format the code and output as preformatted text (the icon is the 0 1 0 1 0 1 one). I've just done this for you. This is done with three spaces at beginning of line. Thanks for actually including code as text rather than a screenshot!

opalmirror gravatar imageopalmirror ( 2018-02-07 13:38:20 -0600 )edit

@LBerger,Thanks for response,i will try and let you know,

python openCV gravatar imagepython openCV ( 2018-02-07 20:36:33 -0600 )edit

@opalmirror,Thanks for your help.

python openCV gravatar imagepython openCV ( 2018-02-07 20:38:40 -0600 )edit

@LBerger,still i'm getting same problem,is their any alternate way.

python openCV gravatar imagepython openCV ( 2018-02-08 01:04:21 -0600 )edit

can you edit your message and insert synthetic image in png ?

LBerger gravatar imageLBerger ( 2018-02-08 01:35:47 -0600 )edit

@LBerger,Sorry for the delay,please check my edited post.

python openCV gravatar imagepython openCV ( 2018-02-08 05:19:29 -0600 )edit

Upper image is "my image" (zoom x4) : it's a color image. lower image is image in gray (cvtColor) : I don't know how to extract character in your image.

image description

LBerger gravatar imageLBerger ( 2018-02-08 05:56:42 -0600 )edit

@LBerger,my upper image is sipping from existing windows forms ,but my second image is created synthetic image .That's why different background colours.

python openCV gravatar imagepython openCV ( 2018-02-08 06:27:12 -0600 )edit

@LBerger,Removing background colour and extracting only text is also more helpfull to me.

python openCV gravatar imagepython openCV ( 2018-02-08 06:37:03 -0600 )edit