自建网站需要哪些技术,博罗网站设计公司,惠州seo博客报价,邯郸市做网站的公司匿名用户1级2017-05-16 回答OpenCV 生成 伪彩色图像opencv中没有易用的伪彩色图像生成函数#xff0c;这里提供一个改造过的函数#xff0c;利用自定义colorbar 将灰度图像转换成为伪彩色图像#xff0c;优点在于提供了对于颜色的直观可操控性#xff0c;转换方便。函数代码…匿名用户1级2017-05-16 回答OpenCV 生成 伪彩色图像opencv中没有易用的伪彩色图像生成函数这里提供一个改造过的函数利用自定义colorbar 将灰度图像转换成为伪彩色图像优点在于提供了对于颜色的直观可操控性转换方便。函数代码如下[cpp] view plain copy 在CODE上查看代码片派生到我的代码片//function : Pseudo color - enhanced//author : Xin Yang, Shenzhen Univ., School of medicine//email : xinyangszu.edu.cn//date : 2015.01.23void C_Assistant::Gray2PseudoColor(IplImage* src ,IplImage *dst){if(dst ! NULL){cvReleaseImage(dst);dst NULL;}dst cvCreateImage(cvGetSize(src), IPL_DEPTH_8U, 3);IplImage *R, *G,*B;//Load referred color barstd::string HeatMapPath ..\\ColorBar.png;IplImage* heatmap cvLoadImage(HeatMapPath.c_str());//we split the heatmap along the 3 channelsR cvCreateImage(cvGetSize(heatmap), heatmap-depth,1);G cvCloneImage(R);B cvCloneImage(R);cvSplit(heatmap,B,G,R,NULL);for(int x0; xwidth; x){for(int y0;yheight; y){//memory access to the destination color image (faster than splitting the 3 channels...)unsigned char *data ((unsigned char*)(dst-imageData dst-widthStep*y ))[x*3];//read the intensity value in the grayscale imageunsigned char gray src-imageData[src-widthStep*y x*src-nChannels];//remember, OpenCV store images as BGR internally !//So access [2] for Red, [1] for Green et [3] for Bluefloat ColorIndex gray/255.0*heatmap-height;if(ColorIndex heatmap-height) ColorIndex heatmap-height - 1;data[2] cvGet2D(R, ColorIndex, 1).val[0]; //Red channeldata[1] cvGet2D(G, ColorIndex, 1).val[0]; //Green channeldata[0] cvGet2D(B, ColorIndex, 1).val[0]; //Blue channel}}//Clearif(heatmap ! NULL){cvReleaseImage(heatmap);heatmap NULL;}}参考可用的colorbar如下也可以自己生成来替换。