From: Tomas Musil Date: Tue, 24 Jun 2014 12:51:20 +0000 (+0200) Subject: comments for hough and geometry X-Git-Url: http://git.tomasm.cz/imago.git/commitdiff_plain/2e09f5b5e012d70ed2d4341d40fe3a01bda68165?ds=sidebyside;hp=8d0a81039d4ba02531b3aa57c99093ce1098818e comments for hough and geometry --- diff --git a/imago_pack/geometry.py b/imago_pack/geometry.py index 60e679b..f324692 100644 --- a/imago_pack/geometry.py +++ b/imago_pack/geometry.py @@ -40,6 +40,7 @@ class V(object): return V(-self.y, self.x) def projection(p, l, v): + #TODO what is this? return V(*intersection(line(p, p + v.normal), line(*l))) def l2ad((a, b), size): diff --git a/imago_pack/hough.py b/imago_pack/hough.py index 77f30b2..deeb9d8 100644 --- a/imago_pack/hough.py +++ b/imago_pack/hough.py @@ -7,14 +7,20 @@ from PIL import Image import pcf class Hough: + """Hough transform. + + This class stores the transformed image and metainformation. + """ def __init__(self, size, dt, init_angle, image): - self.size = size # TODO is this a tuple? This language is crazy - self.dt = dt + self.size = size # this is a tuple (width, height) + self.dt = dt # this is the angle step in hough transform self.initial_angle = init_angle self.image = image @classmethod def Transform(cls, image): + """Create Hough transform of the *image* with default parameters.""" + # TODO rename to transform? size = image.size dt = pi / size[1] initial_angle = (pi / 4) + (dt / 2) @@ -27,12 +33,15 @@ class Hough: filter_f(self.image)) def lines_from_list(self, p_list): + """Take a list of transformed points and return a list of corresponding + lines as (angle, distance) tuples.""" lines = [] for p in p_list: lines.append(self.angle_distance(p)) return lines def all_lines_h(self): + # TODO what is this? im_l = self.image.load() lines1 = [] for x in xrange(self.size[0] / 2): @@ -47,6 +56,7 @@ class Hough: return [lines1, lines2] def all_lines(self): + # TODO what is this? how does it differ from the upper one? im_l = self.image.load() lines = [] for x in xrange(self.size[0]): @@ -56,6 +66,8 @@ class Hough: return lines def angle_distance(self, point): + """Take a point from the transformed image and return the corresponding + line in the original as (angle, distance) tuple.""" return (self.dt * point[1] + self.initial_angle, point[0] - self.size[0] / 2)