OpenCV common basic processing functions (5) image blur

2D convolution

cv.filter2D () allows us to perform an image convolution operation,

Image blur (image smoothing)
using a low pass filter can achieve the purpose of image blur. This is very helpful for removing noise with. In fact, the removal of high frequency components in an image (such as: noise, boundary). So the border will be blurred a little. (Of course, there are some fuzzy technology does not blur the boundary). OpenCV offers four blur technology.

1. Average

Only cover an area with the average of the pixel block instead of the central element convolution

cv2.blur () and cv2.boxFilter () to complete this task

2. Gaussian blur

The convolution kernels into Gaussian kernel, the same block, the original value of each box are equal, the value of which is now in line with Gaussian distribution .

Gaussian filtering Gaussian noise can be effectively removed from the image.

# 0 refers to the size of the window according to (5,5) is calculated standard deviation Gaussian 
blur = cv2.GaussianBlur (img, (5,5 ), 0)

 

3. Median blur

A convolution block corresponding to the pixel value to replace the value of the center pixel. This filter is often used to remove salt and pepper noise;

A new value to replace the value of the center pixel value, and median filtering is around the center pixel (may enable him) in front of the filter are used to replace him calculated

median = cv2.medianBlur(img,5)

4. bilateral filtering

Function cv2.bilateralFilter () can effectively remove noise while maintaining clear boundary.

Gaussian filter is a Gaussian weighted averaging the center point of the adjacent area of the pixel . This Gaussian filter only considers the pixels between the spatial relationship, and does not consider the relationship between the pixel values ( the similarity of pixels ).

Therefore, this method does not consider whether a pixel located at the boundary. So the border will not obscured. Bilateral filtering while using spatial Gaussian weight values and gray similarity Gaussian weight.

Guess you like

Origin www.cnblogs.com/ywheunji/p/10987781.html