Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Function in OpenCV to find mean / avg over any one dimension (rows/cols) simultaneously

Tags:

c++

opencv

I know that there are Opencv functions mean() for c++ and cvAvg for C , which find average of an image for all channels. I need to find average / mean of all channels of an image in just one direction i.e. mean over all columns (result:a single row vector) and mean over all rows (result:single column vector). Is there any function or efficient method (probably without splitting the channels or using for loop) to do so ?

like image 227
Prakruti Avatar asked Jan 02 '14 12:01

Prakruti


1 Answers

reduce should do the trick.

Mat row_mean, col_mean;
reduce(img,row_mean, 0, CV_REDUCE_AVG);
reduce(img,col_mean, 1, CV_REDUCE_AVG);
like image 150
berak Avatar answered Oct 22 '22 02:10

berak