6 from scipy
import signal
10 image
.outdir
= 'client_data'
12 imgfn
= 'halfdome_from_northdome.jpg'
14 host
,port
= "localhost",5020
16 server
= xmlrpclib
.ServerProxy("http://%s:%d"%(host
,port
))
17 available_methods
= server
.system
.listMethods()
19 print available_methods
21 print server
.system
.methodHelp('double')
22 print server
.system
.methodHelp('rot180')
23 print server
.system
.methodHelp('invert_color')
25 def wrap_server(f
,img
):
26 ''' Run server method f on img, marshalling and unmarshalling the img '''
27 return image
.unmarshal(f(image
.marshal(img
)))
29 ''' Methods to undo server methods '''
31 ''' Inverse of double '''
33 x
= signal
.resample(x
,x
.shape
[0]/2,axis
=0,window
='boxcar')
34 x
= signal
.resample(x
,x
.shape
[1]/2,axis
=1,window
='boxcar')
37 return image
.process_image(img
,fxchan
)
40 ''' Inverse of 180 degree rotation '''
44 return image
.process_image(img
,fxchan
)
46 def invert_color(img
):
47 ''' Inverse of flipping intensities '''
51 return image
.process_image(img
,fxchan
)
55 img
= image
.load_image(imgfn
)
59 image
.save_image('raw%d.jpg'%index
,img
)
61 img_mod
= wrap_server(srv
,img
)
63 image
.save_image('mod%d.jpg'%index
,img_mod
)
65 img_res
= cli(img_mod
)
67 image
.save_image('res%d.jpg'%index
,img_res
)
71 def runtest_client(cli
):
73 image
.save_image('raw%d.jpg'%index
,img
)
77 image
.save_image('res%d.jpg'%index
,img_res
)
80 runtest(server
.double
,halve_image
)
81 runtest(server
.rot180
,rot180
)
82 runtest(server
.invert_color
,invert_color
)