Ask Your Question
1

GaussianBlur parameter bounds

asked 2018-10-22 15:26:30 -0500

dkeidel gravatar image

I want to apply a GaussianBlur to my image before I attempt to detect edges. I have been reading the openCV documentation for GaussianBlur, in particular what values are possible for the parameters to this function. The documentation outlines the parameters that are needed, however, it does not indicate what the upper and lower bounds are for each.

My question to the group is what are the limits on these parameters, in particular, the following:

  1. sigmaX - lower limit looks to be zero, but not sure about the upper limit
  2. sigmaY - lower limit looks to be zero, but not sure about the upper limit
  3. ksize - kernel size - curious what reasonable kernel sizes should be

For border type I am assuming the values can be:

BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT, BORDER_WRAP, BORDER_REFLECT_101, BORDER_TRANSPARENT, BORDER_REFLECT101, BORDER_DEFAULT, BORDER_ISOLATED

edit retag flag offensive close merge delete

Comments

The sigma are the standard deviation in the X and Y direction, and so what is the upper bound for the standard deviation? I'm no statistics master, but from what I know, there is no limit.

sjhalayka gravatar imagesjhalayka ( 2018-10-22 15:59:14 -0500 )edit

@sjhalayka thank you for your response. Do you have a suggestion of what might be a reasonable value to not exceed from your experience? Also, any advice on kernel sizes?

dkeidel gravatar imagedkeidel ( 2018-10-22 19:41:43 -0500 )edit

I don't have a lot of experience with Gaussian blur. From what I understand, the sigma are calculated from the kernel size if you leave the sigma parameters as 0.

On the other hand, I would try standard deviations of 1, 2 and 3 just to see what happens. Basically the standard deviation defines the `hilliness' of the filter. A larger standard deviation leads to a more spread out hill.

Have a look at:

https://en.wikipedia.org/wiki/Standar...

The red distribution has a standard deviation of 10 (very hilly), and the blue distribution has a standard deviation of 50 (less hilly). You can also look at it as a measure of blurriness: the lower the standard distribution, the more focused (less blurry) the filter is.

sjhalayka gravatar imagesjhalayka ( 2018-10-22 19:57:09 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2018-10-22 21:55:30 -0500

sjhalayka gravatar image

updated 2018-10-22 22:43:18 -0500

The following code, in C++, shows the difference between a standard deviation of 0.001 and 1.0.

GaussianBlur(image, blurred_1, Size(5, 5), 0.001, 0.001);
GaussianBlur(image, blurred_2, Size(5, 5), 1.0, 1.0);

Here is an image of the output. Notice that where the standard deviation of 0.001, there is practically no blur. This is because the hill is so tall and narrow that the only sample that counts is the one in the centre of the kernel -- which leaves that pixel practically untouched. Where the standard deviation is 1.0, the blur is noticeable, because the hill is so much shorter and wider. For very large standard deviation, the hill is practically zero in height, which makes for a blur based on the average of the pixel and its surrounding neighbours (that is, neighbours defined by the kernel size). So there's your limiting case, which is met when standard deviation goes to infinity.

image description

edit flag offensive delete link more

Comments

1

@sjhalayka thank you for the very detailed explanation! I now have a better understanding of how the standard deviation value and kernel size affect the blur. Very helpful!

dkeidel gravatar imagedkeidel ( 2018-10-23 11:50:52 -0500 )edit

@dkeidel -- No problem. Please upvote my answer and mark it as correct (click on the check mark). :)

sjhalayka gravatar imagesjhalayka ( 2018-10-23 12:35:43 -0500 )edit

@dkeidel -- It looks like GaussianBlur handles sigma of infinite value. :)

double upper_bound = numeric_limits<double>::infinity();

PS. Thank you so much for voting and marking the answer as correct!

sjhalayka gravatar imagesjhalayka ( 2018-10-23 13:03:12 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-10-22 15:26:30 -0500

Seen: 88 times

Last updated: Oct 22 '18