# From Iris Image to Embedded Code: System of Methods
## 3 Eye Segmentation Methods
### Base Radii Detection  
The algorithm simultaneously locates two iris boundaries as circle approximations: inner (pupil) \((x_{P},y_{P},r_{P})\) and outer (iris) \((x_{I},y_{I},r_{I})\) starting from the center \(\vec{c}\) (2). In this section, we set \((x_{C},y_{C})=\vec{c}\) as coordinate origin. Anti-gradient vector at the boundary of the dark circle and the direction to the circle center coincide or form a small angle. As the pupil and iris are both dark circles on the brighter background, one can state the following condition for pixels \(\vec{x}\) of their boundaries:  
\[\phi(\vec{x})=\arccos\frac{\vec{g}(\vec{x})\cdot\vec{x}}{\|\vec{g}(\vec{x}) \|\ \|\vec{x}\|}<\tau_{\phi}\,\,\,. \tag{4}\]We use a threshold value \(\tau_{\phi}=45^{0}\). Furthermore, the condition for gradient value (1) is applicable. Pixel \(\vec{x}\) satisfying the conditions (1), (4) probably belongs to the inner or outer boundary. Call it _candidate_. Define the set of candidate pixels as \(\Omega_{2}\):  
\[\Omega_{2}=\left\{\vec{x}:\phi(\vec{x})<\tau_{\phi},H(\|\vec{g}(\vec{x})\|) \geqslant(1-\tau_{\mathrm{s}})N\right\}\,. \tag{5}\]  
For each radius \(r\) a ratio of candidate count at this radius to the count of all pixels at this radius is estimated:  
\[\Pi(r)=\frac{\left|\{\vec{x}:\|\vec{x}\|\in[r-0.5,r+0.5),\vec{x}\in\Omega_{2} \}\right|}{\left|\{\vec{x}:\|\vec{x}\|\in[r-0.5,r+0.5)\}\right|}\,\,\,. \tag{6}\]  
If there is a dark circle of some radius \(\rho\) with the center near the coordinate origin its border pixels are likely to belong to the set \(\Omega_{2}\), and are likely to have distance \(\rho\) to the coordinate origin. Thus, \(\Pi(\rho)\) will be big, i.e., have local maximum. Other contours will not vote to the same radius of circular projection and will not form local maxima therein. The image plane is divided into four quadrants, left, right, top and bottom by the lines \(y=x\) and \(y=-x\). In each quadrant, a _sub-projection_ is calculated separately according to (6). Positions of local maxima on the right, left, top, and bottom sub-projections are:  
\[\mu_{\alpha}(n)=\arg\underset{n}{\mathrm{loc}}\max_{r}\Pi_{\alpha}(r)\,\,,\, \,\,\alpha=\{R,L,T,B\}\,\,. \tag{7}\]  
The quality of maxima is simply the value of histogram at the point  
\[q_{\alpha}(n)=\Pi_{\alpha}(\mu_{\alpha}(n))\,\,. \tag{8}\]  
If not occluded, each of the two circular contours (inner and outer borders) gives a local maximum in each sub-projection. Other maxima may arise due to occlusions such as eyelashes and eyelids or due to other details in eye images, including patterns of the iris itself. Combining local maxima positions (7) gives set of hypothetical pupils:  
\[ \begin{split}& x_{p}^{i,j}=\frac{1}{2}(\mu_{R}(i)-\mu_{L}(j))\,\,, \,\,\,i=\overline{1,n_{R}}\,\,,\,\,\,j=\overline{1,n_{L}}\,\,,\\ & y_{p}^{k,l}=\frac{1}{2}(\mu_{T}(k)-\mu_{B}(l))\,\,,\,\,\,k= \overline{1,n_{T}}\,,\,\,\,\,l=\overline{1,n_{B}}\,\,,\\ & r_{p}^{i,j,k,l}=\frac{1}{4}(\mu_{R}(i)+\mu_{L}(j)+\mu_{T}(k)+ \mu_{B}(l))\,\,.\end{split}  \tag{9}\]  
Qualities of combinations are also defined from values (8):  
\[q_{p}^{i,j,k,l}=\frac{1}{4}(q_{R}(i)+q_{L}(j)+q_{T}(k)+q_{B}(l))\,\,. \tag{10}\]  
Irises are estimated by just the same formulas:  
\[ \begin{split}& x_{l}^{i,j}=\frac{1}{2}(\mu_{R}(i)-\mu_{L}(j))\,\,,\,\,\,i= \overline{1,n_{R}}\,\,,\,\,\,j=\overline{1,n_{L}}\,\,,\\ & y_{l}^{k,l}=\frac{1}{2}(\mu_{T}(k)-\mu_{B}(l))\,\,,\,\,\,k= \overline{1,n_{T}}\,,\,\,\,l=\overline{1,n_{B}}\,\,,\\ & r_{l}^{i,j,k,l}=\frac{1}{4}(\mu_{R}(i)+\mu_{L}(j)+\mu_{T}(k)+ \mu_{B}(l))\,\,,\\ & q_{l}^{i,j,k,l}=\frac{1}{4}(q_{R}(i)+q_{L}(j)+q_{T}(k)+q_{B}(l) )\,\,.\end{split}  \tag{11}\]  
The nature of the pupil and iris imposes certain limitations on their locations and sizes. We use the following four inequalities: pupil size is not less than 15% of iris size and not more than 75% of iris size; center of the iris is inside pupil; pupil cannot be displaced too much from iris center.