projekty
/
imago.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
index error in stone_color fixed
[imago.git]
/
imago.py
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