欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

读取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;
}

相关标签: 算法