2 import SimpleXMLRPCServer
5 from scipy
import signal
9 image
.outdir
= 'server_data'
11 class ImageManipulation(object):
15 def __server_method(self
,imagestr
,fxchan
):
16 ''' Generic server method for processing an image, marshalling, saving data products '''
17 x
= image
.unmarshal(imagestr
)
18 image
.save_image('raw%d.jpg'%(self
.log_index
),x
)
20 y
= image
.process_image(x
,fxchan
)
22 image
.save_image('final%d.jpg'%(self
.log_index
),y
)
26 return image
.marshal(y
)
28 def double(self
,imagestr
):
29 ''' Double size of an image by assuming image is band limited '''
31 x
= signal
.resample(x
,x
.shape
[0]*2,axis
=0,window
='boxcar')
32 x
= signal
.resample(x
,x
.shape
[1]*2,axis
=1,window
='boxcar')
35 return self
.__server
_method
(imagestr
,fxchan
)
37 def rot180(self
,imagestr
):
38 ''' Rotate image by 180 degrees '''
42 return self
.__server
_method
(imagestr
,fxchan
)
44 def invert_color(self
,imagestr
):
45 ''' Flip intensities '''
49 return self
.__server
_method
(imagestr
,fxchan
)
51 host
,port
= "localhost",5020
53 server
= SimpleXMLRPCServer
.SimpleXMLRPCServer((host
,port
),allow_none
=True)
54 server
.register_instance(ImageManipulation())
55 server
.register_multicall_functions()
56 server
.register_introspection_functions()
58 print "Server running on ",host
,port
59 server
.serve_forever()