Ask Your Question
0

Sobel function argument

asked Feb 6 '13

eyal gravatar image

updated Oct 12 '0

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

Preview: (hide)

1 answer

Sort by » oldest newest most voted
3

answered Feb 7 '13

Michael Burdinov gravatar image

updated Feb 7 '13

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.

Preview: (hide)

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 (Feb 7 '13)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.

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

eyal gravatar imageeyal (Feb 7 '13)edit

Question Tools

Stats

Asked: Feb 6 '13

Seen: 810 times

Last updated: Feb 07 '13