# Sobel edge detector

This topic is 2124 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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?

Edited by Michael Tanczos

##### Share on other sites

Because it works with both horizontal and vertical directions, it is possible to make diagonals and any other direction.

L. Spiro

Edited by L. Spiro

##### Share on other sites

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?

##### Share on other sites

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)

##### Share on other sites

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

Edited by L. Spiro

##### Share on other sites

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.

##### Share on other sites

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.

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

Edited by L. Spiro

##### Share on other sites

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.

##### Share on other sites

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

Edited by L. Spiro

##### Share on other sites

Thank you. This is what I was looking for.

1. 1
2. 2
Rutin
21
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633736
• Total Posts
3013603
×