# Introduction

• The polar coordinates (r, θ) of a point on the Euclidean plane whose origin is denoted by point 'O' are defined as:
• r: the distance between point 'P' and the point 'O'.
• θ: the angle between the line segment and the axis x.

# Synopse

• g = iapolar(f, domain, thetamax=2*pi)
• g: Image converted to polar coordinates.
• f: Image (cartesian coordinates). Input image.
• domain: Domain image
• thetamax: Float. Default = 2*pi, Max theta in the transformation.

# Description

• Function to convert 2D image in cartesian coordinates to polar coordinates. The origin is at the center of the image and the transformation is applied to the larger square centered in the image.
```01. from numpy import *
02.
03. def iapolar(f, domain, thetamax = 2 * pi):
04.
05.     from ia636 import iainterpollin
06.     f = array(f)
07.     m,n = f.shape
08.     dm,dn = domain
09.     Ry,Rx = floor(array(f.shape)/2)
10.
11.     b = min(Ry,Rx)/dm
12.     a = thetamax/dn
13.
14.     y,x = indices(domain)
15.
16.     XI = Rx + (b*y)*cos(a*x)
17.     YI = Ry + (b*y)*sin(a*x)
18.
19.     g = iainterpollin(f, array([YI.ravel(), XI.ravel()]))
20.     g.shape = domain
21.
22.     return g```

# Examples

## Example 1

```01. import ia636
02.
03. f = array([[1,0,0,0,0,0],
04.            [0,0,0,0,0,0],
05.            [0,0,0,1,0,0],
06.            [0,0,0,0,0,1],
07.            [0,0,0,0,0,0]])
08.
09. g = ia636.iapolar(f, (6,6))
10.
11. print g```
```[[ 1.          1.          1.          1.          1.          1.        ]
[ 0.66666667  0.59277072  0.59277072  0.66666667  0.59277072  0.59277072]
[ 0.33333333  0.28176649  0.28176649  0.33333333  0.28176649  0.28176649]
[ 0.          0.0669873   0.0669873   0.          0.0669873   0.0669873 ]
[ 0.          0.          0.          0.          0.          0.        ]
[ 0.          0.          0.          0.          0.          0.        ]]
```

## Example 2

```1. f = adreadgray("cameraman.pgm")
2. adshow(f, "Figure a) - Original Image")
3. g = ia636.iapolar(f,(250,250))
4. adshow(g, "Figure b) - Image converted to polar coordinates, 0 to 2*pi")
5.
6. g = ia636.iapolar(f,(250,250), pi)
7. adshow(g, "Figure c) - Image converted to polar coordinates, 0 to pi")```

## Example 3 - non square image

```1. f = adreadgray('astablet.tif')