As shown in Fig. 4 and algorithm 4 also searching 30 pixels on the left of P and 30 pixels on the right of P in order to find if there are green pixels; which are the door center pixels. If green pixels are found, then the Pcenter is put on an array that collect all the doors on the main path and their coordinates doorsArray along with the ―left‖ or ―right‖ values. But if the green pixels ware within the targetDoorMask, then the variable endPointVar is set as Pcenter along with the ―left‖ or ―right‖ values. Fig. 5, shows the path after finding center pixels for vertical and horizontal corridors. Fig. 6 presents the original Medial Axis after Applying the Algorithm on MATLAB R2009b Fig. 5: Path after Finding Center Pixels for Vertical & 

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

![0_image_2.png](0_image_2.png) Horizontal Corridors.

C. *Finding Turnings Centers* From applying the two above steps, almost all white pixels from the mask are removed, except white shapes that connected horizontal and vertical corridors, these shapes present the turning in the real world, and the nodes in the path graph. Since any pixel in these shapes cannot be either a center pixel or mid pixel (pixels between tow boarders), so these shapes where ignored by the conditions in the above two sections.

Using code in Algorithm-5, each turning shape is selected using floodfill8 function, then for each pixel in the shape if one of its neighbors (not all of them) is nonwhite colored pixel, then the pixel is a boarder pixel, it is removed. The algorithm repeats removing the turning boarder until finding a pixel that its eight neighbors' pixels colors are nonwhite, then this is a center pixel for the turning, that should be black colored and added to an array that contain all nodes of the main path named nodesArray.

The colors of these shapes are white, with at least two black pixels touching its boarder from more than one side, why? Because if there is one black pixel touching its boarder, then the corridor was not ignored by the conditions, (it is not a turning shape), and it has been already skeletonized in previous 

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

## Algorithm 5: Finding Turns Pseudo Code

The black pixels touching the turning shape are saved in an array for the current shape, before finding the center pixel for this shape. So when the center pixel is allocated the algorithm connect these pixels with the center pixel. 

## D. Labeling The Medial-Axis 

![0_Image_3.Png](0_Image_3.Png)

Fig. 7 shows labeled medial axis with nodes on red for simulation purpose. As mentioned before, doors are already labeled in the medial-axis, also the end point variable was found, so the algorithm (Algorithm-6) searches for the start point in the medial-axis from the set of pixels in startPointMask, these values is put on a variable startPointVar. 