Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Pillow opencv convert RGB to BRG or RGB to BRG

import PIL
import numpy as np
img = PIL.Image.open("myimage.png") # The image is load in RGB order.
img = np.asarray(img)'''The Image.open() method opens a file in binary 
format which needs to be converted to numpy however the order is still
RGB. Below is the conversion to BGR is done:'''
screen = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
# It is also possible to go in reverse:
screen = cv2.cvtColor(screen, cv2.COLOR_BGR2RGB)
 
PREVIOUS NEXT
Tagged: #Pillow #opencv #convert #RGB #BRG #RGB #BRG
ADD COMMENT
Topic
Name
4+1 =