imread()
我在 Windows 7 上使用 jpg 文件的 Matlab (2014) 和 OpenCV (3.0) 中的函数遇到问题。
通过读取相同的文件 jpg 和相同的像素,我没有相同的值。
这是我的 2 个代码:(OpenCV 代码后跟 Matlab 代码)和我拥有的值(在 OpenCV 中查看模式调试,在 Matlab 中查看键盘)
#include <opencv2\opencv.hpp>
#include <cstdio>
using namespace cv;
using namespace std;
int main()
{
Mat img = imread("test.jpg");
uchar pb = img.at<Vec3b>(0, 0).val[0];
uchar pg = img.at<Vec3b>(0, 0).val[1];
uchar pr = img.at<Vec3b>(0, 0).val[2];
int d = img.depth();
int t = img.type();
}
价值观:
pixel [0,0] = (147,174,204); // = index(1,1) in the image.
d = 0;
t = 16;
代码MATLAB:
img = imread('test.jpg');
img(1,1,:)
whos img
价值观:
ans(:,:,1) =
148
ans(:,:,2) =
174
ans(:,:,3) =
201
Name Size Bytes Class Attributes
img 1920x2560x3 14745600 uint8
你知道为什么价值观不同吗?
我在另一篇文章中看到过这样的问题,但是这个人通过阅读 tiff 并没有相同的深度。在这里你可以看到我有同样的深度!
提前感谢您,对任何英语错误深表歉意。
PS:我也对其他像素进行了测试,结果相同:封闭结果但不完全相等。