博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python opencv绘制直方图
阅读量:3898 次
发布时间:2019-05-23

本文共 701 字,大约阅读时间需要 2 分钟。

灰度直方图概括了图像的灰度级信息,简单的来说就是每个灰度级图像中的像素个数以及占有率

import cv2import matplotlib.pyplot as pltimport numpy as npimg = cv2.imread('hand.jpg',1)ori = img.copy()color = ['b','g','r']plt.subplot(221)img = cv2.cvtColor(img,cv2.COLOR_BGR2RGB)plt.imshow(img),plt.title('original'),plt.xticks([]),plt.yticks([])plt.subplot(222)for n ,col in enumerate(color):    histr = cv2.calcHist([img],[n],None,[256],[0,256])    plt.plot(histr, color=col)    plt.xlim([0, 256])image = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)plt.subplot(223)plt.imshow(image,'gray'),plt.title('original'),plt.xticks([]),plt.yticks([])plt.subplot(224)hist_full = cv2.calcHist([image],[0],None,[256],[0,256])plt.plot(hist_full),plt.xlim([0,256])plt.show()

在这里插入图片描述

转载地址:http://chben.baihongyu.com/

你可能感兴趣的文章
数据库SQL语言语法总结4---数据更新
查看>>
数据库SQL语言语法总结5---视图
查看>>
数据库SQL语言语法总结6---数据控制
查看>>
数据库SQL语言语法总结1---表操作
查看>>
Numpy中stack(),hstack(),vstack()函数详解
查看>>
基于3D卷积神经网络的行为识别
查看>>
K.function用法
查看>>
keras -- multi-loss
查看>>
pytorch数据增强的具体细节
查看>>
pytorch专题 --- load模型
查看>>
VSCode编写C++代码从零开始
查看>>
ESC ubuntu16.04 ipv6配置
查看>>
visual studio 创建 C/C++静态库和动态库
查看>>
2021-05-26
查看>>
ubuntu中配置环境变量
查看>>
ubuntu安装weditor
查看>>
Ubuntu安装NVIDIA显卡驱动
查看>>
vue-cli中实现dolist
查看>>
sass的安装
查看>>
Vue-cli中路由配置
查看>>