opencv imwrite
时间: 2023-05-26 14:02:05 浏览: 49
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.
相关推荐
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)