opencv imwrite
时间: 2023-05-26 15:02:05 浏览: 126
The function `cv2.imwrite()` is used to write an image to a file in OpenCV.
Syntax:
`cv2.imwrite(filename, img[, params])`
Parameters:
- **filename**: Name of the file to be saved. The file extension should be supported by OpenCV.
- **img**: The numpy array containing the image to be saved.
- **params**: The optional parameters to be passed to the file writer.
Return Value:
The function returns true if the image is saved successfully, otherwise false.
Example:
```
import cv2
# Read an image
img = cv2.imread('image.jpg')
# Save the image
cv2.imwrite('saved_image.jpg', img)
```
In the above example, we first read an image using `cv2.imread()` and then save it using `cv2.imwrite()`. The saved image will be in the same directory as the program.
阅读全文