高斯模糊
-
个人理解:高斯模糊简单理解就是讲对应点的坐标值,带入高斯函数中,并将对应的数值写入对应像素点。最后将该像素点进行归一化处理,使得所有像素点的值加起来为1。
-
代码:
对图像加入 gaussian noise
# add gaussian noise to the image
def gaussian_noise(image):
h, w, c = image.shape;
for row in range(0, h, 1):
for col in range(0, w, 1):
s = np.random.normal(0, 20, 3);
b = image[row, col, 0];#blue
g = image[row, col, 1];
r = image[row, col, 2];
image[row, col, 0] = clamp(b + s[0]);
image[row, col, 1] = clamp(g + s[1]);
image[row, col, 2] = clamp(r + s[2]);
cv.imshow(" added gaussian noise", image);
对图像进行Gaussian模糊:
#gaussian 模糊API
dst = cv.GaussianBlur(src, (5, 5), 15);
cv.imshow("gaussian_noise", dst);
- gaussian模糊的效果:图像的轮廓还在,保留了像素的主要特征,可以消除guassian的影响。
- opencv的GaussianBlur()API
- 浮点数运算,比较费时