小编Maj*_* ـG的帖子

使用直方图的图像python opencv中的颜色百分比

我是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()
Run Code Online (Sandbox Code Playgroud)

我使用的图像

我使用的图像

我有这个代码的输出 在此输入图像描述

python opencv image-processing histogram

4
推荐指数
1
解决办法
4258
查看次数

标签 统计

histogram ×1

image-processing ×1

opencv ×1

python ×1