projekty
/
imago.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
comments for hough and geometry
[imago.git]
/
imago_pack
/
hough.py
diff --git
a/imago_pack/hough.py
b/imago_pack/hough.py
index
2f6e63f
..
deeb9d8
100644
(file)
--- a/
imago_pack/hough.py
+++ b/
imago_pack/hough.py
@@
-7,14
+7,20
@@
from PIL import Image
import pcf
class Hough:
import pcf
class Hough:
+ """Hough transform.
+
+ This class stores the transformed image and metainformation.
+ """
def __init__(self, size, dt, init_angle, image):
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):
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)
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):
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):
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):
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):
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]):
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):
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)
return (self.dt * point[1] + self.initial_angle,
point[0] - self.size[0] / 2)