projekty
/
imago.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
5c59d02
)
intersections
author
Tomas Musil
<tomik.musil@gmail.com>
Tue, 7 Aug 2012 15:56:00 +0000
(17:56 +0200)
committer
Tomas Musil
<tomik.musil@gmail.com>
Tue, 7 Aug 2012 15:56:00 +0000
(17:56 +0200)
imago.py
patch
|
blob
|
history
diff --git
a/imago.py
b/imago.py
index
f3a9eb7
..
127ddd9
100755
(executable)
--- a/
imago.py
+++ b/
imago.py
@@
-110,9
+110,12
@@
def main():
do_something(im_c, "first hough x lines")
lines = hough1.all_lines(im_c)
do_something(im_c, "first hough x lines")
lines = hough1.all_lines(im_c)
+ intersections = intersections_from_angl_dist(lines)
draw = ImageDraw.Draw(image)
draw = ImageDraw.Draw(image)
- for line in lines:
- draw.line(line_from_angl_dist(line, image.size), fill=(120, 255, 120))
+ for (x, y) in intersections:
+ draw.point((x + image.size[0] / 2, y + image.size[1] / 2), fill=(120, 255, 120))
+
+ print(len(intersections))
do_something(image, "the grid")
do_something(image, "the grid")
@@
-142,10
+145,20
@@
def combine(image1, image2):
def line_from_angl_dist((angle, distance), size):
x1 = - size[0] / 2
def line_from_angl_dist((angle, distance), size):
x1 = - size[0] / 2
- y1 = int(round((x1 * math.sin(angle) - distance)
/
math.cos(angle))) + size[1] / 2
+ y1 = int(round((x1 * math.sin(angle) - distance)
/
math.cos(angle))) + size[1] / 2
x2 = size[0] / 2
x2 = size[0] / 2
- y2 = int(round((x2 * math.sin(angle) - distance)
/
math.cos(angle))) + size[1] / 2
+ y2 = int(round((x2 * math.sin(angle) - distance)
/
math.cos(angle))) + size[1] / 2
return [(0, y1), (size[0] - 1, y2)]
return [(0, y1), (size[0] - 1, y2)]
+def intersections_from_angl_dist(lines):
+ intersections = set()
+ for (angl1, dist1) in lines:
+ for (angl2, dist2) in lines:
+ if abs(angl1 - angl2) > 0.3:
+ x = - ((dist2 / math.cos(angl2))-(dist1 / math.cos(angl1))) / (math.tan(angl1) - math.tan(angl2))
+ y = (math.tan(angl1) * x) - (dist1 / math.cos(angl1))
+ intersections.add((int(x), int(y)))
+ return intersections
+
if __name__ == '__main__':
sys.exit(main())
if __name__ == '__main__':
sys.exit(main())