Skip to content

Commit 9866848

Browse files
committed
Revert "up 13"
This reverts commit f419435.
1 parent f419435 commit 9866848

File tree

2 files changed

+8
-24
lines changed

2 files changed

+8
-24
lines changed
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# edges = cv2.Canny(gray,50,150,apertureSize = 3)
1313
edges = cv2.Canny(gray, 10, 50, apertureSize=3)
1414
cv2.imshow("edges", edges)
15-
1615
lines = cv2.HoughLines(edges, 1, np.pi / 180, 200)
1716
print("Len of lines:", len(lines))
1817
# print lines
@@ -32,4 +31,3 @@
3231
# cv2.imwrite('houghlines3.jpg',img)
3332
cv2.imshow("houghlines3.jpg", img)
3433
cv2.waitKey(0)
35-
cv2.destroyAllWindows()

官方samples/color_histogram.py

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,20 @@
1919

2020
if __name__ == '__main__':
2121

22-
# 构建 HSV颜色地图
2322
hsv_map = np.zeros((180, 256, 3), np.uint8)
24-
# np.indices 可以 回由数组索引构建的新数组。 例如 np.indices 3,2 其中 3,2 为原来数组的维度 和列。 回值 先看 入的参数有几维 3,2 有 2 维 所以从 出的结果应 是 [[a],[b]], 其中包含两个 3 2 列数组。 第二看每一维的大小 第一维为 3, 所以 a 中的值就 0 到 2 最大索引数 a 中的每一个值就是它的 索引 同样的方法得到 b 列索引
25-
# 结果就是
26-
# array([[[0, 0],
27-
# [1, 1],
28-
# [2, 2]],
29-
# [[0, 1],
30-
# [0, 1],
31-
# [0, 1]]])
3223
h, s = np.indices(hsv_map.shape[:2])
33-
hsv_map[:, :, 0] = h
34-
hsv_map[:, :, 1] = s
35-
hsv_map[:, :, 2] = 255
24+
hsv_map[:,:,0] = h
25+
hsv_map[:,:,1] = s
26+
hsv_map[:,:,2] = 255
3627
hsv_map = cv2.cvtColor(hsv_map, cv2.COLOR_HSV2BGR)
3728
cv2.imshow('hsv_map', hsv_map)
3829

3930
cv2.namedWindow('hist', 0)
4031
hist_scale = 10
4132

42-
4333
def set_scale(val):
4434
global hist_scale
4535
hist_scale = val
46-
47-
4836
cv2.createTrackbar('scale', 'hist', hist_scale, 32, set_scale)
4937

5038
try:
@@ -56,21 +44,19 @@ def set_scale(val):
5644
while True:
5745
flag, frame = cam.read()
5846
cv2.imshow('camera', frame)
59-
# 图像 字塔
60-
# 图像 字塔 低分 率 但不会对直方图有太大影响。
61-
# 但 种低分 率 可以很好抑制噪声 从而去 孤立的小点对直方图的影响
47+
6248
small = cv2.pyrDown(frame)
6349

6450
hsv = cv2.cvtColor(small, cv2.COLOR_BGR2HSV)
65-
dark = hsv[..., 2] < 32
51+
dark = hsv[...,2] < 32
6652
hsv[dark] = 0
6753
h = cv2.calcHist([hsv], [0, 1], None, [180, 256], [0, 180, 0, 256])
6854

69-
h = np.clip(h * 0.005 * hist_scale, 0, 1)
70-
vis = hsv_map * h[:, :, np.newaxis] / 255.0
55+
h = np.clip(h*0.005*hist_scale, 0, 1)
56+
vis = hsv_map*h[:,:,np.newaxis] / 255.0
7157
cv2.imshow('hist', vis)
7258

7359
ch = cv2.waitKey(1)
74-
if ch == ord('q'):
60+
if ch == 27:
7561
break
7662
cv2.destroyAllWindows()

0 commit comments

Comments
 (0)