直方图均衡化及opencv实现

直方图均衡化及opencv实现

ID:16982940

大小:38.70 KB

页数:7页

时间:2018-08-26

直方图均衡化及opencv实现_第1页
直方图均衡化及opencv实现_第2页
直方图均衡化及opencv实现_第3页
直方图均衡化及opencv实现_第4页
直方图均衡化及opencv实现_第5页
资源描述:

《直方图均衡化及opencv实现》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、一、直方图均衡化原理:出自Sonka“Imageprocessing,analysisandmachinevision”,3rded,2008.直方图均衡化是想把左边的直方图变换为右边的直方图,使各个灰度值上的像素个数均匀分布,这样图像整体的亮度分布较均匀,不会过亮或过暗,同时可以增加图像的对比度。假设变换前后图像的灰度等级都为k,则变换过程为:i=0kG(qi)=i=0kH(pi)otherstaffoftheCentre.Duringthewar,ZhuwastransferredbacktoJiangxi,andDirectorofthenewOfficeinJingdez

2、hen,JiangxiCommitteeSecretary.Startingin1939servedasrecorderoftheWestNorthOrganization,SecretaryoftheSpecialCommitteeAfterthevictoryofthelongMarch,hehasbeentheNorthwestOfficeoftheFederationofStateenterprisesMinister,ShenmufuguSARmissions,DirectorofNingxiaCountypartyCommitteeSecretaryandrecord

3、eroftheCountypartyCommitteeSecretary,Ministersand其中,pi为变换前的灰度值,qi为变换后的灰度值,H(p)为变换前的直方图,G(p)为变换后的直方图。假设图像大小为N*N,那么Gqi应为常量值:N2qk-q0那么用精确的连续函数表达,有:其中,称为累积直方图(cumulativehistogram).转换为离散形式,得到:二、算法实现otherstaffoftheCentre.Duringthewar,ZhuwastransferredbacktoJiangxi,andDirectorofthenewOfficeinJingdez

4、hen,JiangxiCommitteeSecretary.Startingin1939servedasrecorderoftheWestNorthOrganization,SecretaryoftheSpecialCommitteeAfterthevictoryofthelongMarch,hehasbeentheNorthwestOfficeoftheFederationofStateenterprisesMinister,ShenmufuguSARmissions,DirectorofNingxiaCountypartyCommitteeSecretaryandrecord

5、eroftheCountypartyCommitteeSecretary,Ministersand1)声明数组H,数组长度为图像的灰度等级G(一般为256),图像大小为N*M;2)扫描图像,建立灰度直方图:H(pi)=H(pi)+1;3)建立累积直方图Hc(pi):Hc(p0)=H(p0);Hc(pi)=Hc(pi-1)+H(pi);4)扫描图像,计算新像素值qi,也可以建立一个查找表:qi=(G-1)Hc(pi)/(N*M)三、代码实现:Mat&MyHistEqual(Mat&I){CV_Assert(I.data);//acceptonlychartypematricesCV

6、_Assert(I.depth()!=sizeof(uchar));constintchannels=I.channels();switch(channels)otherstaffoftheCentre.Duringthewar,ZhuwastransferredbacktoJiangxi,andDirectorofthenewOfficeinJingdezhen,JiangxiCommitteeSecretary.Startingin1939servedasrecorderoftheWestNorthOrganization,SecretaryoftheSpecialCommi

7、tteeAfterthevictoryofthelongMarch,hehasbeentheNorthwestOfficeoftheFederationofStateenterprisesMinister,ShenmufuguSARmissions,DirectorofNingxiaCountypartyCommitteeSecretaryandrecorderoftheCountypartyCommitteeSecretary,Ministersand{case1:{intHi

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。