【发布时间】:2017-08-27 07:55:30
【问题描述】:
我是 python 和图像处理的初学者。我想使用直方图函数从图像中找到棕色的百分比。
我做了直方图功能,但我不知道如何找到图像中棕色的百分比。
这是我的python代码
import cv2
import numpy as np
from matplotlib import pyplot as plt
img = cv2.imread('C:\Users\MainUser\Desktop\histogram\dates.jpg', -1)
cv2.imshow('GoldenGate',img)
color = ('b','g','r')
for channel,col in enumerate(color):
histr = cv2.calcHist([img],[channel],None,[256],[0,256])
plt.plot(histr,color = col)
plt.xlim([0,256])
plt.title('Histogram for color scale picture')
plt.show()
while True:
k = cv2.waitKey(0) & 0xFF
if k == 27: break # ESC key to exit
cv2.destroyAllWindows()
我使用的图片
【问题讨论】:
-
你想严格使用直方图来完成这个吗?
-
从技术上讲,我在回答中使用了直方图方法,方法是对颜色通道进行积分并获取与所需颜色相对应的积分子集。尽管如此,我同意你的观点,这个问题在这方面是可以解释的。猜猜作者是时候回应了。
标签: python opencv image-processing histogram