# Fully Parallel Homological Region Adjacency Graph via Frontier Recognition
## 6 Results  
A complete implementation of the algorithm that computes the _HomDuRAG_ has been performed in MATLAB/OCTAVE that serves to check the results for different types of images. The main script (script_dual_RAG_images.m) can load one of these sets of images at each time: (1) a synthetic image written in a matrix; (2) several random synthetic square images having a different number of colors and densities; (3) several synthetic square images containing an object with the longest perimeter; and (4) a real image. After having loaded and checked an image, this main script launches dual_RAG_main_stages.m, which computes and checks the _HomDuRAG_ by executing these stages in order:  
(1) Script to compute jump distances for the 0-cells (dual_RAG_Ocell_determination.m). (2) Script to extract _HomDuRAG_ expressed as a table \(T\) (\(T\_crosses\) in the code) called dual_RAG_counting_crit_cells_v1.m. After computing _HomDuRAG_, a mechanism to check the correctness of those results concentrated in \(T\) has been written. First, frontiers are fused (script fusing_frontier_CCs.m) as they were connected components (CCs). This fusion process returns the number of frontier CCs that contain more than one region (\(n_{1,poly}\)). With this number, homological representative cells of the regions embedded in the image can be completely derived using the Euler formula and the following calculation. The Euler number of the whole set of open separated objects is 1 (because no object intersection exists). In addition, the sum of all the Euler numbers can be calculated through the representative cells and can be expressed as \(n_{2}-n_{1}+n_{0}=1\), \(n_{k}\) being the number of representative cells of dimension \(k\) (which can be CCs or holes). Clearly, \(n_{0}\) can be computed via the table \(T\); it is the total number of crosses with three or four pixels with different attributes (here described as \(n_{0,3}\) and \(n_{0,4}\), respectively) plus the number of holes composed of only one frontier (called \(n_{0,2}\) in this work because the southeast-most 0-cell representative of any of these holes has only two cobounds). With respect to \(n_{1}\), it can be composed of four types of homological representative cells:  
(a) Those corresponding to holes composed of only one frontier (that is, \(n_{1,mono}\), which is equal to \(n_{0,2}\)). Figure 10: (Left): Final labels of the frontiers for the image in Figure 1. Orange cells represent cross/hole representatives; the rest of colored cells correspond to 0-cells inside regions. (Center): Final _HomDuRAG_ expressed as a table for the image in Figure 1. The first column holds cross addresses. The next four columns hold the adjacencies with other crosses (or with themselves in the case of a hole). The last four columns hold the pixel colors around each cross. (Right): _HomDuRAG_ of this table. (b) Those that must appear in regions that are outside each of these previous mono-frontier holes; \(n_{1,reg,mono}\). Note that if the image border is a cycle, it cannot be counted in \(n_{1}\) because this homological representative cell of dimension 1 would reside outside the whole image; thus, \(n_{1,reg,mono}=n_{1,mono}-1\). On the contrary, \(n_{1,reg,mono}=n_{1,mono}\). (c) Those that must emerge in regions that are outside each frontier CC containing more than one region. Again, if the image border belongs to one of these frontier CCs, the corresponding homological representative cell of dimension 1 would reside outside the whole image; thus, \(n_{1,reg,poly}=n_{1,poly}-1\), being \(n_{1,poly}\), the value calculated by the script fusing_frontier_CCs.m. On the contrary, \(n_{1,reg,poly}=n_{1,poly}\). (d) Each frontier itself not being a cycle represents a homological representative cell of dimension 1, which can be computed as half of the number of frontiers that go out of the crosses; that is, \((3\times n_{0,3}+4\times n_{0,4})/2\). Dividing by two is necessary because the cobounds of crosses are repeated twice, or, correspondingly, each frontier has two bounds.