opencv study notes three - image smoothing / denoising processing

import cv2
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
from PIL import Image
image1 = mpimg.imread('image.png')
plt.imshow(image1);

Please add a picture description

1. Mean filtering

A 3×3 convolution kernel, the value of which is 1

image2 = cv2.blur(image1, (3,3))
plt.imshow(image2)

Please add a picture description

2. Box filtering

Here -1 means that the number of color channels of input and output is the same

A 3×3 convolution kernel, the value of which is 1

normalize indicates whether to take the average during convolution, and it is false to indicate that only the sum is taken, and if it exceeds 255, take 255 directly

image3 = cv2.boxFilter(image1, -1, (3,3), normalize=False)
plt.imshow(image3);

Please add a picture description

3. Gaussian filtering

The convolution kernel is not all 1. Instead, values ​​closer to the middle are larger

image4 = cv2.GaussianBlur(image1, (5,5), 1)
plt.imshow(image4)

Please add a picture description

4. Median filtering

image5 = cv2.medianBlur(image1, 5)
plt.imshow(image5)

Please add a picture description

Guess you like

Origin blog.csdn.net/weixin_44669966/article/details/125636046