Files
fzu-product/2.高效学习/2.4提问的艺术.md
2023-04-14 15:41:04 +08:00

36 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 2.4 提问的艺术
最好的提问方式就是自问自答。
请结合 2.1.3 共同观看
# 2.4.1 关于如何搜索代码
如果我现在想要把图片读取并转换成灰度图,我该怎么去搜索呢?
首先,我打算使用 python所以我会搜索“python 图片转灰度图”
以下是我从搜索到的博客中找到的代码:
```python
import cv2 as cv
img = cv.imread('lbxx.jpg',1)
img_1 = cv.cvtColor(img,cv.COLOR_BGR2GRAY)
cv.imshow('gray',img_1)
cv.imshow('colour',img)
cv.waitKey(0)
```
接下来,我会去搜索每行代码的作用:(以下是搜索后我做的注释)
```python
import cv2 as cv # 调opencv库
img = cv.imread('lbxx.jpg',1) # 读取图片(“图片路径”)
img_1 = cv.cvtColor(img,cv.COLOR_BGR2GRAY) # 转换成灰度图(图片, 颜色模式)
cv.imshow('gray',img_1) # 展示图片展示img_1为灰度图
cv.imshow('colour',img) # 展示图片展示img为彩色图
cv.waitKey(0) # 保存展示窗口打开
```
于是,我就不仅学会了如何转换灰度图,还学会了相关函数的用法。