Ask Your Question
1

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
3

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

AlexanderShishkov gravatar image

Both 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.

edit flag offensive delete link more

Question Tools

Stats

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

Seen: 15,886 times

Last updated: Dec 03 '12