import Image, ImageDraw, ImageFilter
-from manual import lines as g_grid, l2ad
+from manual import lines as g_grid, l2ad, intersection, line as g_line
from intrsc import intersections_from_angl_dist
from linef import line_from_angl_dist
def t(self):
return (self.x, self.y)
+ def normal(self):
+ return V(-self.y, self.x)
+
+def projection(point, line, vector):
+ n = vector.normal()
+ l2 = g_line(point.t(), (point + n).t())
+ return V(*intersection(l2, g_line(*line)))
+
+
def find(lines, size, l1, l2, bounds, hough, do_something):
a, b, c, d = [V(*a) for a in bounds]
l1 = line_from_angl_dist(l1, size)
l2 = line_from_angl_dist(l2, size)
v1 = V(*l1[0]) - V(*l1[1])
v2 = V(*l2[0]) - V(*l2[1])
+ a = projection(a, l1, v1)
+ b = projection(b, l1, v1)
+ c = projection(c, l2, v2)
+ d = projection(d, l2, v2)
grid = get_grid(a, b, c, d, hough, size)
dist = distance(lines, grid, size)
print dist
dr_g = ImageDraw.Draw(im_g)
for line in grid[0] + grid[1]:
dr_g.line(line, width=1, fill=255)
+ #im_g = im_g.filter(MyGaussianBlur(radius=3))
im_d, distance = combine(im_l, im_g)
return distance
for x in xrange(fg.size[0]):
for y in xrange(fg.size[1]):
if fg_l[x, y]:
- res_l[x, y] = bg_l[x, y]
+ res_l[x, y] = bg_l[x, y] * fg_l[x, y]
score += bg_l[x, y]
area += 1