#include "highgui.h"
#include "Cv.h"
#pragma comment (lib, "Cv.lib")
#pragma comment (lib, "Cxcore.lib")
#pragma comment (lib, "Highgui.lib")
int main ()
{
Iplimage *src = cvloadimage ("0.jpg", 1);
Iplimage *DST;
Iplimage *dst1;
Iplimage *dst2;
Iplimage *dst3;
Dst1 = Cvcreateimage (Cvsize (Src->width, Src->height), ipl_depth_8u, 1);
Dst2 = Cvcreateimage (Cvsize (Src->width, Src->height), ipl_depth_8u, 1);
Dst3 = Cvcreateimage (Cvsize (Src->width, Src->height), ipl_depth_8u, 1);
DST = Cvcreateimage (Cvsize (Src->width, Src->height), ipl_depth_8u, 3);
Cvsplit (SRC, dst1, dst2, DST3, 0);//separate RGB channels, get BGR single-channel images respectively
Cvmerge (Dst1, Dst2, Dst3, 0, DST);//inverse operation, combining three-channel image to get color image
Cvnamedwindow ("Dst1", 1);
Cvshowimage ("Dst1", dst1);
Cvnamedwindow ("Dst2", 1);
Cvshowimage ("Dst2", dst2);
Cvnamedwindow ("Dst3", 1);
Cvshowimage ("Dst3", DST3);
Cvnamedwindow ("DST", 1);
Cvshowimage ("DST", DST);
Cvmovewindow ("Dst1", 100,100);
Cvmovewindow ("Dst2", 200,200);
Cvmovewindow ("Dst3", 300,300);
Cvwaitkey (0);
Cvreleaseimage (&SRC);
Cvreleaseimage (&DST1);
Cvreleaseimage (&DST2);
Cvreleaseimage (&DST3);
Cvreleaseimage (&DST);
return 0;
}
Channel segmentation and fusion of images