Ask Your Question
0

Sobel function argument

asked 2013-02-06 16:26:30 -0600

eyal gravatar image

updated 2020-10-12 07:53:00 -0600

Hi All,

Im new to OpenCV and I'm trying for the past hour to understand what is the scale and delta input argument to cv::Sober function.

Can anyone help me?

Thank u in advance

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
3

answered 2013-02-07 01:02:51 -0600

Michael Burdinov gravatar image

updated 2013-02-07 01:46:20 -0600

Documentation of Sobel function is prety clear on this:

"scale – optional scale factor for the computed derivative values; by default, no scaling is applied."

"delta – optional delta value that is added to the results prior to storing them in dst."

The reason why those arguments are part of the function is that type of image that stores the derivative may not be enough for whole range of values. For example: assume you are calculating derivative of CV_8U image with default kernel size. Resulting values of derivatives will be in range between -1024 and 1024. You may want (for various reasons) to stores derivatives in image of the same type, i.e. CV_8U. This means that all negative values will be cropped to 0, and all values above 255 will be cropped to 255. To pervent this crop you may set scale to 0.125 and delta to 128, so that all results will fall in range between 0 and 255.

edit flag offensive delete link more

Comments

First of all thank u very much for your answer!!

now I see why scale and delta are needed. But how do I know the output ranges if the derivatives I mean how do u know that derivatives of CV_8U map to [-1024,1024] ??

eyal gravatar imageeyal ( 2013-02-07 07:29:32 -0600 )edit

You should check the kernel that is used. 3x3 Sobel kernel is [[-1, -2, -1], [0, 0, 0], [1, 2, 1]]. Maximum value for it will be 1 * 255 + 2 * 255 + 1 * 255 = 1020. And minimum value is -1 * 255 - 2 * 255 - 1 * 255 = - 1020.

Michael Burdinov gravatar imageMichael Burdinov ( 2013-02-07 07:52:53 -0600 )edit

I see...Thank u , you the best :)

eyal gravatar imageeyal ( 2013-02-07 09:28:12 -0600 )edit

Question Tools

Stats

Asked: 2013-02-06 16:26:30 -0600

Seen: 655 times

Last updated: Feb 07 '13