Sum of each column opencv -


in matlab, if matrix, sum(a) treats columns of vectors, returning row vector of sums of each column.

sum(image); how done opencv?

for 8 bit greyscale image, following should work (i think). shouldn't hard expand different image types.

int imgstep = image->widthstep; uchar* imagedata = (uchar*)image->imagedata; uint result[image->width]; memset(result, 0, sizeof(uchar) * image->width); (int col = 0; col < image->width; col++) {   (int row = 0; row < image->height; row++) {     result[col] += imagedata[row * imgstep + col];   } }  // desired vector in result 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -