Ask Your Question

cv::sum() and cv::norm() for CV_U8...

asked 2012-12-03 10:45:17 -0600

ryhor gravatar image

updated 2012-12-03 10:46:17 -0600

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?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2012-12-03 14:34:43 -0600

AlexanderShishkov gravatar image

Both these functions are implemented in stat.cpp file (

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.

edit flag offensive delete link more

Question Tools


Asked: 2012-12-03 10:45:17 -0600

Seen: 15,711 times

Last updated: Dec 03 '12