# Read Image
import numpy as np
import cv2
# Load an color image in grayscale
img = cv2.imread('messi5.jpg',0)
#Display an Image: Use the function cv2.imshow() to display an image in a window. The window automatically fits to the image size
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
'''
cv2.waitKey() is a keyboard binding function. Its argument is the time in milliseconds.
The function waits for specified milliseconds for any keyboard event.
cv2.destroyAllWindows() simply destroys all the windows we created.
If you want to destroy any specific window, use the function cv2.destroyWindow()
where you pass the exact window name as the argument.
'''
# Write an image: Use the function cv2.imwrite() to save an image.
#First argument is the file name, second argument is the image you want to save.
cv2.imwrite('messigray.png',img)