什么是滞后阈值?如何使用Python中的scikit-learn实现?

什么是滞后阈值?如何使用Python中的scikit-learn实现?

滞后是指结果的滞后效应。关于阈值的滞后,指的是 低于特定低阈值或高于高阈值的区域。它涉及到高度自信的区域。

通过使用滞后,可以忽略图像中物体边缘外的噪声。

让我们看看如何使用scikit-learn库实现滞后阈值:

更多Python相关文章,请阅读:Python 教程

示例

import matplotlib.pyplot as plt
from skimage import data, filters
fig, ax = plt.subplots(nrows=2, ncols=2)
orig_img = data.coins()
edges = filters.sobel(orig_img)
low = 0.1
high = 0.4
lowt = (edges > low).astype(int)
hight = (edges > high).astype(int)
hyst = filters.apply_hysteresis_threshold(edges, low, high)
ax[0, 0].imshow(orig_img, cmap='gray')
ax[0, 0].set_title('Original image')
ax[0, 1].imshow(edges, cmap='magma')
ax[0, 1].set_title('Sobel edges')
ax[1, 0].imshow(lowt, cmap='magma')
ax[1, 0].set_title('Low threshold')
ax[1, 1].imshow(hight + hyst, cmap='magma')
ax[1, 1].set_title('Hysteresis threshold')
for a in ax.ravel():
a.axis('off')
plt.tight_layout()
plt.show()

输出

什么是滞后阈值?如何使用Python中的scikit-learn实现?

解释

  • 导入所需的库。

  • 在绘制图像之前,使用subplot函数设置绘图区域。

  • 使用scikit-learn包中已经存在的’coin’数据作为输入。

  • 使用’sobel’滤波器来获取输入的’sobel’图像,在结果图像中强调了图像的边缘。

  • 使用’apply_hysteresis_threshold’函数获取高于和低于一定阈值的值。

  • 使用’imshow’函数将数据显示在控制台上。

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程