使用opencv错误搜索图像的均值和方差

时间:2016-01-08 18:00:11

标签: c++ opencv types mean

尝试找出图像的均值和方差。 输出是: M = -5.8099e-16 D = -4.97692e-23

Mat _mat = imread("img.jpg",0);
_mat.convertTo(mat, CV_32F, 1.0/255, 0);    
Mat mean, dev;
mean.convertTo(mean, CV_32F);
dev.convertTo(dev, CV_32F);
meanStdDev(_mat, mean, dev);
float M = mean.at<float>(0,0);
float D = dev.at<float>(0,0);
cout << M << D

怎么了?

1 个答案:

答案 0 :(得分:1)

Scalar mean,dev; 
meanStdDev(_mat, mean, dev); 
double M = mean.val[0]; 
double D = dev.val[0];