-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnectionCreater.py
More file actions
47 lines (36 loc) · 1.18 KB
/
ConnectionCreater.py
File metadata and controls
47 lines (36 loc) · 1.18 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
__author__ = 'Yakovlev.Nikolay'
__date__ = '06.06.2012'
import threading
import LinearFilter
import Matrix
import cPickle
from PIL import Image
kernel = [[-1, 1],]
class Connection(threading.Thread):
def __init__(self, User, Address):
self.User = User
self.Address = Address
threading.Thread.__init__(self)
def run (self):
while True:
Buffer = self.User.recv(1024)
FileToLoad = open(Buffer, "r")
NewLoadedObject = cPickle.Unpickler(FileToLoad)
ImageToOperate = NewLoadedObject.load()
ImageToOperate = Image.open(Buffer)
ImageToOperate.show()
ImageToOperate = ImageToOperate.convert("L")
ImageToOperate.show()
PixelsMatrix = Matrix.ImageToMatrix(ImageToOperate)
Result = LinearFilter.ApplyLinearFilter(PixelsMatrix, kernel)
print "Input"
Matrix.OutputMatrix(PixelsMatrix)
print ""
print ""
print "Kernel"
Matrix.OutputMatrix(kernel)
print ""
print ""
print "Output"
Matrix.OutputMatrix(Result)
self.sock.close()