Image analysis depends critically on the detection of junctions (boundaries) between the different features depicted. Many different approaches to this problem have been tried, some of which are referred to and discussed in this paper. The procedure proposed here is based on local fits of suitable templates to detect the junctions, which in turn are used to identify the different features in the picture. The underlying mathematical theory is given in detail, and several examples of actual pictures are presented. A computer program, Kona, that implements the procedure used in the paper has been published separately [1].