理解三通道的构成以及显示器实现

#include<iostream> using namespace std; #include<cvaux.h> #include<cxcore.h> #include<highgui.h> int main() { IplImage *src,*dst; IplImage *r_rode,*g_rode,*b_rode; src = cvLoadImage(".//photo//3.jpg",1); r_rode = cvCreateImage(cvGetSize(src),src->depth,1); g_rode = cvCreateImage(cvGetSize(src),src->depth,1); b_rode = cvCreateImage(cvGetSize(src),src->depth,1); dst = cvCreateImage(cvGetSize(src),src->depth,3); cvSplit(src,b_rode,g_rode,r_rode,NULL);//顺序是BGR cvZero(dst); cvNamedWindow("red_channel",1); cvMerge(r_rode,NULL,NULL,NULL,dst); cvShowImage("red_channel",r_rode); cvWaitKey(0); cvZero(dst); cvNamedWindow("blue_channel",1); cvMerge(NULL,NULL,b_rode,NULL,dst); cvShowImage("blue_channel",dst); cvWaitKey(0); cvZero(dst); cvNamedWindow("green_channel",1); cvMerge(NULL,g_rode,NULL,NULL,dst); cvShowImage("green_channel",dst); cvWaitKey(0); cvNamedWindow("src",1); cvShowImage("src",src); cvWaitKey(0); cvDestroyWindow("red_channel"); cvDestroyWindow("blue_channel"); cvDestroyWindow("green_channel"); cvDestroyWindow("src"); cvReleaseImage(&r_rode); cvReleaseImage(&g_rode); cvReleaseImage(&b_rode); cvReleaseImage(&src); cvReleaseImage(&dst); }

1.如果仅仅分解到某一个通道上,显示的是灰色。这与显示器的显示原理有关,它显示时会把三个灯(RGB)的数值调成一致的,因而是灰色。

2.将分解的图与NULL,NULL合并就可以显示彩色图,这是因为其他两个分量成为0

3.注意分解得到的通道次序:BGR

你可能感兴趣的:(null,DST)