简单例程—RAW-to-BMP
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace std; //使用 cout 输出方式
using namespace cv; // 省去函数前面加 cv::的必要性
int main()
{
FILE *fp; //读入文件
if((fp=fopen("C:/Daiqin/标准图像 1024-1024.raw","rb+"))==NULL){
printf("cannot3open3file for read\n");
waitKey();
exit(0);
}
Mat M(1024,1024, CV_8UC1, Scalar(0));
uchar * p;
for (int i =0; i<1024; i++)
{
p=M.ptr<uchar>(i);
fread(p,1,1024,fp);
}
// 显示图片
namedWindow("image",CV_WINDOW_AUTOSIZE);
imshow("image",M);
// 等待按键后窗口自动关闭
waitKey();
imwrite("pic.bmp",M); // 存为 bmp 格式图片
fclose(fp);
return 0;
}