Added image processing to extract gridlines