当前位置:网站首页>OpenCV image transformation - histogram equalization
OpenCV image transformation - histogram equalization
2022-08-09 18:26:00 【why why】
本文摘录 OpenCV Image transformation related operations in ,重点介绍 Opencv 中的直方图均衡化操作.
直方图均衡
Cameras and image sensors don’t just adapt to the naturally occurring contrast in a scene,It is also possible to manage the exposure of the image sensor to the available light levels.in a standard camera,Set the shutter and lens aperture to make sure the sensor is neither too much nor too little.然而,Usable dynamic range for the sensor,The range of contrast in a particular image tends to be too large.因此,Capture dark areas that require longer exposure times(例如阴影)There is a trade-off between bright areas that require shorter exposures,以避免饱和“白化”.在许多情况下,You can't have both in the same image.
- Histogram equalization mathematical background is to combine a distribution(The given histogram of intensity values)映射到另一个分布(A wider and ideally uniform distribution of intensity values).也就是说,We want to distribute the original distribution as evenly as possible in the new distributiony值.事实证明,A good way to solve the problem of spreading distributed values is :The remapping function should be a cumulative distribution function.如图所示,An example of a cumulative distribution function is shown,A somewhat idealized case for the original pure Gaussian density distribution.然而,Cumulative density can be applied to any distribution,The running sum of the original distribution ranges from negative to positive.
- We can use the cumulative distribution function to remap the original distribution to a uniform distribution,Just look at each in the original distributiony值,And see where in the balanced distribution it should go.For a continuous distribution the result will be an exact equilibrium,But for numeric discrete distributions,Results can be quite inconsistent.
cv2.calcHist()
直方图统计 官方文档
cv2.calcHist(
images, # 源图像
channels, # List of channels used for statistical histograms
mask, # Optional mask.if the matrix is not empty,It must be the same size as the image8位数组.
histSize, # An array of histogram sizes for each dimension.
ranges[, # Integer array of histogram bin boundaries in each dimension.
hist[, # 输出直方图
accumulate]]) # accumulation mark.如果被设置,then the histogram will not be cleared at the beginning.
# This feature enables you to compute a single histogram for several groups of arrays,或者及时更新直方图.
-> hist- 示例代码
img = mt.cv_rgb_imread('img2_gray.jpg', gray=True)
hist = cv2.calcHist([img], [0], None, [256], [0,255])
PIS(img, hist[:, 0])numpyThis histogram function can also be implemented
hist_cv = cv2.calcHist([img],[0],None,[256],[0,256])
hist_np,bins = np.histogram(img.ravel(),256,[0,256])
hist_np2 = np.bincount(img.ravel(),minlength=256)cv2.equalizeHist()
灰度图的直方图均衡化 官方文档
- 函数使用
cv2.equalizeHist(
src[, # 源图像
dst]) -> dst- 示例代码
img = mt.cv_rgb_imread('img2_gray.jpg', gray=True)
hist = cv2.calcHist(img, [0], None, [256], [0,255])
res = cv2.equalizeHist(img)
res_hist = cv2.calcHist(res, [0], None, [256], [0,255])
PIS(img, hist[:, 0], res, res_hist[:, 0], cmap='gray')参考资料
- 《学习 OpenCV3》 第十一章
- https://blog.csdn.net/qq_41895190/article/details/89646787
边栏推荐
猜你喜欢

网络——介质访问控制

成为CTO,6个月被老板干死,我损失了1000万

5G NR Paging 寻呼

Detailed explanation of three pieces in C language

SQL trill interview: send you a universal template, to?(key, each user to log on to the maximum number of consecutive monthly)

网络——虚拟专用网和地址转换NAT

<IDEA 使用小技巧&&常用键联合操作>

2022国赛Ezpop

uni-app中websocket的使用 断开重连、心跳机制

网络——IPv6 vs IPv4
随机推荐
qiucode.cn网站之文章详情实现代码块可点击按钮进行复制
第一篇博客
After the WeChat developer tool program is developed, no error is reported, but the black screen "recommended collection"
PADS生成位号图
线性表重点之链表
网络——IPV4地址(二)
MySQL 5.5系列安装步骤教程(图解版)
推荐一些面向 Web 开发者的杀手级网站
Codeforces Round #808 (Div. 2)||Precipitation
Qt学习第二天
NFT+IDO预售代币合约模式系统开发
resubmit 渐进式防重复提交框架简介
3种特征分箱方法!
OpenCV 图像变换之 —— 直方图均衡化
@AllArgsConstructor 和 @NoArgsConstructor
领先实践|全球最大红酒App如何用设计冲刺创新vivino模式
SQL trill interview: send you a universal template, to?(key, each user to log on to the maximum number of consecutive monthly)
dichotomy
Super hot summer air conditioner
IDEA中Lombok插件的安装与使用