码迷,mamicode.com
首页 > 其他好文 > 详细

直方图均衡化 EqualizeHist

时间:2014-08-14 17:06:29      阅读:287      评论:0      收藏:0      [点我收藏+]

标签:opencv 直方图均衡化 equalizehist

核心函数:

cvEqualizeHist

程序:

bubuko.com,布布扣

#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
#include <iostream>
int EqualizeHist(int argc,char** argv)
{
IplImage* src=cvLoadImage("e:\\picture\\4.jpg");
IplImage* SrcB=cvCreateImage(cvGetSize(src),8,1);
IplImage* SrcG=cvCreateImage(cvGetSize(src),8,1);
IplImage* SrcR=cvCreateImage(cvGetSize(src),8,1);
IplImage* DstB=cvCreateImage(cvGetSize(src),8,1);
IplImage* DstG=cvCreateImage(cvGetSize(src),8,1);
IplImage* DstR=cvCreateImage(cvGetSize(src),8,1);
IplImage* Result=cvCreateImage(cvGetSize(src),8,3);
cvSplit(src,SrcB,SrcG,SrcR,NULL);  //把彩***分成B,G,R三个灰度图,因为cvEqualizeHist只能处理单通道图像
cvEqualizeHist(SrcB,DstB);  //直方图均衡化
cvEqualizeHist(SrcG,DstG);
cvEqualizeHist(SrcR,DstR);
cvMerge(DstB,DstG,DstR,NULL,Result);  //合并图像
cvNamedWindow("src");
cvNamedWindow("SrcB");
cvNamedWindow("SrcG");
cvNamedWindow("SrcR");
cvNamedWindow("DstB");
cvNamedWindow("DstG");
cvNamedWindow("DstR");
cvNamedWindow("Result");
cvShowImage("src",src);
cvShowImage("SrcB",SrcB);
cvShowImage("SrcG",SrcG);
cvShowImage("SrcR",SrcR);
cvShowImage("DstB",DstB);
cvShowImage("DstG",DstG);
cvShowImage("DstR",DstR);
cvShowImage("Result",Result);
cvWaitKey(0);
return 0;
}


本文出自 “flyclc” 博客,请务必保留此出处http://flyclc.blog.51cto.com/1385758/1539803

直方图均衡化 EqualizeHist,布布扣,bubuko.com

直方图均衡化 EqualizeHist

标签:opencv 直方图均衡化 equalizehist

原文地址:http://flyclc.blog.51cto.com/1385758/1539803

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!