The negation step seems superfluous. The edge detection filter can't detect edges in a regular photo but can in a negative?
And since it's the magnitude of the gradient that Sobel finds, Sobel(Invert(img)) is mathematically equivalent to Sobel(img). The invert step is essentially an expensive noop.