#本质 统计每个像素灰度出现的概率
import cv2
import numpy as np
import matplotlib.pyplot as plt
img = cv2.imread('ruonan.jpg',1)
gray = cv2.cvtColor(img,cv2.COLOR_RGB2GRAY)
Info = gray.shape
height = Info[0]
width = Info[1]
count = np.zeros(256,np.float)
for i in range(0,height):
for j in range(0,width):
pixel = gray[i,j]
index = int(pixel)
count[index] = count[index]+1
for i in range(0,255):
count[i] = count[i]/(height*width)
x = np.linspace(0,255,256)
y = count
plt.bar(x,y,0.9,alpha=1,color='b')#占比90%
plt.show()
cv2.waitKey(0)
32_灰度直方图均衡化源代码
原创wx5c808bf9b561a ©著作权
©著作权归作者所有:来自51CTO博客作者wx5c808bf9b561a的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
浅析MySQL 8.0直方图原理
本文将对直方图概念进行介绍,借助举例描述直方图的使用方式,对创建/删除直方图的原理进行浅析,并通过例子说明其应用场景。
直方图 mysql 执行计划 查询优化 -
灰度图直方图均衡化python python 灰度直方图
目录0 原理 1 统计直方图 2 绘制直方图 3 使用掩膜0 原理什么是直方图呢?通过直方图你可以对整幅图像的灰度分布有一个整体的了解。直方图的 x 轴是灰度值(0 到 255),y 轴是图片中具有同一个灰度值的点的数目。直方图其实就是对图像的另一种
灰度图直方图均衡化python 图像直方图 calcHist 绘制直方图 opencv