A new classification of digital curves into boundary curves and visual curves of different thickness is suggested. A fast algorithm for recognizing digital straight line segments in boundary curves is presented. The algorithm is applied to encode the boundaries of homogeneous regions in digitized images. The code is economical and enables an exact reconstruction of the original image.