The importance given to the safety of railway transportation and the maintenance of railway components is also increasing as railway transportation is widespread all over the world. The most basic measure is to take to reduce railway accidents is to check the railway components at regular intervals. The identification of railways with advanced technology, unlike traditional methods, has made a great demand in recent years. Regular inspection of rail, railway component, traverse, turnout crossing and level crossing at regular intervals will prevent possible accidents. In this study, it has ensured that railway components have been diagnosed using contact image processing based techniques. The proposed approach consists of preprocessing, morphological feature extraction, fault and deficiency detection steps. The railway component which is missing after the fixing of the connecting element and the rail line is determined. The lack of railway components can jeopardize the safety of railway transportation. After the rail track has been detected, the existing faults on the rail surface have been determined. The operations applied in rail surface diagnosis include image padding, average filter, difference of images, feature extraction and defects labeling. The proposed method is performed through the interface created with Emgu CV library in Visual Studio and high accuracy results are obtained.