OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Mon, 03 Dec 2012 14:34:43 -0600cv::sum() and cv::norm() for CV_U8...http://answers.opencv.org/question/4843/cvsum-and-cvnorm-for-cv_u8/result of cv::sum() is double - could you please tell how calculation is performed for CV_8U Matrix?
Same question for cv::norm() please
Will it convert to double every element or result only?
Also could you please tell how to locate implementation in source code as direct search shows only *.hpp?Mon, 03 Dec 2012 10:45:17 -0600http://answers.opencv.org/question/4843/cvsum-and-cvnorm-for-cv_u8/Answer by AlexanderShishkov for <p>result of cv::sum() is double - could you please tell how calculation is performed for CV_8U Matrix?
Same question for cv::norm() please </p>
<p>Will it convert to double every element or result only? </p>
<p>Also could you please tell how to locate implementation in source code as direct search shows only *.hpp?</p>
http://answers.opencv.org/question/4843/cvsum-and-cvnorm-for-cv_u8/?answer=4848#post-id-4848Both these functions are implemented in stat.cpp file (https://github.com/Itseez/opencv/blob/master/modules/core/src/stat.cpp).
cv::sum():
For calculation sum of CV_8U matrix we split matrix to few pieces. After that we sum each piece to int value and add this int value to the result double value.
cv::norm():
Similarly to sum. E.g. we sum the squares of the values to the integer variable and then add this value to the double value for L2 norm. After calculating the sum we call sqrt() function.
Mon, 03 Dec 2012 14:34:43 -0600http://answers.opencv.org/question/4843/cvsum-and-cvnorm-for-cv_u8/?answer=4848#post-id-4848