读取16bit图片
程序员文章站
2022-07-01 21:00:58
...
int main()
{
char* filePath = "D:\\16bit\\1 (%d).bmp";
char pathStr[100];
for (int i = 1; i <= 5000; i++)
{
cout << i << endl;
sprintf_s(pathStr, filePath, i);
Mat I16 = imread(pathStr,0);
if (!I16.data)
{
cout << "输入错误" << endl;
}
Mat ori16(I16.rows, I16.cols / 2, CV_16UC1);
memcpy(ori16.data, I16.data, I16.rows*I16.cols);
Mat I(ori16.size(), CV_8UC1);
double sumPiexl = sum(ori16)[0];
double mean = (sumPiexl) / (I16.rows*I16.cols / 2);
double deta = 123 - 0.5*mean;
ori16.convertTo(I, 8, 0.5, deta);
transpose(I, I);
flip(I, I, 1);
transpose(ori16, ori16);
flip(ori16, ori16, 1);
imshow("I", I);
waitKey(100);
}
return 0;
}
上一篇: 萤石视频接口(tp后台)
下一篇: RAW12转RAW16