Spherical coordinate

Sypnose

Spheric transformation.

  • g = sphericalTransformation(f,domain)
    • g: Image. Output image
    • f: Image. Output image
    • domain: Final Domain
 1 from ia636 import *
 2 from numpy import *
 3 
 4 def iaspherical(f,domain):
 5     f = array(f)
 6     z,r,c = f.shape
 7     dz,dr,dc = domain
 8     Rz = floor(z/2)
 9     Ry = floor(r/2)
10     Rx = floor(c/2)
11 
12     b = min(Rz,Ry,Rx)/dz
13     a = pi/dr
14     c = pi/dc
15 
16     zi,xi,yi = indices(domain)
17 
18     X = Rz+(a*zi)*sin(b*yi)*cos(c*xi)
19     Y = Ry+(a*zi)*sin(b*yi)*sin(c*xi)
20     Z = Rx+(a*zi)*cos(c*xi)
21 
22     g=iainterpollin(f,array([Z,Y,X]))
23 
24     return g

Example

 1 from numpy import *
 2 
 3 f = mmreadgray("courseIA369O1S2011/jan_15/raio.jpg")
 4 adshow(f, title ='image')
 5 g = zeros((150,f.shape[0],f.shape[1])) #pseudo 3d
 6 g[:] = f
 7 F = iaspherical(g,(150,f.shape[0],f.shape[1]))
 8 adshow(iamosaic(F,F.shape[0],1,10,'XY'),'xy')
 9 adshow(iamosaic(F,F.shape[0],1,10,'XZ'),'xz')
10 adshow(iamosaic(F,F.shape[0],1,10,'YZ'),'yz')
ERROR execute

------------------------------------------------------------
*** Exception while evaluating code:
  File "<string>", line 8, in <module>
TypeError: iamosaic() takes at most 3 arguments (5 given)

------------------------------------------------------------

image

Equation