Replace the picture path in your code with the actual path.
#include"stdafx.h"#include"cv.h"#include"highgui.h"#include#include<cv.h>using namespacestd;intMainintargcChar**argv) {intK;iplimage* src = cvloadimage (".. \\4_3.jpg",1); Iplimage* imgchannel[4] = {0,0,0,0};iplimage* DST = cvcreateimage (cvgetsize (SRC), ipl_depth_8u,3);if(SRC) { for(k =0; K < src->nchannels; k++) {Imgchannel[k]= Cvcreateimage (cvgetsize (SRC), ipl_depth_8u,1);//requires a single channel image to equalize the histogram}//Channel SeparationCvsplit (SRC, imgchannel[0], imgchannel[1], imgchannel[2], imgchannel[3]);//BGRAcout <<"Dst->nchannels:"<< dst->nchannels; for(k =0; K < dst->nchannels; k++){//histogram equalization, the original image and the target image must be single-channelcvequalizehist (Imgchannel[k], imgchannel[k]);}//Channel CombinationCvmerge (imgchannel[0], imgchannel[1], imgchannel[2], imgchannel[3], DST); Cvnamedwindow ("src",1); Cvshowimage ("src", SRC); Cvnamedwindow ("Equalize",1); Cvshowimage ("Equalize", DST); Cvwaitkey (0);//Freeing Resources for(k =0; K < src->nchannels; k++){if(Imgchannel[k]) {cvreleaseimage (&imgchannel[k]);//Imgchannel[i] = 0;}}cvreleaseimage (&DST);}return 0;}
Histogram equalization of OpenCV