from scipy import * import Image def arr2img(r,g=None,b=None): imr=Image.new("L", (r.shape[1],r.shape[0])) imr.fromstring(r.astype(UnsignedInt8).tostring()) imr=Image.Image()._makeself(imr) if g==None: return imr img=Image.new("L", (g.shape[1],g.shape[0])) img.fromstring(g.astype(UnsignedInt8).tostring()) img=Image.Image()._makeself(img) imb=Image.new("L", (b.shape[1],b.shape[0])) imb.fromstring(b.astype(UnsignedInt8).tostring()) imb=Image.Image()._makeself(imb) return Image.merge("RGB",(imr.im,img.im,imb.im)) y,x = mgrid[-2.5:2.5:500j,-2.5:2.5:500j] z=x+1.j*y f=log(z*z-1.0) fr = real(f) fi = imag(f) gr = (floor(fr*100./2./pi).astype(UnsignedInt8))%2 gi = (floor(fi*100./2./pi).astype(UnsignedInt8))%2 g0 = gi*0 im = arr2img( 255*gr,255* gr, 255*gi ) im.save("cassini.png")