Hi,
I need to find edges in an image in an arbitrary direction. I found sobel or other edge detectors
work for horizontal and vertical directions only. Is it possible to extend these to work for any
arbitrary direction?
Thanks in advance.
Sobel edge detector
Because it works with both horizontal and vertical directions, it is possible to make diagonals and any other direction.
L. Spiro
Thanks for your reply. I know how to make it work for horizontal, vertical and diagonal edges. Could you please add some more details for
an edge which is not either of these types?
Thanks for your reply. I know how to make it work for horizontal, vertical and diagonal edges. Could you please add some more details for
an edge which is not either of these types?
you have to combine vertical and horizontal detectors:
http://en.wikipedia.org/wiki/Sobel_operator
use Gx and Gy as described to compute vertical and horizontal gradients
then combine those to the gradient G= sqrt(Gx² + Gy²) or a approximated gradient G= |Gx|+|Gy| (much faster)
Thanks for your reply. I know how to make it work for horizontal, vertical and diagonal edges. Could you please add some more details for
an edge which is not either of these types?
The Sobel filter already handles all directions. There is nothing extra you have to do. The image I posted was made using a standard non-modified Sobel filter, which is in its full form in the link above.
L. Spiro
use Gx and Gy as described to compute vertical and horizontal gradients
then combine those to the gradient G= sqrt(Gx² + Gy²) or a approximated gradient G= |Gx|+|Gy| (much faster)
I do not agree. It will give me edges in horizontal and vertical directions. It's not for any arbitrary direction.
use Gx and Gy as described to compute vertical and horizontal gradients
then combine those to the gradient G= sqrt(Gx² + Gy²) or a approximated gradient G= |Gx|+|Gy| (much faster)
I do not agree. It will give me edges in horizontal and vertical directions. It's not for any arbitrary direction.
You didn’t even read the link he gave.
A Sobel operator has 2 kernels, one for each direction, and then they are combined to create a new direction from both of those directions (basically).
Look at almost every single image in that link.
Plus the image I provided at first.
It is obvious that a Sobel filter works with all directions. What do you think a diagonal line is? It’s a little bit of horizontal mixed with a little bit of vertical.
I don’t know what else you want us to say.
L. Spiro
Hi L Spiro,
My intention is not to detect edges in all directions. Say, for a given direction u,
I want to detect edges that are alligned with this direction only. This u can be
anything.
You completely did not say that at the beginning.
In any case, use a Sobel filter to get the Gx and Gy values.
The direction you want to find should be stored as a CVector2( X, Y ).
Create a new CVector2( Gx, Gy ) and normalize it.
The magnitude in the direction CVector2( X, Y ) is:
CVector2( X, Y ) DOT CVector2( Gx, Gy ).
Done and done.
L. Spiro