# Python program to use openCV functions
import cv2
src = cv2.imread("star.jpg") #read-in image
# Using cv2.COLOR_BGR2GRAY convert to gray scale
image = cv2.cvtColor(src, cv2.COLOR_BGR2GRAY )
cv2.imwrite("star_gray.jpg", image) #write image to a new file
# cv2.rectangle() method draw a rectange
start_point = (5, 5)
end_point = (220, 220)
color = (255, 0, 0) # Blue color in BGR
thickness = 4 # Line thickness of 4 px
image = cv2.rectangle(src, start_point, end_point, color, thickness)
image = cv2.rectangle(image, (100,100),(400,400), (0,0,255), thickness)
cv2.imwrite("star_rect.jpg", image)
#---------------------------------------------------------
# put 2 images in parallel(hstack) and serial(vstack)
import numpy as np
a=cv2.imread("star.jpg")
b=cv2.imread("star_rect.jpg")
c=np.hstack((a,b))
d=np.vstack((a,b))
cv2.imwrite("star_hstack.jpg", c)
cv2.imwrite("star_vstack.jpg", d)