plt.imshow显示灰度图
时间: 2023-08-21 19:08:30 浏览: 111
要想在使用plt.imshow函数显示灰度图像,可以通过设置cmap参数为'gray'来实现。具体的代码如下所示:
```python
import matplotlib.pyplot as plt
plt.imshow(img, cmap='gray')
plt.show()
```
其中,img是你要显示的灰度图像。通过将cmap参数设置为'gray',可以确保图像以灰度的形式显示出来。\[1\] \[2\]
#### 引用[.reference_title]
- *1* *3* [python计算机视觉第一章](https://blog.csdn.net/weixin_45154388/article/details/117779279)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [【Python】如何使用matplotlib 库正确的显示灰度图像](https://blog.csdn.net/qq_42951560/article/details/124355446)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文