-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4420f29
commit 6c3af15
Showing
10 changed files
with
245 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
def Cluster(lines, var1, var2): | ||
''' | ||
数轴上两类聚类 | ||
输入:初始line,两个估计聚集点 | ||
输出:两个聚类后的数组 | ||
''' | ||
while True: | ||
line1 = [] | ||
line2 = [] | ||
for line in lines: | ||
for rho, _ in line: | ||
if abs(abs(rho) - var1) <= abs(abs(rho) - var2): | ||
line1.append(line) | ||
else: | ||
line2.append(line) | ||
nvar1 = getMeans(line1) | ||
nvar2 = getMeans(line2) | ||
# 若新聚集点误差大于原聚集点的百分之一则继续 | ||
if abs(nvar1 - var1) > var1 / 100 or abs(nvar2 - var2) > var2 / 100: | ||
var1 = nvar1 | ||
var2 = nvar2 | ||
else: | ||
return line1, line2 | ||
|
||
def getMeans(lines): | ||
''' | ||
计算平均值,line为数组 | ||
''' | ||
sum = 0 | ||
for line in lines: | ||
for rho, _ in line: | ||
sum += abs(rho) | ||
return (sum / len(lines)) if len(lines) else 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
red_low = 150 | ||
red_high = 195 | ||
green_low = 160 | ||
green_high = 205 | ||
blue_low = 160 | ||
blue_high = 205 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
canny_threshold_1 = 100 | ||
canny_threshold_2 = 150 | ||
sobel = 3 | ||
hough_rho = 1 | ||
hough_theta = 1 | ||
hough_threshold = 20 |
Oops, something went wrong.