Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to return PIL image from opencv

import cv2
import numpy as np
from PIL import Image

img = cv2.imread("path/to/img.png")

# You may need to convert the color.
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
im_pil = Image.fromarray(img)

# For reversing the operation:
im_np = np.asarray(im_pil)
Comment

PREVIOUS NEXT
Code Example
Python :: drop a column pandas 
Python :: where to import messages in django 
Python :: cv2 grayscale 
Python :: install xgboost 
Python :: cv2 add text 
Python :: jupyter notebook reload module 
Python :: python clear console 
Python :: dataframe column to string 
Python :: pandas version check in python 
Python :: ValueError: Tz-aware datetime.datetime cannot be converted to datetime64 unless utc=True site:stackoverflow.com 
Python :: how to round the values in a list 
Python :: how to add percentage in pie chart in python 
Python :: python upgrade pip scipy 
Python :: select first word in string python 
Python :: convert dataframe to float 
Python :: EnvironmentError command line 
Python :: python upload video to youtube 
Python :: pygame rect collisions 
Python :: how to get image in jupyter notebook 
Python :: how to check weather my model is on gpu in pytorch 
Python :: not x axis labels python 
Python :: python reload function from file 
Python :: python resize image 
Python :: terminal python version 
Python :: pandas rename index 
Python :: python elif invalid syntax 
Python :: read google sheet from web to pandas python 
Python :: Python function remove all whitespace from all character columns in dataframe 
Python :: xlim python 
Python :: pygame get mouse position 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =