I am working on detecting two lines on the edges of a road. This is the original frames. And this is the masked black and white frame. However, I am facing two main challenges: Fragmented Lines Due to Shadows: Some lines are harder to detect because of shadows, causing the lines to appear broken or fragmented. Noise from Road Details: There is a lot of detail on the road surface (e.g., textures, markings, or reflections) that I cannot eliminate, no matter how I adjust the thresholds. I have tried using color thresholding in the HLS color space and Sobel edge detection, but the results are still noisy. Do you have any suggestions for improving the detection of these lane lines while reducing noise and handling shadows? def white_tresh(frame): hls = cv2.cvtColor(frame, cv2.COLOR_RGB2HLS) kernel = np.ones((1,1), np.uint8) lower = np.array([0,120,0], dtype="uint8") upper = np.array([255,255,255], dtype="uint8") mask = cv2.inRange(hls, lower, upper) eroded = cv2.erode(mask, kernel, iterations=1) dilated = cv2.dilate(eroded, kernel, iterations=1) return dilated Continue reading...