- Installation
- Mini Task Color to Grayscale
- Image Handling (Reading Image , Displaying , Saving , Image Dimensions, Color Channels , Grayscale Conversion)
- Image -> A 2D grid of pixels (matrix of numbers)
- Pixel -> Smallest unit of Image , a colored pixel will hold 3 values : Red Green Blue in range of 0 - 255
- Width & Height -> Horizontal total pixels & Vertical total pixels
- Color Channel -> A channel that stores a part of the color information for each pixel (Grayscale : 1 , RGB : 3)
- Image Format -> the way image is compressed and stored in our device.
- Loading Image:
image = cv2.imread("path", flag)
- image -> Variable
- cv2.imread -> load and read image
- path -> image path
- flag -> default 1 = color , 0 = grayscale , -1 = unchanged
- Display Image :
cv2.imshow("Title", image)cv2.waitKey(0)cv2.destroyAllWindows()
- waitKey(0) -> to keep the image display on pause , 0 to keep the window till any key is
pressed on keyboard - destroyAllWindows() -> to close that created window
- Saving Image:
cv2.imwrite("output.jpg", image)
- imwrite() -> saves the image to hard disk
- Image Dimension:
image.shape
- .shape -> will return height , width , and channel.
- GrayScale Conversion:
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
- .cvtColor -> convert color to change color of image
- cv2.COLOR_BGR2GRAY -> change BGR to GRAY