In [30]:
%matplotlib inline

import cv2
import numpy as np
import matplotlib.pyplot as plt

image = cv2.imread('003/eye.png')

center = (376, 184)
iris_radius = 115

drawing = np.copy(image)

cv2.circle(drawing, center, 3, (0, 255, 0), -1)
cv2.circle(drawing, center, iris_radius, (0, 255, 0), 1)

plt.figure(figsize=(10, 5))
plt.imshow(drawing, cmap='gray')
Out[30]:
<matplotlib.image.AxesImage at 0x1117f5a10>
In [25]:
nsamples = 360
samples = np.linspace(0, 2 * np.pi, nsamples)[:-1]

polar = np.zeros((iris_radius, nsamples))

for r in range(iris_radius):
    for theta in samples:
        x = r * np.cos(theta) + center[0]
        y = r * np.sin(theta) + center[1]
        
        polar[r][theta * nsamples / 2.0 / np.pi] = image[y][x][0]

plt.figure(figsize=(10, 5))
plt.imshow(polar, cmap='gray')
Out[25]:
<matplotlib.image.AxesImage at 0x110fc0990>
In [ ]: