Line direction detection using grayscale value stdevs