mathimage-processingcomputer-visionderivativesobel

Calculating the diagonal Sobel operator


I was trying to calculate the diagonal (bottom left to top right) Sobel operator but couldn't manage to do it. I know what it should look like, but getting there im not able to.

So thanks in advance if some kind soul can explain it.

I already tryed to synthesise it out of the horizontal and vertical Sobel operators, but got stuck in multiple wrong results.


Solution

  • The x and y derivatives together form the gradient vector. Using the Sobel operator you can compute these two derivatives.

    Projecting the gradient vector onto a unit vector you can find the directional gradient. Your desired direction corresponds to the unit vector [sqrt(2), -sqrt(2)]. The projection is a dot product. Thus, your desired derivative image corresponds to:

    dx = sobel(img)
    dy = sobel(img)
    out = sqrt(2)*dx - sqrt(2)*dy
    

    Knowing that the Sobel operator is applied with a convolution, and that the convolution is associative and linear, we can see that the operations above correspond to a single convolution with a kernel formed by sqrt(2)*sobel_x - sqrt(2)*sobel_y. We can compute this kernel:

             0    2.8284    2.8284
       -2.8284         0    2.8284
       -2.8284   -2.8284         0   
    

    Of course you could choose to normalize the kernel differently, the magnitude of the Sobel operator is wrong anyway. So you could instead use for example

         0     1     1
        -1     0     1
        -1    -1     0