This study presents a fully automated railhead detection method based on a direct image processing algorithm for use on a railway track. This method functions at a much faster pace than artificial intelligence algorithms that process rail images on embedded systems or low-power devices, as it does not require the use of significant computing resources. With the use of this method, railheads can be analyzed to identify the presence of cracks and other defects. We converted color images to halftone images, performed histogram equalizations to improve the contrast, applied a Gaussian filter to reduce the presence of noise, utilized convolutional filters to extract any vertical and horizontal lines, applied the Canny method and Sobel filters to refine the boundaries of the extracted lines, applied the Hough transform technique to extract lines belonging to the railhead images, and identified the segments with the highest brightness values to process the images of the railheads under study. The method of railhead separation described in this article will allow for further comprehensive diagnostics of the condition of rail threads to ensure the safe and sustainable operation of railway transport. The implementation of intelligent maintenance systems and effective monitoring of railway track conditions can reduce the negative impact on the environment and contribute to the advancement of rail transport as a sustainable, safe, and more environmentally friendly mode of transportation.