高滤波器opencv(Python)

高滤波器(HPF)

检测图像的某个区域,然后根据像素与周围像素的亮度差来提升该像素的亮度的滤波器。

数值上,一般为一个核(也是一个矩阵)

效果

原图:

这里写图片描述

经过一个核来进行滤波之后,结果是
这里写图片描述

先找到原图像的高斯噪声(之后作差):

这里写图片描述

其实可以看出来,高斯的那个效果会更好一点(主要是线更粗,说明准确率更高。但是也导致了边角的那个箭尾没有找到)

代码

下面代码中的1.png就是原图

import cv2
import numpy as np
from scipy import ndimage

kernak_3x3 = np.array([[-1, -1, -1], [-1, 8, -1], [-1, -1, -1]])

img = cv2.imread('1.png', 0)  # read the img in a gray way

k3 = ndimage.convolve(img, kernak_3x3)  # convolve

blurred = cv2.GaussianBlur(img, (11, 11), 0)
g_hpf = img - blurred

cv2.imshow('g_hpf', g_hpf)
cv2.imwrite('g_hpf.png', g_hpf)
cv2.imshow('k3', k3)
cv2.imwrite('k3.png', k3)

cv2.waitKey()
cv2.destroyAllWindows()

猜你喜欢

转载自blog.csdn.net/a19990412/article/details/81104776
今日推荐