Sign in to follow this  
udvat

Sobel edge detector

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?
 
Thanks in advance.

Edited by Michael Tanczos

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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.

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.

 

300px-Valve_sobel_%283%29.PNG

 

200px-Bikesgraysobel.jpg

 

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this