【14】opencv/C++ 打开图像,转成Mat格式
作者:
豚大叔的小屋 | 来源:发表于
2023-10-23 15:48 被阅读0次 //1.加载图像
std::ifstream file("apple.prj", std::ios::binary);
if (!file) {
std::cout << "无法打开文件" << std::endl;
return 0;
}
// 跳过100个字节的头部数据
file.seekg(100, std::ios::beg);
int width =512; // 图像宽度
int height =512; // 图像高度
int numPixels = width * height; // 像素数
cv::Mat image(height, width, CV_16UC1);
file.read(reinterpret_cast<char*>(image.data), numPixels * sizeof(uint16_t));
file.close();
本文标题:【14】opencv/C++ 打开图像,转成Mat格式
本文链接:https://www.haomeiwen.com/subject/ymkjidtx.html
网友评论