Blurs an image using a Gaussian filter. The function convolves the source image with the specified Gaussian kernel.
cv2.GaussianBlur(src, ksize, sigmaX[, dst[, sigmaY[, borderType]]]) → dst
cv2.CV_8U
, cv2.CV_16U
, cv2.CV_16S
, cv2.CV_32F
or cv2.CV_64F
.sigmaX
and sigmaY
.src
.sigmaX
. Default is set to 0.cv2.BORDER_*
): Pixel extrapolation method. Default is BORDER_DEFAULT. Choose from:
This filter works by producing a window of size ksize
that is examined surrounding each pixel in the image. A two-dimensional convolution matrix over this window is created using a Gaussian distribution from the center point (the pixel under consideration). This distribution gives the center pixel the heaviest weight, with smaller weights given as we move further outwards. Essentially, this is acting as a weighted average for the center pixel to be influenced by its neighbors, with closer neighbors having a larger influence. As sigmaX
and sigmaY
get smaller, the Gaussian distribution's peak becomes narrower, meaning that the image will be less blurred as further pixels receive smaller weights in the weighted average. Similarly, reducing the window size (ksize
) produces an image with less blur since we are considering only neighbors that are closer to the center pixel.
ksize = (0,0)
, then ksize
is computed from sigmaX
and sigmaY
.sigmaX
and sigmaY
are both 0, then sigmaX
and sigmaY
are computed from ksize
.ksize
, sigmaX
, and sigmaY
.copyMakeBorder
, otherwise the default value is set to 0.