我是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()
我使用的图片 我有代码的输出结果
![输入图像描述](https://istack.dev59.com/oP2EM.webp)