By performing the following steps, you will be able to visualize the true-color palette of a color image:
- Let's have a look at a particular image:
In [1]: import cv2... import numpy as np... lena = cv2.imread('data/lena.jpg', cv2.IMREAD_COLOR)
- By now, we know how to start Matplotlib in our sleep:
In [2]: import matplotlib.pyplot as plt... %matplotlib inline... plt.style.use('ggplot')
- However, this time, we want to disable the grid lines that the ggplot option typically displays over images:
In [3]: plt.rc('axes', **{'grid': False})
- Then, we can visualize Lena with the following command (don't forget to switch the BGR ordering of the color channels to RGB):
In [4]: plt.imshow(cv2.cvtColor(lena, cv2.COLOR_BGR2RGB)) ...