1. Description of IMAGE BGR format
The data format for reading images in OpenCV is NUMpy’s NDARray data format. The value is in the BGR format and ranges from 0 to 255.
As shown in the figure below, it is divided into three dimensions:
First dimension: Height Height, the number of nRow rows corresponding to the image
The second dimension: Width, the number of nCol columns corresponding to the image
The third dimension: Value indicates the Value of the THREE BGR channels
BGR stands for blue, green and red
2. Properties of the Image object
Image. shape Returns the width, length, and number of channels of the image. If it is a grayscale image, only the number of rows and columns are returned.
Image. size Returns the pixels of the image
Image. dtype Returns the data type of the image
The import cv2 img = cv2. Imread (' 1. JPG ') print (" length: "img. Shape [1]," width: ", img. Shape [0], "channel:", img. Shape [2], "pixel", img. The size, "Data type :", img.dtype)Copy the code