X-Git-Url: http://git.tomasm.cz/imago.git/blobdiff_plain/3790db9ab7a4871faf0b445c8283c7f0b7b30a22..dfd21c7829d456a1c05db4fb0ef10c5994e2469a:/imago_pack/hough.py?ds=sidebyside diff --git a/imago_pack/hough.py b/imago_pack/hough.py index 2f6e63f..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 - 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)