Add more accurate edge detection

Replace straight Sobel in preprocessing with something approximating a
Canny edge detector, which allows the mask to be tighter around edges
and reduce texture effects better.