Table of Contents
show
cv2 is the namespace for opencv library
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
img = cv2.imread("parrot.jpg")

cv2.imread // automatically reads the image as numpy array
When the path specified in the imread( ) is wrong, then it does not show the error rather it shows the type as None

- imread() – to load an image from the specified file
- The input is the path of the image. The result is a numpy array with intensity values as 8 bits
To get the size of the image
img.shape

To print the pixel value of the image
img

To display the image
plt.imshow(img)

While trying to show the image, the color appears off
This is because the order of each channel is different in OpenCV
The image is shown as bluish tint. Why?
- Because OpenCV and matplotlib expects different orders of red, green and blue channels
- Matplotlib reads the images as Red, Green, Blue
- OpenCV reads the images as Blue, Gree, Red
PIL vs OpenCV

Views: 1