Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Why my image is in bad quality ? Date: Thu, 17 Dec 2015 03:41:07 +1100 Lines: 28 Message-ID: References: <424a0169-fe5b-4650-9673-46d265290c30@googlegroups.com> <94c84373-db80-43cd-a705-a89e695e140a@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de Lx5p7/07dwXQi711NtrZEgVP4ZwhhlB/4R9TvYJC+VDA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '16,': 0.03; 'below)': 0.07; 'omit': 0.07; 'scaling': 0.07; 'wednesday,': 0.07; 'cc:addr :python-list': 0.09; 'pil': 0.09; 'subject:Why': 0.09; 'argument': 0.15; 'file,': 0.15; 'thu,': 0.15; 'cleanly': 0.16; 'disabled.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'inclined': 0.16; 'left,': 0.16; 'pulling': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:image': 0.16; 'wrote:': 0.16; 'result,': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; '(see': 0.20; 'work,': 0.21; 'parse': 0.22; 'recognize': 0.22; 'simpler': 0.22; 'am,': 0.23; 'dec': 0.23; 'second': 0.24; 'tried': 0.24; 'import': 0.24; 'header:In- Reply-To:1': 0.24; 'chris': 0.26; 'scale': 0.27; 'subject: ?': 0.27; 'message-id:@mail.gmail.com': 0.27; 'bad.': 0.29; "i'm": 0.30; 'code': 0.30; 'another': 0.32; "can't": 0.32; 'december': 0.32; 'maybe': 0.33; 'getting': 0.33; 'problem': 0.33; 'wrap': 0.33; 'editor': 0.34; 'file': 0.34; 'received:google.com': 0.35; 'on,': 0.35; 'text': 0.35; 'something': 0.35; 'but': 0.36; 'skip:i 20': 0.36; 'received:209.85': 0.36; 'possible': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'skip:p 20': 0.38; 'sure': 0.39; "didn't": 0.39; 'your': 0.60; "you'll": 0.61; 'more': 0.63; 'you.': 0.64; 'quality': 0.72; 'chrisa': 0.84; 'recognition': 0.84; 'subject:quality': 0.84; 'to:none': 0.91; 'different.': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=MQDNYpQG0g/Rr8DTvYPDE6qJRE3Gzx4VOcQ8dFr7v34=; b=AZ8vh/zAdh3KNFp27K2aopyhw34aNmsB7F1KYSisKonTT0779Yi1nij7/JfowFDM6p DyaZz9cTYVTOPdWsYJiqokKc6taAnjomM2luhFMExwygT/jj04xcTcL7ZGF4E9evEuwr L4ulP/ilkE347+hDg0e7LAQFz1NjX2wy2PHjb3dluC/ytT5LqTVcIvfNTdibA8xjvZ4N nGFNMMXTQlAKeH1K6qCzyNQwASTrMgfQI6S0J07E7U0TvlhMJVAglyNXnecemWGGyG7P C9WioibM4FBrv8qT0SAv9Tjaj/Rv8tsEyMpIerf9DDjP4bspnCPVGbhggchadxbF++rG b6zw== X-Received: by 10.107.163.146 with SMTP id m140mr26179618ioe.19.1450284067213; Wed, 16 Dec 2015 08:41:07 -0800 (PST) In-Reply-To: <94c84373-db80-43cd-a705-a89e695e140a@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:100520 On Thu, Dec 17, 2015 at 3:33 AM, wrote: > On Wednesday, December 16, 2015 at 6:33:56 PM UTC+4, Chris Angelico wrote: >> On Thu, Dec 17, 2015 at 1:21 AM, wrote: >> > I tried also another code (see below) and without scaling by 20 quality of recognition was very bad. >> > >> > from pytesseract import image_to_string >> > from PIL import Image >> > >> > im = Image.open("screen.png") >> > print(im) >> > im = im.resize((214*20,26*20), Image.ANTIALIAS) >> > print(image_to_string(im)) >> >> If you need to scale by 20x20 to get the text recognition to work, I >> would recommend using something other than an anti-alias filter. Omit >> the second argument to use a simpler algorithm; you'll get a blocky >> result, which might parse more cleanly for you. >> >> ChrisA > > It didn't help to recognize words, the main problem is that image is inclined to the left, like backslash. Interesting. I'm not sure what exactly is going on, as I can't see your image or the result, but is it possible that the text is getting wrapped? Try printing it to a file, then pulling the file up in a text editor with word wrap disabled. Maybe it'll look different. ChrisA