Ask Your Question
2

Problem with meanStdDev

asked 2013-01-25 14:14:51 -0600

unxnut gravatar image

I seem to be having a problem trying to compute the mean and standard deviation of pixels in an image. Can someone look at my code and point out what I am doing wrong? I am unable to get correct results.

cv::Mat             img;
cv::Mat     mean;
cv::Mat     stddev;

cv::meanStdDev ( img, mean, stddev );
uchar       mean_pxl = mean.data[0];
uchar       stddev_pxl = stddev.data[0];

I have also tried to get the data using mean.at<uchar>(0) without success.

Thanks for your help.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-03-22 04:28:14 -0600

TripleS gravatar image

The return type should be

double       mean_pxl = mean.val[0];
double       stddev_pxl = stddev.val[0];

otherwise you can use "auto"

auto mean_pxl = mean.val[0];
auto stddev_pxl = stddev.val[0];
edit flag offensive delete link more

Comments

Keep in mind that for auto you will need to enable c++11.

StevenPuttemans gravatar imageStevenPuttemans ( 2017-03-22 05:26:33 -0600 )edit

Question Tools

Stats

Asked: 2013-01-25 14:14:51 -0600

Seen: 23,332 times

Last updated: Mar 22 '17