Patryk Ziemkowski
Patryk Ziemkowski

Reputation: 1510

How to create Gaussian kernel and use it as filter in opencv

I am developing road line detection algorithm with OpenCv and found some quote and I can't understand its fragment.

Could you explain it how would i achieve such thing in OpenCv?

Here is the quote:

The image is then filtered by a two dimensional Gaussian kernel. The vertical direction is a smoothing Gaussian, whose σy is adjusted according to the required height of lane segment (set to the equivalent of 1m in the image). The horizontal direction is a second-derivative of Gaussian, whose σx is adjusted according to the expected width of the lane.

How can i prepare such kernel? getDerivKernel doesn't seem to allow me to set its σx or σy.

Thank you in advance.

Upvotes: 1

Views: 8619

Answers (2)

john k
john k

Reputation: 6615

I believe OpenCV has a function to do exactly this.

 Mat getGaussianKernel(int ksize, double sigma, int ktype=CV_64F)

see http://docs.opencv.org/modules/imgproc/doc/filtering.html

Upvotes: 3

ArtemStorozhuk
ArtemStorozhuk

Reputation: 8725

Just use GaussianBlur method. From documentation:

sigmaX - Gaussian kernel standard deviation in X direction.

sigmaY - Gaussian kernel standard deviation in Y direction; if sigmaY is zero, it is set to be equal to sigmaX, if both sigmas are zeros, they are computed from ksize.width and ksize.height, respectively (see "getGaussianKernel" for details); to fully control the result regardless of possible future modifications of all this semantics, it is recommended to specify all of ksize, sigmaX, and sigmaY.

Upvotes: 2

Related Questions