c++ - Calculating sum of a subset of Mat OpenCV -


can calculate directly without using loops sum of subset of mat element in opencv (c++)?

example: mat b_hist, has 1 column , 256 rows. how can calculate sum of rows 0 105 rows or 106 150 rows?

i know sum(b_hist) give sum of entire mat. how can of subset? there similar method? can please tell it?

you can first use cv::range sub-mats want , sum on them:

cv::mat sub_mat_1 = mat(cv::range(0, 106),   cv::range::all()); cv::mat sub_mat_2 = mat(cv::range(106, 151), cv::range::all());  std::cout << cv::sum(sub_mat_1).val[0] << std::endl; std::cout << cv::sum(sub_mat_2).val[0] << std::endl; 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -