Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathanalyse.py
More file actions
Latest commit
66 lines (51 loc) · 1.34 KB
/
Copy pathanalyse.py
File metadata and controls
66 lines (51 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python
#import os,sys
importImage
importImageDraw
#import numpy
#import math
importpylab
defbresenham(x0, y0, x1, y1):
"""https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm"""
dx=abs(x1-x0)
dy=abs(y1-y0)
sx=1ifx0<x1else-1
sy=1ify0<y1else-1
err=dx-dy
yieldx0,y0
whilex0!=x1ory0!=y1:
e2=2*err
ife2>-dy:
err=err-dy
x0=x0+sx
ife2<dx:
err=err+dx
y0=y0+sy
yieldx0, y0
classanalyse(object):
def__init__(self):
self.tmpPath="tmp/"
defanalyseImage(self, imageFullPath, xStart, yStart, xStop, yStop):
im=Image.open(imageFullPath)
printim.bits, im.size, im.format
pixelsInt= [im.getpixel((x,y)) forx,yinbresenham(xStart, yStart, xStop, yStop)]
indices=range(1, len(pixelsInt)+1)
pylab.plot(indices, pixelsInt)
my_dpi=80
#pylab.figure(figsize=(600/my_dpi, 500/my_dpi), dpi=my_dpi)
pylab.figure(1, figsize=(3.25, 3))
draw=ImageDraw.Draw(im)
draw.line([(xStart, yStart),(xStop, yStop)], fill=128)
deldraw
im.save(self.tmpPath+"line.png", "PNG")
#pylab.show()
pylab.savefig(self.tmpPath+"graph.png", dpi=my_dpi)
pylab.close()
#600x500
if__name__=="__main__":
xStart=170
yStart=10
xStop=170
yStop=220
an=analyse()
an.analyseImage("images/IR_0485.jpg", xStart, yStart, xStop, yStop)