# Reading a image files
import cv2
img = cv2.imread("rose.png")
print("Image Properties:")
print("- Number of Pixels: " + str(img.size))
print("- Shape/Dimensions: " + str(img.shape))
Image Properties:
- Number of Pixels: 7458906
- Shape/Dimensions: (1729, 1438, 3)
import numpy as np
import cv2
img_gs = cv2.imread("rose.png", cv2.IMREAD_GRAYSCALE) # Convert image to grayscale
blue, green, red = cv2.split(img) # Split the image into its channels
rgb = cv2.merge([red,green,blue])
cv2.imshow('rgb image',rgb)
# Displaying the image
cv2.imshow('image', img_gs)
cv2.waitKey(0)
cv2.destroyAllWindows()