Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1a22758

Browse files
committed
update ch29-30
1 parent 6107d70 commit 1a22758

File tree

5 files changed

+54
-26
lines changed

5 files changed

+54
-26
lines changed

‎ch29-理解图像特征/note.txt‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
找到图像特征的技术被称为特征检测。
3+
4+
描述特征
5+
6+
计算机也要对特征周围的区域进行描述,这样它才能 在其他图像中找到相同的特征。
7+
我们把这种描述称为特征描述
8+
9+
角点的一个特性:向任何方向移动变化都很大
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# -*-coding:utf8-*-#
2+
__author__ = 'play4fun'
3+
"""
4+
create time:15-10-28 下午7:27
5+
6+
cv2.cornerHarris() 参数如下
7+
• img - 数据类型为 float32 的 入图像。
8+
• blockSize - 点检测中 考 的 域大小。
9+
• ksize - Sobel 求导中使用的窗口大小
10+
• k - Harris 点检测方程中的自由参数 取值参数为 [0,04 0.06].
11+
"""
12+
13+
import cv2
14+
import numpy as np
15+
16+
filename = '../data/chessboard.jpeg'
17+
# filename = '../data/chessboard-3.png'
18+
# filename = '../data/corner-detection.jpg'
19+
20+
img = cv2.imread(filename)
21+
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
22+
gray = np.float32(gray)
23+
24+
# 输入图像必 是 float32 最后一个参数在 0.04 到 0.05 之间
25+
dst = cv2.cornerHarris(gray, 2, 3, 0.04)
26+
# result is dilated for marking the corners, not important
27+
dst = cv2.dilate(dst, None)
28+
# Threshold for an optimal value, it may vary depending on the image.
29+
img[dst > 0.01 * dst.max()] = [0, 0, 255]
30+
31+
cv2.imshow('dst', img)
32+
33+
cv2.waitKey(0)
34+
cv2.destroyAllWindows()

‎ch30-Harris角点检测/cornerSubPix.py‎ renamed to ‎ch30-Harris角点检测/30.2-亚像素级精确度的角点-cornerSubPix.py‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
__author__ = 'play4fun'
33
"""
44
create time:15-10-29 上午7:47
5+
6+
最大精度的角点检测
7+
8+
首先我们 找到 Harris 角点
9+
然后将角点的重心传给这个函数进行修正。
10+
Harris 角点用红色像素标出
11+
绿色像素是修正后的像素。
12+
在使用 个函数是我们 定义一个爹代停止条件。
13+
当 代次数 到或者精度条件满 后 代就会停止。
14+
我们同样需要定义进行角点搜索的邻域大小。
515
"""
616

717
import cv2
@@ -33,7 +43,7 @@
3343
corners = cv2.cornerSubPix(gray, np.float32(centroids), (5, 5), (-1, -1), criteria)
3444
# Now draw them
3545
res = np.hstack((centroids, corners))
36-
# np.int0 可以用来省略小数点后 的数字,非四舍五入
46+
# np.int0 可以用来省略小数点后的数字,非四舍五入
3747
res = np.int0(res)
3848
img[res[:, 1], res[:, 0]] = [0, 0, 255]
3949
img[res[:, 3], res[:, 2]] = [0, 255, 0]

‎ch30-Harris角点检测/cornerHarris.py‎

Lines changed: 0 additions & 25 deletions
This file was deleted.

‎data/fruits.jpg‎

80.5 KB
Loading[フレーム]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /