Replaced some PIL methods with cv2 methods