直方图均衡化实例

上传人:M****1 文档编号:467716118 上传时间:2024-01-25 格式:DOC 页数:3 大小:138.50KB
返回 下载 相关 举报
直方图均衡化实例_第1页
第1页 / 共3页
直方图均衡化实例_第2页
第2页 / 共3页
直方图均衡化实例_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

《直方图均衡化实例》由会员分享,可在线阅读,更多相关《直方图均衡化实例(3页珍藏版)》请在金锄头文库上搜索。

1、一实验目的1.熟练使用opencv编写程序。2.熟悉并运用直方图均衡话的方法处理图像。二实验原理及代码#includecv.h#includehighgui.h#includestdio.h#includestdlib.h#includemath.h#defineLEVEL256intmain(intargc,char*argv)IplImage*pImgSource,*pImgDestination;/声明IplImage指针intheight,width,stepSource,stepDestination,channels,grayLevelLEVEL,pixelsCLEVEL;ucha

2、r*dataSource,*dataDestination;inti,j,k,p;/载入图像pImgSource=cvLoadImage(couple.bmp);if(!pImgSource)printf(Imagewasnotloaded.n);return-1;/获取图像信息height=pImgSource-height;width=pImgSource-width;stepSource=pImgSource-widthStep;channels=pImgSource-nChannels;dataSource=(uchar*)pImgSource-imageData;printf(Pro

3、cessinga%d*%dwith%dchannelsn,height,width,channels);/获得NO.ofpixelsfor(i=0;iLEVEL;i+)grayLeveli=0;/初始化灰度级数组for(i=0;iheight;i+)for(j=0;jwidth;j+)for(k=0;kchannels;k+)p=dataSourcei*stepSource+j*channels+k;grayLevelp+;/均衡化处理pixelsC0=grayLevel0;for(i=1;iLEVEL;i+)/pixelsC中存储统计量pixelsCi=grayLeveli+pixelsCi

4、-1;for(i=0;idepth,channels);dataDestination=(uchar*)pImgDestination-imageData;stepDestination=pImgDestination-widthStep;/将源图像处理后的数据添加到新建图像的数据区域for(i=0;iheight;i+)for(j=0;jwidth;j+)for(k=0;kchannels;k+)p=dataSourcei*stepSource+j*channels+k;dataDestinationi*stepDestination+j*channels+k=pixelsCp;/显示处理前

5、和处理后的图像cvNamedWindow(Image1,1);/创建窗口cvShowImage(Image1,pImgSource);/显示图像cvNamedWindow(Image2,1);cvShowImage(Image2,pImgDestination);cvWaitKey(0);cvDestroyWindow(Image1);/销毁窗口cvDestroyWindow(Image2);cvReleaseImage(&pImgSource);/释放图像cvReleaseImage(&pImgDestination);return0;三实验结果实验原图均衡化后四.实验心得通过实验我对opencv的上机环境变得更加的熟悉,并对直方图均衡化处理图像和中值滤波也有了一定的理解。

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 解决方案

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号