核心函数:
cvEqualizeHist
程序:
#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
原文地址:http://flyclc.blog.51cto.com/1385758/1539803