Skip to content

Commit bdb0ac8

Browse files
committed
add files: Basic.py
1 parent 57b15f8 commit bdb0ac8

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

opencv/Basic.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import cv2 as cv
2+
import numpy as np
3+
4+
fileName0 = "C:\\Users\\nvt-pc\\Desktop\\1.png"
5+
fileName1 = "C:\\Users\\nvt-pc\\Desktop\\1_0.png"
6+
7+
img = cv.imread(fileName0)
8+
9+
# 图像:高、宽、channel
10+
print(img.shape)
11+
# 像素取值
12+
pixel = img[100, 100]
13+
# 图像通道分割
14+
b, g, r = cv.split(img)
15+
# 图像高、宽
16+
h, w = img.shape[0:2]
17+
# 图像缩放
18+
img_resize = cv.resize(img, (50, 50), cv.INTER_AREA)
19+
# 颜色空间变换
20+
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
21+
# 保存图像
22+
cv.imwrite(fileName1, gray)
23+
24+
25+

0 commit comments

Comments
 (0)