python-imaging-library

Image Processing Error, “not enough values to unpack”

*爱你&永不变心* 提交于 2020-06-01 07:40:29
问题 The main problem was described by the post earlier. This is a sequel with full code and traceback. I have a certain error while processing photos using the telegram bot. In particular, this is a problem with a change in contrast. Full code: import telebot import os import urllib.request from PIL import Image import numpy as np TOKEN = 'here token is, just cut it out' bot = telebot.TeleBot(TOKEN) result_storage_path = 'temp' @bot.message_handler(commands=['start']) def start_message(message):

Using PIL or a Numpy array, how can I remove entire rows from an image?

馋奶兔 提交于 2020-05-29 04:13:12
问题 I would like to know how I could remove entire rows from an image, preferably based on the color of the row? Example: I have an image that is 5 pixels in height, the top two rows and the bottom two rows are white and the middle row is black. I would like to know how I could get PIL to identify this row of black pixels, then, remove the entire row and save the new image. I have some knowledge of python and have so far been editing my images by listing the result of "getdata" so any answers

Python CAPTCHA-like image disortion

无人久伴 提交于 2020-05-26 06:09:18
问题 I would like to disort some images the same way standard CAPTCHA disorts fonts. How would I achieve it in python? What libraries/algorithms I should use? Any proof-of-concept? DISCLAIMER: I was googling for some time before I asked this question but I couldn't find any satisfying answer. I'm new to the field so I can't provide any code proving my 'research effort'... 回答1: I think you are looking for PyCaptcha http://svn.navi.cx/misc/trunk/pycaptcha/ The actual code to distort is here: http:/

OpenCV reads an image as a 3-channel image while PIL reads the same image as a 1-channel image

泄露秘密 提交于 2020-05-26 05:40:03
问题 I'm trying to figure out the NYU-v2 for semantic segmentation dataset in this Repository. I'm having a hard time trying to understand how the image labels have been stored. For example, given the following image : The corresponding label image is: Now if I open the label image in OpenCV it reads this image as an RGB image:(wrongly, though. Even tried -1 as the second argument in imread ) import cv2 import numpy as np img = img = cv2.imread(labelImage) img.shape >>> (468, 625, 3) np.unque(img)

OpenCV reads an image as a 3-channel image while PIL reads the same image as a 1-channel image

旧时模样 提交于 2020-05-26 05:39:32
问题 I'm trying to figure out the NYU-v2 for semantic segmentation dataset in this Repository. I'm having a hard time trying to understand how the image labels have been stored. For example, given the following image : The corresponding label image is: Now if I open the label image in OpenCV it reads this image as an RGB image:(wrongly, though. Even tried -1 as the second argument in imread ) import cv2 import numpy as np img = img = cv2.imread(labelImage) img.shape >>> (468, 625, 3) np.unque(img)

OpenCV reads an image as a 3-channel image while PIL reads the same image as a 1-channel image

一个人想着一个人 提交于 2020-05-26 05:38:39
问题 I'm trying to figure out the NYU-v2 for semantic segmentation dataset in this Repository. I'm having a hard time trying to understand how the image labels have been stored. For example, given the following image : The corresponding label image is: Now if I open the label image in OpenCV it reads this image as an RGB image:(wrongly, though. Even tried -1 as the second argument in imread ) import cv2 import numpy as np img = img = cv2.imread(labelImage) img.shape >>> (468, 625, 3) np.unque(img)

Python PIL image Verify returns None

谁说胖子不能爱 提交于 2020-05-26 02:45:35
问题 I am developing a tool which retrieves a JPG from an API and processes it. The source of the image cannot be trusted and I want to test if the image is a valid JPG (which is the only image type allowed). I encountered an error with PIL that I am unable to fix. Below is my code: image = StringIO(base64.b64decode(download['file'])) img = Image.open(image) if img.verify(): print 'Valid image' else: print 'Invalid image' However, it seems that img.verify() returns None. I can call other functions

Python PIL image Verify returns None

扶醉桌前 提交于 2020-05-26 02:45:34
问题 I am developing a tool which retrieves a JPG from an API and processes it. The source of the image cannot be trusted and I want to test if the image is a valid JPG (which is the only image type allowed). I encountered an error with PIL that I am unable to fix. Below is my code: image = StringIO(base64.b64decode(download['file'])) img = Image.open(image) if img.verify(): print 'Valid image' else: print 'Invalid image' However, it seems that img.verify() returns None. I can call other functions

Python PIL image Verify returns None

谁说胖子不能爱 提交于 2020-05-26 02:43:12
问题 I am developing a tool which retrieves a JPG from an API and processes it. The source of the image cannot be trusted and I want to test if the image is a valid JPG (which is the only image type allowed). I encountered an error with PIL that I am unable to fix. Below is my code: image = StringIO(base64.b64decode(download['file'])) img = Image.open(image) if img.verify(): print 'Valid image' else: print 'Invalid image' However, it seems that img.verify() returns None. I can call other functions

How to find subimage using the PIL library?

£可爱£侵袭症+ 提交于 2020-05-24 21:22:46
问题 I want to find the sub-image from large image using PIL library. I also want to know the coordinates where it is found ? 回答1: import cv2 import numpy as np image = cv2.imread("Large.png") template = cv2.imread("small.png") result = cv2.matchTemplate(image,template,cv2.TM_CCOEFF_NORMED) print np.unravel_index(result.argmax(),result.shape) This works fine and in efficient way for me. 回答2: I managed to do this only using PIL. Some caveats: This is a pixel perfect search. It simply looks for