Abstract. Optimized the binary image morphological dilation algorithm by run length encoding with the optimization features in background redundant and intersection and union simple operation, the Run Length Encoding-Morphological Dilation optimized algorithm had been proposed. The track contour binary image was processed by morphological dilation with the optimized algorithm. Compared analysis based on the image processing result and the speed before and after optimization. The edge burr and disconnection phenomenon can be removed by the optimized algorithm. The processing result of the track contour single frame image increased 5 times. The detection accuracy of the track visual inspection system can be improved to 20 points per meter.