cv2 read rgb image 1

cv2 read rgb image

import cv2
#read image
img = cv2.imread('D:/image-1.png')
#print its shape
print('Image Dimensions :', img.shape)

Here is what the above code is Doing:
1. cv2.imread() : This is an OpenCV function used to read an image.
2. The first argument is the image path.
3. The second argument is a flag which specifies the way image should be read.
4. cv2.IMREAD_COLOR : Loads a color image. Any transparency of image will be neglected. It is the default flag.
5. cv2.IMREAD_GRAYSCALE : Loads image in grayscale mode
6. cv2.IMREAD_UNCHANGED : Loads image as such including alpha channel
7. Instead of these three flags, you can simply pass integers 1, 0 or -1 respectively.
8. img.shape : It returns a tuple of number of rows, columns and channels (if image is color):

Similar Posts