整理一下opencv下将IR图像转为BMP的程序
#include<opencv2\opencv.hpp>
using namespace cv;
using namespace std;
//输入图像
String File_Path = "E:\\log\\ir_data_file_20190619_153236817.dat";
//图像保存位置
#define img_path "E:\\处理\\"
#define img_type ".bmp"
#define IMG_WIDTH 640
#define IMG_HEIGHT 512
#define IMG_BITWIDTH 16384 //2^14 14位图像
unsigned short(imagedata[IMG_WIDTH*IMG_HEIGHT]);
unsigned short Hist[IMG_BITWIDTH];
//路径和文件数字
char *filename;
char *number;
//两种不同的14位转8位映射
Mat mat14to8(unsigned short *srcData);
Mat img14to8(ushort *in, int rows, int cols);
int main()
{
Mat outputImage(IMG_HEIGHT, IMG_WIDTH, CV_8UC1, Scalar(0));
//打开文件并确定结尾位置和图片数量
FILE *pfile;
if(pfile = fopen(File_Path.c_str(), "r")==NULL)
{
return false;
}
struct stat statbuf;
stat(File_Path.c_str(), &statbuf);
cout << "文件大小为" << statbuf.st_size << "B" << endl;
int number_size = statbu