Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

cv2 jupyter notebook matplotlib inverted colors fix

from PIL import Image
import cv2 
from IPython.display import display

img = cv2.imread('image.png') # with the OpenCV function imread(), the order of colors is BGR (blue, green, red).

# In Pillow, the order of colors is assumed to be RGB (red, green, blue).
# As we are using Image.fromarray() of PIL module, we need to convert BGR to RGB.

img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) # Converting BGR to RGB

display(Image.fromarray(img))
Comment

PREVIOUS NEXT
Code Example
Python :: python secret module to generate secure strings 
Python :: Horizontal stacked bar chart with annotations 
Python :: pytube.exceptions.RegexMatchError: __init__: could not find match for ^w+W 
Python :: python get combobox value 
Python :: np logical and 
Python :: initialise a 3D tab in python 
Python :: create layer file arcpy 
Python :: generating cross tables after clustering 
Python :: NMF cosine similarities 
Python :: plotting a dendrogram from the distance matrix 
Python :: Python Code for Checking if a number is an Odd number 
Python :: remove variables withouth variance python 
Python :: patoolib extract password-protected archives 
Python :: python concurrent.futures.ProcessPoolExecutor multiple arguments 
Python :: delta lake with spark 
Python :: 1042 uri solution 
Python :: Select non-NaN rows and replace column value 
Python :: filetype: env "DB_PASSWORD" 
Python :: unpack list 
Python :: expecting property name enclosed in double quotes json 
Python :: change the surface color rhinopython 
Python :: how to import qpalette pyqt5 
Python :: make_interp_spline 
Python :: how to check what version of pygame you have instaled 
Python :: how to write a correct python code 
Python :: micropython string to int 
Python :: flask return 404 
Python :: importare un csv in pycharm e pandas 
Python :: staff user is not restricting permission in django 
Python :: count number of repeats in list python 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =