Ask Your Question
2

Problem with meanStdDev

asked Jan 25 '13

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.

Preview: (hide)

1 answer

Sort by » oldest newest most voted
1

answered Mar 22 '17

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];
Preview: (hide)

Comments

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

StevenPuttemans gravatar imageStevenPuttemans (Mar 22 '17)edit

Question Tools

Stats

Asked: Jan 25 '13

Seen: 23,442 times

Last updated: Mar 22 '17