Visual c++ imread函数在windows上不适用于.PNG
我正在尝试使用Visual c++ imread函数在windows上不适用于.PNG,visual-c++,opencv3.0,Visual C++,Opencv3.0,我正在尝试使用 Mat_<float> depth_image_16_bit = imread(path_to_image, -1); Mat_uudepth_uimage_u16位=imread(路径到图像,-1); 但它无法加载。它显示断言错误。 它适用于Mat,但不适用于short或float如果在imread中使用参数-1,这相当于imread\u UNCHANGED,您将获得一个具有原始通道数的8位图像 因此,如果您的图像是: 单通道,您将获得一个Mat1b(又称M
Mat_<float> depth_image_16_bit = imread(path_to_image, -1);
Mat_uudepth_uimage_u16位=imread(路径到图像,-1);
但它无法加载。它显示断言错误。
它适用于
Mat
,但不适用于short
或float
如果在imread
中使用参数-1
,这相当于imread\u UNCHANGED
,您将获得一个具有原始通道数的8位图像
因此,如果您的图像是:
- 单通道,您将获得一个
(又称Mat1b
)Mat
- 3个频道,您将获得一个
(又称Mat3b
)Mat\u Vec3b
- 4个频道,您将获得一个
(又称Mat4b
)Mat\u Vec4b
Mat
的频道类型和数量,然后更改为更正Mat\uu
:
或者,您可以以正确的深度加载它(如果您的图像每像素有2个字节,则这非常有用):
Mat img=imread(文件名,imread\u ANYDEPTH);
库特
Mat img = imread(filename, IMREAD_UNCHANGED);
cout << img.channels();
cout << img.depth() << endl;
Mat img = imread(filename, IMREAD_UNCHANGED);
img.convertTo(img, CV_32F); // now your image is of CV_32F type
Mat img = imread(filename, IMREAD_ANYDEPTH);
cout << img.channels();
cout << img.depth() << endl;