import cv2
img = cv2.imread('/home/cobalt/Pictures/elder.jpg')[:,:,::-1]
import matplotlib.pyplot as plt
%matplotlib inline
fig, ax = plt.subplots(figsize=(24,12))
plt.imshow(img)
<matplotlib.image.AxesImage at 0xbb0d12c>
print img.shape
print img.dtype
print img.min(), img.max()
(719, 1280, 3) uint8 0 255
# raw BGR instead
img = cv2.imread('/home/cobalt/Pictures/elder.jpg')
fig, ax = plt.subplots(figsize=(24,12))
plt.imshow(img)
<matplotlib.image.AxesImage at 0xbe3da0c>
im_gray = cv2.imread("/home/cobalt/Pictures/elder.jpg", cv2.IMREAD_GRAYSCALE)
fig, ax = plt.subplots(figsize=(24,12))
plt.imshow(im_gray, cmap = plt.cm.gray)
<matplotlib.image.AxesImage at 0xbf6132c>
img = cv2.imread("/home/cobalt/Pictures/elder.jpg")[:,:,::-1]
fig, axes = plt.subplots(2, 2, figsize = (24, 12))
axes = axes.ravel()
fig.tight_layout()
axes[0].imshow(img)
axes[0].set_title("original")
axes[1].imshow(img[:, :, 0], cmap = plt.cm.Reds)
axes[1].set_title("red")
axes[2].imshow(img[:, :, 1], cmap = plt.cm.Greens)
axes[2].set_title("green")
axes[3].imshow(img[:, :, 2], cmap = plt.cm.Blues)
axes[3].set_title("blue")
<matplotlib.text.Text at 0xc6351ec>