In image boundary detection, the common method is the threshold based on image segmentation. Traditional fixed grey threshold based on segmentation results in high false alarm and misses alarm rate. A framework of switch gaps detection based on CMOS plane is constructed, which focuses on the location and monitoring of switch gaps in high-speed railways. By the information theory, adaptive threshold selection and edge detection algorithm based on Shannon entropy are proposed. This algorithm shows low computation complexity and is adaptive to various contrast ratio of image with noise. It improves the detection precision and reliability. The efficiency of the proposed framework and the edge detection algorithm is verified by field data from Changsha Station in Beijing-Guangzhou high speed railway. The experiment results show that the efficiency of the proposed framework and edge detection algorithm based on Shannon entropy is improved.