Mean filtering

Time:2021-9-17

Mean filtering

The pixel value of any point is the average of the surrounding n x N pixel values

Example: new pixel value of red dot = sum of pixels in blue background area divided by 25

New pixel values for red dots=

((197 + 25 +106 +156 +159)+(149 + 40 + 107 + 5 + 71) + (163 + 198 + 226 + 223 + 156) + (222 + 37 + 68 + 193 + 157) + (42 + 72 + 250 + 41 + 75)) /25

Mean filtering

Function blur

Processing result = cv2.blur (original image, core size)

Core size: tuple in the form of (width, height)

r = cv2.blur(o,(5, 5))

After mean filtering, the image is smoother

Gaussian filtering

Make adjacent pixels more important. The weighted average value is calculated for the surrounding pixels, and the closer pixels have a larger weight value

Mean filtering

Gaussian blur function

dst = cv2.GaussianBlur (src, ksize, sigmaX)

median filtering

The adjacent pixels are arranged according to the size, and the value in the middle of the arranged pixel set is taken as the pixel value after median filtering

Mean filtering

Medianblur function

dst = cv2.medianBlur(src, ksize)

SRC, source file

Ksize, core size, must be an odd number greater than 1, such as 3, 5, 7, etc

This work adoptsCC agreement, reprint must indicate the author and the link to this article

Hacking