【发布时间】:2018-09-02 17:00:49
【问题描述】:
我正在从文档中复制此 example:
import matplotlib.pyplot as plt
from skimage import data
from skimage.filters import threshold_otsu, threshold_adaptive
image = data.page()
global_thresh = threshold_otsu(image)
binary_global = image > global_thresh
block_size = 35
binary_adaptive = threshold_adaptive(image, block_size, offset=10)
fig, axes = plt.subplots(nrows=3, figsize=(7, 8))
ax0, ax1, ax2 = axes
plt.gray()
ax0.imshow(image)
ax0.set_title('Image')
ax1.imshow(binary_global)
ax1.set_title('Global thresholding')
ax2.imshow(binary_adaptive)
ax2.set_title('Adaptive thresholding')
for ax in axes:
ax.axis('off')
plt.show()
有threshold_adaptive,但是会引发警告:
“UserWarning:threshold_local的返回值为阈值图像,而threshold_adaptive返回阈值图像”
但是当我使用 threshold_adaptive 时,结果就不同了:
【问题讨论】:
-
@CrisLuengo 我的问题是如何在两种方法中获得相同的结果,因为它应该是相同的功能。我更新了代码
标签: python image-processing scikit-image threshold