小编Aur*_*eur的帖子

垃圾箱必须单调增加

我只是想从skimage.exposure绘制Matplotlib直方图,但我得到了一个ValueError: bins must increase monotonically.原始图像来自这里和我的代码:

from skimage import io, exposure
import matplotlib.pyplot as plt

img = io.imread('img/coins_black_small.jpg', as_grey=True)
hist,bins=exposure.histogram(img)

plt.hist(bins,hist)
Run Code Online (Sandbox Code Playgroud)

ValueError:bin必须单调增加.

但是当我对bin值进行排序时会出现同样的错误:

import numpy as np
sorted_bins = np.sort(bins)
plt.hist(sorted_bins,hist)
Run Code Online (Sandbox Code Playgroud)

ValueError:bin必须单调增加.

我终于尝试检查了箱子的值,但是我认为它们似乎是排序的(对于这种测试的任何建议也会受到赞赏):

if any(bins[:-1] >= bins[1:]):
    print "bim"
Run Code Online (Sandbox Code Playgroud)

没有输出.

关于会发生什么的任何建议?
我正在努力学习Python,所以请放纵.这是我的安装(在Linux Mint上):

  • Python 2.7.13 :: Anaconda 4.3.1(64位)
  • Jupyter 4.2.1

python matplotlib scikit-image

7
推荐指数
2
解决办法
2万
查看次数

标签 统计

matplotlib ×1

python ×1

scikit-image ×1