opencv_python uses
1. Gui features in opencv:
1. Read in the image:
The cv2.imread() function reads in the image. Its parameters are:
(1) The path to this image.
(2) Tell the function how to read the image:
cv2.IMREAD_COLOR: Read in a color image. But the transparency of the image is ignored and can be represented by 1.
cv2.IMREAD_GRAYSCALE: Read the image in grayscale mode, which can be represented by 0.
cv2.IMREAD_UNCHANGED: read in an image, and include the alpha channel of the image, I haven't tried out how to represent this.
1 import numpy as np 2 import cv2 3 img=cv2.imread('F:\python\opencv\pic\kongfu.jpg',0)
2. Display image:
cv2.imshow() displays the image. The first parameter is the name of the window, followed by the obtained image parameter.
3. Save the image:
Use the function cv2.imwrite() to save an image. The first parameter is a filename, followed by the image you want to save.
Summary code: