# A New Approach to Border Irregularity Assessment with Application in Skin Pathology
## 2 Material and Methods
### Determining the Epidermis Main Axis  
The epidermis main axis is a centerline of the epidermis base, i.e., the epidermal region with retes passed over (Figure 4). We determine the epidermis main axis to identify pixels being candidates for rete roots (as all roots of retes are located on that axis) and to distinguish between projections branching off towards the underlying skin layers and towards the stratum corneum (the outermost skin layer).  
A naive solution to determine the epidermis main axis would be to find the longest path in a graph \(G\) spanned on the skeleton of the epidermis. However, there are two problems with such an approach: (1) if holes are present in epidermis (e.g., due to partially merged retes) the longest path in \(G\) may not necessarily run along the epidermis \"outer\" edge (Figure 10a), and (2) simply taking the longest path in \(G\) would fail if there was a long rete near an edge of the epidermis region (Figure 10b).  
To address these issues, we firstly determine the two endpoints of the main axis by choosing the best path in a graph \(G_{f}\) spanned on the skeleton of epidermis region with holes filled (skeletonization is performed using the same procedure as described in Section 2.5), which ensures that \(G_{f}\) is acyclic and that the position of all leaves in \(G\) is retained in \(G_{f}\) (Figure 10b). We rank paths in \(G_{f}\) using the score including a penalty based on the depth of the path endpoints:  
\[\text{Score}(\pi)=\sum_{\epsilon_{i}\in\pi}w(e_{i})-(D(v_{0})+D(v_{n})) \tag{7}\]  
where \(\pi=(e_{1},\ldots,e_{p})\) is a path in a graph \(G_{f}\), \(w(e)\) is the weight of the edge \(e\) (here: number of pixels forming this edge), \(D(v)\) is the geodesic distance of \(v\) from the epidermis \"outer\" edge, and \(v_{0}\) and \(v_{n}\) are endpoints of \(\pi\). We consider all possible paths from all leaves in \(G_{f}\) and choose endpoints of the path with the highest score as the main axis endpoints \(v_{1}^{\epsilon}\) and \(v_{2}^{\epsilon}\) (Figure 10c). To determine the actual route of the main axis, we use [PERSON]'s algorithm to find the longest path between \(v_{1}^{\epsilon}\) and \(v_{2}^{\epsilon}\) in \(G\)[41]. Edges are weighted according to the mean depth of pixels \(p_{i}\) forming a given edge:  
\[w(e)=\sum_{p_{i}\in\epsilon}D(p_{i}). \tag{8}\]  
Figure 10: Issues when finding the epidermis main axis and their solutions: (**a**) holes in epidermis cause the longest path in \(G\) not to run along the epidermis outer edge, (**b**) the problem with holes can be resolved by locating main axis endpoints based on the analysis of the skeleton of a filled epidermis region yet long retes near ends of the epidermis region still cause the longest path in \(G\) to omit the last segment of the true main axis, (**c**) the problem with long retes can be resolved by ranking endpoints based on their depth (\(|\epsilon_{1}|-D(v_{1})>|\epsilon_{2}|-D(v_{2})\)), (**d**) endpoints determined using the \(G_{f}\) skeleton are also valid in \(G\), (**e**) simply taking the longest path between endpoints does not work, and (**f**) finding the shortest path when edges are weighted according to the sum of depth of pixels forming a given edge gives the proper result. In each step the computed main axis is marked as a thick solid line.  
It ensures that we choose a path running through the epidermis base.