projekty
/
imago.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
1e4066f
)
index error in stone_color fixed
author
Tomas Musil
<tomik.musil@gmail.com>
Sat, 25 Aug 2012 16:19:48 +0000
(18:19 +0200)
committer
Tomas Musil
<tomik.musil@gmail.com>
Sat, 25 Aug 2012 16:19:48 +0000
(18:19 +0200)
imago.py
patch
|
blob
|
history
diff --git
a/imago.py
b/imago.py
index
cf04f53
..
3c4ca56
100755
(executable)
--- a/
imago.py
+++ b/
imago.py
@@
-167,7
+167,10
@@
def stone_color(image, (x, y)):
suma = 0.
for i in range(-2, 3):
for j in range(-2, 3):
suma = 0.
for i in range(-2, 3):
for j in range(-2, 3):
- suma += sum(image.getpixel((x + i, y + j)))
+ try:
+ suma += sum(image.getpixel((x + i, y + j)))
+ except IndexError:
+ pass
suma /= 3 * 25
if suma < 55:
return 'B'
suma /= 3 * 25
if suma < 55:
return 'B'
@@
-212,7
+215,9
@@
def intersections_from_angl_dist(lines, size):
if abs(angl1 - angl2) > 0.4:
x = - ((dist2 / math.cos(angl2))-(dist1 / math.cos(angl1))) / (math.tan(angl1) - math.tan(angl2))
y = (math.tan(angl1) * x) - (dist1 / math.cos(angl1))
if abs(angl1 - angl2) > 0.4:
x = - ((dist2 / math.cos(angl2))-(dist1 / math.cos(angl1))) / (math.tan(angl1) - math.tan(angl2))
y = (math.tan(angl1) * x) - (dist1 / math.cos(angl1))
- line.append((int(x + size[0] / 2), int(y + size[1] / 2)))
+ if (-size[0] / 2 < x < size[0] / 2 and
+ -size[1] / 2 < y < size[1] / 2):
+ line.append((int(x + size[0] / 2), int(y + size[1] / 2)))
intersections.append(line)
return intersections
intersections.append(line)
return intersections