sobel: Clean up the implementation

This implementation also makes the result compatible with the classic
GIMP plug-in.