A linking algorithm to fill gaps between edge segments is presented. The gap filling operation is performed in an iterative manner rather than a single step. During each iteration, the noises are also removed gradually. The proposed algorithm starts with connecting the tip ends of two (line or curve) segments with a line segment and then tries to modify the resulting segment by straight-line fitting. The two major phases of the algorithm are detailed step by step. The advantages of using the algorithm are also discussed.