Sobel derivatives in the 45 and 135 degree direction
Hi, From the documentation, the Sobel edge detector seems to work only for horizontal and vertical direction edges (by specifying 0,1 or 1,0). Is there any way to get diagonal edges (i.e. 45deg and 135deg) with cvSobel (not cvCanny)?
Thanks
UPDATE: Thanks for the suggestions! I can get what I need by rotating the image beforehand, but it is quite inefficient. I need to access the pixels for both the x-yand diagonal45-diagonal135 matrices, so by rotating the image, I incur the penalty of an extra pass over the pixels.
I've come across : sqrt((Ysin(alpha))^2 + (Xcos(alpha))^2) (where Y and X are derivatives in the y and x direction) which supposedly allows the calculation of the derivative in any direction given by alpha. However, when I try this, the results are different to when rotating the image by 45 degrees before hand. Is that expression correct? If not, how can I go about calculating the derivatives I need without rotating the image beforehand?
Many thanks.
For the 45 and 135, you want one of the "Kirsch" or "compass" operators. It's basically`
and the various symmetries. In general, what you can do is rotate the Sobel kernel with warpAffine instead of the image. Like turn the lightbulb instead of the ladder. For anything but the orthogonals and diagonals, I'd recommend using a larger kernel than 3x3 though to get good results.
Kind of like this