View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Sobel edge detector

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

9 replies to this topic

### #1udvat  Members

Posted 18 February 2013 - 09:35 PM

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, 18 February 2013 - 10:20 PM.

### #2L. Spiro  Members

Posted 18 February 2013 - 11:45 PM

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, 19 February 2013 - 06:09 AM.

### #3udvat  Members

Posted 20 February 2013 - 12:17 AM

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?

### #4DDoS  Members

Posted 20 February 2013 - 08:27 AM

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)

### #5L. Spiro  Members

Posted 20 February 2013 - 07:13 PM

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, 20 February 2013 - 07:16 PM.

### #6udvat  Members

Posted 20 February 2013 - 07:14 PM

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.

### #7L. Spiro  Members

Posted 20 February 2013 - 07:21 PM

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, 20 February 2013 - 07:22 PM.

### #8udvat  Members

Posted 20 February 2013 - 07:25 PM

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.

### #9L. Spiro  Members

Posted 20 February 2013 - 07:29 PM

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, 20 February 2013 - 11:01 PM.

### #10udvat  Members

Posted 20 February 2013 - 11:06 PM

Thank you. This is what I was looking for.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.