小编Giu*_*io 的帖子

直方图中的垂直线与pyplot

我已经为kinect深度图像计算了Otsu的阈值,现在我想指出直方图上的最佳阈值,例如在opencv2中使用带有pyplot的axvline.我是python和编程的初学者,这是我的代码的特定部分:

fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(8, 2.5))
ax1.imshow(img)
ax1.set_title('Original')
ax1.axis('off')

ax2.hist(img)
ax2.set_title('Histogram')
plt.axvline(x=thresh, color='r', linestyle='dashed', linewidth=2)

ax3.imshow(binary, cmap=plt.cm.gray)
ax3.set_title('Thresholded')
ax3.axis('off')

plt.show()
Run Code Online (Sandbox Code Playgroud)

但我不知道为什么,我在阈值图上获得了垂直线

我究竟做错了什么??谢谢

matplotlib histogram python-2.7 threshold

5
推荐指数
1
解决办法
6017
查看次数

标签 统计

histogram ×1

matplotlib ×1

python-2.7 ×1

threshold ×1