projekty
/
imago.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8056745
)
peak extraction
author
Tomas Musil
<tomik.musil@gmail.com>
Tue, 10 Apr 2012 18:33:01 +0000
(20:33 +0200)
committer
Tomas Musil
<tomik.musil@gmail.com>
Tue, 10 Apr 2012 18:33:01 +0000
(20:33 +0200)
Much better results on the second test set.
filters.py
patch
|
blob
|
history
imago.py
patch
|
blob
|
history
diff --git
a/filters.py
b/filters.py
index
df3b49f
..
222d8fe
100644
(file)
--- a/
filters.py
+++ b/
filters.py
@@
-10,8
+10,8
@@
def edge_detection(image):
print "edge detection"
for x in range(2, image.size[0] - 2):
for y in range(2, image.size[1] - 2):
print "edge detection"
for x in range(2, image.size[0] - 2):
for y in range(2, image.size[1] - 2):
- pix = (sum([sum(
-
[
image_l[a, b]
+ pix = (sum([sum(
[
+ image_l[a, b]
for b in range(y - 2, y + 3)])
for a in range(x - 2, x + 3)])
- (25 * image_l[x, y]))
for b in range(y - 2, y + 3)])
for a in range(x - 2, x + 3)])
- (25 * image_l[x, y]))
@@
-21,6
+21,26
@@
def edge_detection(image):
pix = 0
new_image_l[x, y] = pix
return new_image
pix = 0
new_image_l[x, y] = pix
return new_image
+
+def peaks(image):
+ image_l = image.load()
+ new_image = Image.new('L', image.size)
+ new_image_l = new_image.load()
+ clear()
+ print "peak extraction"
+ for x in range(2, image.size[0] - 2):
+ for y in range(2, image.size[1] - 2):
+ pix = (sum([sum([
+ - image_l[a, b]
+ for b in range(y - 2, y + 3)])
+ for a in range(x - 2, x + 3)])
+ + (16 * image_l[x, y]))
+ if pix > 255:
+ pix = 255
+ if pix < 0:
+ pix = 0
+ new_image_l[x, y] = pix
+ return new_image
def high_pass(image, height):
image_l = image.load()
def high_pass(image, height):
image_l = image.load()
diff --git
a/imago.py
b/imago.py
index
3634363
..
45d165c
100755
(executable)
--- a/
imago.py
+++ b/
imago.py
@@
-68,6
+68,10
@@
def main():
im_hough = hough1.transform(im_h)
if show_all:
do_something(im_hough, "hough transform")
im_hough = hough1.transform(im_h)
if show_all:
do_something(im_hough, "hough transform")
+
+ im_hough = filters.peaks(im_hough)
+ if show_all:
+ do_something(im_hough, "peak extraction")
im_h2 = filters.high_pass(im_hough, 120)
if show_all:
im_h2 = filters.high_pass(im_hough, 120)
if show_all: