You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
673 B
24 lines
673 B
# 导入numpy包
|
|
import numpy as np
|
|
# 导入opencv包
|
|
import cv2
|
|
def sf(image_path,max):
|
|
# 使用opencv读取图片
|
|
image = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)
|
|
# 待输出的图片
|
|
m = int(max)
|
|
output = np.zeros(image.shape, np.uint8)
|
|
array = []
|
|
# 带通的范围
|
|
for i in range(image.shape[0]):
|
|
for j in range(image.shape[1]):
|
|
# 滤波器内像素值的和
|
|
array.clear()
|
|
if image[i][j] > m:
|
|
output[i][j] = image[i][j]
|
|
else:
|
|
output[i][j] = 0
|
|
cv2.imshow('result',output)
|
|
cv2.waitKey(0)
|
|
|
|
cv2.destroyAllWindows() |