在将bayer图像转换成为rgb的时候遇到的问题
Mat bayer = imread("/home/pan/Desktop/data/Testaufbau_Ecoflac153.tif",-1);
Mat bayer2rgb;
bayer2rgb.create(bayer.rows,bayer.cols,CV_8UC3);
cvtColor(bayer,bayer2rgb,CV_BayerRG2BGR);
vector<Mat> difChan;
split(bayer2rgb,difChan);
// imshow("Bayer Pattern",difChan[0]);
imwrite("img_b.jpg",difChan[0]);
imwrite("img_r.jpg",difChan[1]);
imwrite("img_g.jpg",difChan[2]);
一直解决不了的问题出现在imread的使用上。
bayer图像是 one channel的图像,
如果简单的用imread,用defualt的参数的话,读出来的是3 channels的matrix。
而 cvtColor(source, destination, CV_BayerRG2BGR) 是将one channel 转换成 3 channel 图像的。
解决办法就是把imread 的参数设为0 或者 -1
此处的bayer pattern filter 需要从camera处获取
具体bayer pattern 介绍如下
copy 自:http://www.tldp.org/HOWTO/libdc1394-HOWTO/concepts.html
4.6. How to get color images: Bayer Pattern Concepts
The image grabbed by the sample code in the previous section is not colored (we have intentionally used the words "not colored," since the image is not gray-sc