Ask Your Question

hn_88's profile - activity

2018-01-26 02:27:30 -0600 commented answer meanStdDev seems to have a bug? Or am I using it wrong?

Downgraded to 2.4.9.1+dfsg-1.5ubuntu1 and found that the bug is not present for this 2.4.9 version. Posted this as a bug

2018-01-25 22:22:14 -0600 commented answer meanStdDev seems to have a bug? Or am I using it wrong?

Upgraded to OpenCV 3.4.0 release from opencv.org, still I get the same bug! With the test code as listed above, I still

2018-01-24 04:14:09 -0600 commented answer meanStdDev seems to have a bug? Or am I using it wrong?

Thanks Berak. On my opencv version 3.3.1 , I got outputs 10000.5 500.032 -485.257 24231.6 So probably my opencv versi

2018-01-24 04:13:43 -0600 commented answer meanStdDev seems to have a bug? Or am I using it wrong?

Thanks Berak. On my opencv version 3.3.1 , I got outputs 10000.5 500.032 -485.257 24231.6 So probably my opencv versio

2018-01-24 04:11:46 -0600 marked best answer meanStdDev seems to have a bug? Or am I using it wrong?

When I use meanStdDev for an array with more than a million elements (m = 1228800x1 matrix, by reshaping a single channel 1280x960 image), I seem to get an overflow or something like that.

Code snippet:

m=cvarrToMat(img, true);
m=m.reshape(0,1); //makes m a 1228800x1 matrix
m.copyTo(m1);
meanStdDev(m1, meanframe1, stdframe1);

If I use a 128x96 matrix as an input, I get values like meanframe(0)=3067.9 stdframe1(0)=107.072 which seem to be correct for a dark frame from a cmos camera.

But if I use a 1280x960 image as input under the same conditions, I get meanframe(0)=-454.69 stdframe1(0)=14832.8 which is absolutely wrong - negative number for mean!

Additional info:

meanframe1=mean(m1);

gives the correct answer even for large matrices. So, meanStdDev along seems to be the culprit....

More additional info:

my own code for StdDev also gives correct results,

meanframe1=mean(m1);
double dstddev = 0.0;
                                    double dmean = meanframe1(0); // only one channel

                                    for (int i = 0; i < w*h; i++)
                                    {
                                        dstddev += (dmean - m1.at<ushort>(i)) * (dmean - m1.at<ushort>(i));
                                    }

                                    dstddev = sqrt(dstddev / (w*h));

                                    std::cout<<"mean="<<meanframe1(0)<<std::endl;
                                    std::cout<<"stddev="<<dstddev<<std::endl;
2018-01-24 04:11:46 -0600 received badge  Scholar (source)
2018-01-21 22:42:57 -0600 edited question meanStdDev seems to have a bug? Or am I using it wrong?

meanStdDev seems to have a bug? Or am I using it wrong? When I use meanStdDev for an array with more than a million elem

2018-01-21 22:21:22 -0600 commented question meanStdDev seems to have a bug? Or am I using it wrong?

Have edited my question to remove the "unsigned int" from the array, since that may be incorrect :)

2018-01-21 22:20:07 -0600 edited question meanStdDev seems to have a bug? Or am I using it wrong?

meanStdDev seems to have a bug? Or am I using it wrong? When I use meanStdDev for an array with more than a million elem

2018-01-21 22:14:51 -0600 commented question meanStdDev seems to have a bug? Or am I using it wrong?

Sorry for the confusion. My data comes from a QHY camera. (The deprecated code is from a QHY sample :) The code for gett

2018-01-21 22:04:55 -0600 commented question meanStdDev seems to have a bug? Or am I using it wrong?

and after that, m=cvarrToMat(img, true);

2018-01-21 22:01:09 -0600 commented question meanStdDev seems to have a bug? Or am I using it wrong?

cvarrToMat, from https://docs.opencv.org/2.4/modules/core/doc/operations_on_arrays.html#Mat%20cvarrToMat That part is

2018-01-21 20:34:11 -0600 received badge  Student (source)
2018-01-21 20:28:18 -0600 received badge  Editor (source)
2018-01-21 20:28:18 -0600 edited question meanStdDev seems to have a bug? Or am I using it wrong?

meanStdDev seems to have a bug? Or am I using it wrong? When I use meanStdDev for an unsigned int array with more than a

2018-01-21 20:19:03 -0600 asked a question meanStdDev seems to have a bug? Or am I using it wrong?

meanStdDev seems to have a bug? Or am I using it wrong? When I use meanStdDev for an unsigned int array with more than a