python-imaging-library

Increase Accuracy of text recognition through pytesseract & PIL

时光怂恿深爱的人放手 提交于 2021-02-05 20:30:33
问题 So I am trying to extract text from image. And as the quality and size of image is not good, it is giving inaccurate results. I tried few enhancements and other things with PIL but that is only worsening the quality of image. Can someone suggest some enhancement in image to get better results. Few Examples of images: 回答1: In the provided example of image the text is visually of quite good quality, so the question is how it comes that OCR gives inaccurate results? To illustrate the conclusions

Advanced cropping with Python Imaging Library

血红的双手。 提交于 2021-02-05 11:21:36
问题 I have an A4 png image with some text in it, it's transparent, my question is, how can I crop the image to only have the text, I am aware of cropping in PIL, but if I set it to fixed values, it will not be able to crop another image that has that text in another place. So, how can I do it so it finds where the text, sticker, or any other thing is placed on that big and empty image, and crop it so the thing fits perfectly? Thanks in advance! 回答1: You can do this by extracting the alpha channel

tkinter doesn't open image via function

自作多情 提交于 2021-02-05 10:50:50
问题 Tkinter doesn't open the image. We can ask the opening incorrectly, we need help. I need it to open the image through the menu. be sure to use pil, as the image can be anything. There are no errors in the syntax. Thank you = ) from tkinter import Tk, Frame, Menu, Canvas, PhotoImage import easygui from PIL import Image, ImageFilter, ImageTk def input_file(): a = easygui.fileopenbox(filetypes=["*.jpg"]) original = Image.open(a) original = original.resize((799, 799), Image.ANTIALIAS) photoimg =

'Image' object has no attribute 'read'

江枫思渺然 提交于 2021-02-05 07:40:58
问题 I want to use the images stored in a dictionary, to convert it to a GIF. The images in the dictionary is like this type: people={ 1: <PIL.Image.Image image mode=RGBA size=16x16 at 0x10962C510>, 2: <PIL.Image.Image image mode=RGBA size=16x16 at 0x1098D7F90>, 3: <PIL.Image.Image image mode=RGBA size=16x16 at 0x1098D7F50>} I think is a Pillow image. But why do I always get this error: 'Image' object has no attribute 'read' What does it mean? The full error: File "/***view.py", line 266, in

Error Opening PGM file with PIL and SKIMAGE

给你一囗甜甜゛ 提交于 2021-02-05 07:10:33
问题 I have following Image file: Image I used PIL and Skimage to open it but I get following errors First with PIL (tried with and without trucate option): Code: from PIL import Image, ImageFile ImageFile.LOAD_TRUNCATED_IMAGES = True img = Image.open("image_output.pgm") Erorr: OSError: cannot identify image file 'image_output.pgm' And with Skimage: Code: from skimage import io img = io.imread("image_output.pgm") Error: OSError: cannot identify image file <_io.BufferedReader name='image_output.pgm

Error Opening PGM file with PIL and SKIMAGE

家住魔仙堡 提交于 2021-02-05 07:02:46
问题 I have following Image file: Image I used PIL and Skimage to open it but I get following errors First with PIL (tried with and without trucate option): Code: from PIL import Image, ImageFile ImageFile.LOAD_TRUNCATED_IMAGES = True img = Image.open("image_output.pgm") Erorr: OSError: cannot identify image file 'image_output.pgm' And with Skimage: Code: from skimage import io img = io.imread("image_output.pgm") Error: OSError: cannot identify image file <_io.BufferedReader name='image_output.pgm

Cannot import name '_imaging' from 'PIL'

给你一囗甜甜゛ 提交于 2021-02-05 06:12:18
问题 I'm trying to run this code: import pyautogui import time from PIL import _imaging from PIL import Image import pytesseract time.sleep(5) captura = pyautogui.screenshot() codigo = captura.crop((872, 292, 983, 337)) codigo.save(r'C:\autobot_wwe_supercard\imagenes\codigo.png') time.sleep(2) pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract' print(pytesseract.image_to_string(r'D:\codigo.png')) And this error pops up: ImportError: cannot import name ' imaging'

Cannot import name '_imaging' from 'PIL'

喜夏-厌秋 提交于 2021-02-05 06:09:39
问题 I'm trying to run this code: import pyautogui import time from PIL import _imaging from PIL import Image import pytesseract time.sleep(5) captura = pyautogui.screenshot() codigo = captura.crop((872, 292, 983, 337)) codigo.save(r'C:\autobot_wwe_supercard\imagenes\codigo.png') time.sleep(2) pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract' print(pytesseract.image_to_string(r'D:\codigo.png')) And this error pops up: ImportError: cannot import name ' imaging'

Cannot import name '_imaging' from 'PIL'

瘦欲@ 提交于 2021-02-05 06:08:27
问题 I'm trying to run this code: import pyautogui import time from PIL import _imaging from PIL import Image import pytesseract time.sleep(5) captura = pyautogui.screenshot() codigo = captura.crop((872, 292, 983, 337)) codigo.save(r'C:\autobot_wwe_supercard\imagenes\codigo.png') time.sleep(2) pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract' print(pytesseract.image_to_string(r'D:\codigo.png')) And this error pops up: ImportError: cannot import name ' imaging'

Is “from … import …” sometimes required and plain “import …” not always working? Why?

筅森魡賤 提交于 2021-02-05 05:12:13
问题 I always thought, doing from x import y and then directly use y , or doing import x and later use x.y was only a matter of style and avoiding naming conflicts. But it seems like this is not always the case. Sometimes from ... import ... seems to be required : Python 3.7.5 (default, Nov 20 2019, 09:21:52) [GCC 9.2.1 20191008] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import PIL >>> PIL.__version__ '6.1.0' >>> im = PIL.Image.open("test.png") Traceback