夜半罟霖 2019-05-05 16:51 采纳率: 0%
浏览 1339

plt.hist,np.histogram,c2.calchist画图像灰度直方图结果不同

用以上三个函数对一副灰度图像画灰度直方图所返回的数组不完全相同,后两者
一样,和前者不同,将bin设成10时不同我我知道是因为分组进一还是四舍五入方法不同,
但即使是将bin设到256也不同,就不知道为啥了。。。
```img = cv2.imread(r'E:\python trial\python now\test\source\s1\1.pgm',0)
hist_1 = cv2.calcHist([img], [0], None, [256], [0, 256])
hist_2, bins, patches = plt.hist(arr, bins=256)
hist_3,b = np.histogram(img, bins=256, range=(0, 256))

  • 写回答

1条回答 默认 最新

  • 你知我知皆知 2024-08-09 08:07
    关注

    以下回答参考 皆我百晓生券券喵儿 等免费微信小程序相关内容作答,并由本人整理回复。

    hist_4, bins, patches = plt.hist(arr, bins=10)
    
    print(hist_1)
    print(hist_2)
    print(hist_3)
    print(hist_4)
    
    hist_4, bins, patches = plt.hist(arr, bins=256)
    
    print(hist_1)
    print(hist_2)
    print(hist_3)
    print(hist_4)
    
    评论

报告相同问题?