With the aid of TI CCS4.0 software development platform, using C language, a kind of track detection algorithm based on gray image is implemented on DM642. The detailed design and implementation steps are introduced. First, image median filtering, vertical sobel edge enhancement, and using the threshold segmentation method for binarization processing. Then search and mark connected domain on the basis of the binary images and prepare for extraction the connected domain about rail. Finally extract and fill around tracks to get a image containng only track region. The experimental results show t...