The algorithm starts finding the boarder of the main path, where the boarder is any white pixel that at least one of its neighbors is not white pixel. All the boarder pixels are put on an array border Array. Algorithm 1 presents the Pseudo code finding boarder pixels.

Algorithm 1 Pseudo code finding boarder pixels B. *Finding Central Pixels for Corridors* There are two types of corridors for the main path, one of them is horizontal that includes typical horizontal and semi horizontal corridors, and the other one is vertical that includes typical vertical and semi vertical corridors.

The algorithm loops the grouped mask twice, one for finding center pixels for vertical corridors and the other loop for finding center pixels for horizontal corridors.

1. *Vertical Corridors* Fig. 3 shows the path after finding center pixels for vertical 

![0_image_0.png](0_image_0.png)

corridors only using MATLAB R2009b.

Fig. 3: the Path for Vertical Corridors Only
As shown in Algorithm 2, starts from the first boarder pixel in the mask, looping mask row by row, for the left boarder pixel (white boarder that its left neighbor pixel is nonwhite colored).

//for vertical and semi vertical paths for each boarder pixel in boarderArray //assure that it is a bottom boarder if color(p4) !=ffffff then for each p in boarderArray if y(pbottom) == y(p) and x(pbottom)!=x(p) and color(pbottom) 
!=ffffff and pbottom is not scanned and maxboarder>=(pbottom)-x(p) 
>minboarder then pcenter = (y(p),(x(pnottom)-x(p))/2) pbottom scanned
 //checking for doors if any pixel between p and p(x(p)-20) ε doors then topDoors[i]=pcenter end if if any pixel between p and p(x(p)-20) ε targetDoor then targetTopDoors[i]=pcenter end if if any pixel between pbottom and p(y(pbottom)+20) ε doors then bottomDoors[i]=pcenter end if if any pixel between pbottom and p(y(pbottom)+20) ε targetdoor then targetBottomDoors[i] = pcenter end if for each pixel between p and pbottom including them if color(px) == ffffff then arraytoRemove[j]=px j++
 end if end for break the current loop end if if maxBoarder < x(pbottom) -x(p) then for each pixel between p and pbottomk including them bottomMaskShapr= px end for end if end for end if end for Algorithm 2 Presents Pseudo Code for Vertical Corridors The algorithm start searching for its right boarder, by increasing the x value of the left pixel until it reaches the right boarder (white boarder that its right neighbor pixel is nonwhite colored), if the distance between these two pixels is smaller than minBoarder value (the value that the corridor must be greater than) then all pixels between them including them are removed. And if the distance between these two pixels is greater than maxBoarder value (the value that the corridor must be smaller than) then these pixels are ignored for now. 

Otherwise the center pixel of these two side boarders is calculated and the Pcenter is then black colored, as equation 1.

Pcenter = (Y (P), X (Pright) - X (P) / 2) … equation 1 Where Pcenter means the pixel in the center, Y (P) means the value of Y coordinator of any Pixel, X (P) means the value of X coordinator of any Pixel, and the X (Pright) means the value of X coordinator of the pixel on the right of the center pixel. Then the algorithm puts the white pixels between the side boarders including the side boarders on an array named arraytoRemove, to delete this array later.

## 2. Horizontal Corridors

Same as vertical scanning, as shown in Algorithm 3, starting from the first boarder pixel in the mask, looping mask 