Combine for loops in Sobel kernel.