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)
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):
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]):
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)